1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_connectivity.hxx" 26 #include "AutoRetrievingBase.hxx" 27 28 namespace connectivity 29 { getTransformedGeneratedStatement(const::rtl::OUString & _sInsertStatement) const30 ::rtl::OUString OAutoRetrievingBase::getTransformedGeneratedStatement(const ::rtl::OUString& _sInsertStatement) const 31 { 32 ::rtl::OUString sStmt = _sInsertStatement; 33 OSL_ENSURE( m_bAutoRetrievingEnabled,"Illegal call here. isAutoRetrievingEnabled is false!"); 34 sStmt = sStmt.toAsciiUpperCase(); 35 ::rtl::OUString sStatement; 36 if ( sStmt.compareToAscii("INSERT",6) == 0 ) 37 { 38 sStatement = m_sGeneratedValueStatement; 39 static const ::rtl::OUString sColumn(RTL_CONSTASCII_USTRINGPARAM("$column")); 40 static const ::rtl::OUString sTable(RTL_CONSTASCII_USTRINGPARAM("$table")); 41 sal_Int32 nIndex = 0; 42 nIndex = sStatement.indexOf(sColumn,nIndex); 43 if ( -1 != nIndex ) 44 { // we need a column 45 } 46 nIndex = 0; 47 nIndex = sStatement.indexOf(sTable,nIndex); 48 if ( -1 != nIndex ) 49 { // we need a table name 50 sal_Int32 nIntoIndex = sStmt.indexOf(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INTO "))); 51 sStmt = sStmt.copy(nIntoIndex+5); 52 do 53 { 54 if ( sStmt.indexOf(' ') == 0 ) 55 sStmt = sStmt.copy(1); 56 } 57 while (sStmt.indexOf(' ') == 0 ); 58 59 nIntoIndex = 0; 60 ::rtl::OUString sTableName = sStmt.getToken(0,' ',nIntoIndex); 61 sStatement = sStatement.replaceAt(nIndex,sTable.getLength(),sTableName); 62 } 63 } 64 return sStatement; 65 } 66 } 67 68