2011-11-17 21:29:14 +01:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2011-09-20 15:56:33 +02:00
/*************************************************************************
*
2011-11-21 11:29:03 +01:00
* Effective License of whole file :
*
* This library is free software ; you can redistribute it and / or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 , as published by the Free Software Foundation .
*
* This library is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
* Lesser General Public License for more details .
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place , Suite 330 , Boston ,
* MA 02111 - 1307 USA
*
* Parts " Copyright by Sun Microsystems, Inc " prior to August 2011 :
*
* The Contents of this file are made available subject to the terms of
* the GNU Lesser General Public License Version 2.1
*
* Copyright : 200 ? by Sun Microsystems , Inc .
*
* Contributor ( s ) : Joerg Budischewski
*
* All parts contributed on or after August 2011 :
*
2013-04-24 17:14:03 +01:00
* This Source Code Form is subject to the terms of the Mozilla Public
* License , v . 2.0 . If a copy of the MPL was not distributed with this
* file , You can obtain one at http : //mozilla.org/MPL/2.0/.
2011-09-20 15:56:33 +02:00
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2011-08-05 12:08:40 +02:00
2011-08-02 16:10:00 +02:00
# include <rtl/ustrbuf.hxx>
# include <rtl/strbuf.hxx>
# include <cppuhelper/queryinterface.hxx>
# include <cppuhelper/typeprovider.hxx>
# include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
# include "pq_updateableresultset.hxx"
# include "pq_resultsetmetadata.hxx"
# include "pq_tools.hxx"
# include "pq_statics.hxx"
2011-08-02 16:13:35 +02:00
# include <string.h>
2013-06-27 12:56:40 +02:00
# include <connectivity/dbconversion.hxx>
2011-08-02 16:10:00 +02:00
using osl : : MutexGuard ;
using com : : sun : : star : : uno : : Reference ;
using com : : sun : : star : : uno : : makeAny ;
using com : : sun : : star : : uno : : Sequence ;
using com : : sun : : star : : uno : : UNO_QUERY ;
using com : : sun : : star : : uno : : Any ;
using com : : sun : : star : : uno : : Type ;
using com : : sun : : star : : uno : : RuntimeException ;
using com : : sun : : star : : sdbc : : XGeneratedResultSet ;
using com : : sun : : star : : sdbc : : XResultSetMetaDataSupplier ;
using com : : sun : : star : : sdbc : : SQLException ;
using com : : sun : : star : : sdbc : : XResultSet ;
using com : : sun : : star : : sdbc : : XCloseable ;
using com : : sun : : star : : sdbc : : XColumnLocate ;
using com : : sun : : star : : sdbc : : XResultSetUpdate ;
using com : : sun : : star : : sdbc : : XRowUpdate ;
using com : : sun : : star : : sdbc : : XRow ;
using com : : sun : : star : : sdbc : : XStatement ;
using com : : sun : : star : : beans : : XFastPropertySet ;
using com : : sun : : star : : beans : : XPropertySet ;
using com : : sun : : star : : beans : : XMultiPropertySet ;
2013-06-27 12:56:40 +02:00
using namespace dbtools ;
2011-08-02 16:10:00 +02:00
namespace pq_sdbc_driver
{
com : : sun : : star : : uno : : Reference < com : : sun : : star : : sdbc : : XCloseable > UpdateableResultSet : : createFromPGResultSet (
const : : rtl : : Reference < RefCountedMutex > & mutex ,
const com : : sun : : star : : uno : : Reference < com : : sun : : star : : uno : : XInterface > & owner ,
ConnectionSettings * * ppSettings ,
PGresult * result ,
2013-04-07 12:06:47 +02:00
const OUString & schema ,
const OUString & table ,
const com : : sun : : star : : uno : : Sequence < OUString > & primaryKey )
2011-08-02 16:10:00 +02:00
{
ConnectionSettings * pSettings = * ppSettings ;
sal_Int32 columnCount = PQnfields ( result ) ;
sal_Int32 rowCount = PQntuples ( result ) ;
Sequence < OUString > columnNames ( columnCount ) ;
for ( int i = 0 ; i < columnCount ; i + + )
{
char * name = PQfname ( result , i ) ;
2013-04-07 12:06:47 +02:00
columnNames [ i ] = OUString ( name , strlen ( name ) , pSettings - > encoding ) ;
2011-08-02 16:10:00 +02:00
}
Sequence < Sequence < Any > > data ( rowCount ) ;
// copy all the data into unicode strings (also binaries, as we yet
// don't know, what a binary is and what not!)
for ( int row = 0 ; row < rowCount ; row + + )
{
Sequence < Any > aRow ( columnCount ) ;
for ( int col = 0 ; col < columnCount ; col + + )
{
if ( ! PQgetisnull ( result , row , col ) )
{
char * val = PQgetvalue ( result , row , col ) ;
aRow [ col ] = makeAny (
2013-04-07 12:06:47 +02:00
OUString ( val , strlen ( val ) , ( * ppSettings ) - > encoding ) ) ;
2011-08-02 16:10:00 +02:00
}
}
data [ row ] = aRow ;
}
UpdateableResultSet * pRS = new UpdateableResultSet (
mutex , owner , columnNames , data , ppSettings , schema , table , primaryKey ) ;
Reference < XCloseable > ret = pRS ; // give it an refcount
pRS - > m_meta = new ResultSetMetaData ( mutex , pRS , 0 , ppSettings , result , schema , table ) ;
PQclear ( result ) ; // we don't need it anymore
return ret ;
}
com : : sun : : star : : uno : : Any UpdateableResultSet : : queryInterface (
const com : : sun : : star : : uno : : Type & reqType )
2014-02-25 21:31:58 +01:00
throw ( com : : sun : : star : : uno : : RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
Any ret = SequenceResultSet : : queryInterface ( reqType ) ;
if ( ! ret . hasValue ( ) )
ret = : : cppu : : queryInterface (
reqType ,
static_cast < XResultSetUpdate * > ( this ) ,
static_cast < XRowUpdate * > ( this ) ) ;
return ret ;
}
com : : sun : : star : : uno : : Sequence < com : : sun : : star : : uno : : Type > UpdateableResultSet : : getTypes ( )
2014-02-25 21:31:58 +01:00
throw ( com : : sun : : star : : uno : : RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
static cppu : : OTypeCollection * pCollection ;
if ( ! pCollection )
{
MutexGuard guard ( osl : : Mutex : : getGlobalMutex ( ) ) ;
if ( ! pCollection )
{
static cppu : : OTypeCollection collection (
2014-05-22 23:19:05 +02:00
cppu : : UnoType < XResultSetUpdate > : : get ( ) ,
cppu : : UnoType < XRowUpdate > : : get ( ) ,
2011-08-02 16:10:00 +02:00
SequenceResultSet : : getTypes ( ) ) ;
pCollection = & collection ;
}
}
return pCollection - > getTypes ( ) ;
}
com : : sun : : star : : uno : : Sequence < sal_Int8 > UpdateableResultSet : : getImplementationId ( )
2014-02-25 21:31:58 +01:00
throw ( com : : sun : : star : : uno : : RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
2014-03-10 11:41:06 +01:00
return css : : uno : : Sequence < sal_Int8 > ( ) ;
2011-08-02 16:10:00 +02:00
}
OUString UpdateableResultSet : : buildWhereClause ( )
{
OUString ret ;
if ( m_primaryKey . getLength ( ) )
{
OUStringBuffer buf ( 128 ) ;
2013-11-19 17:06:06 +02:00
buf . append ( " WHERE " ) ;
2011-08-02 16:10:00 +02:00
for ( int i = 0 ; i < m_primaryKey . getLength ( ) ; i + + )
{
if ( i > 0 )
2013-11-19 17:06:06 +02:00
buf . append ( " AND " ) ;
2011-08-02 16:10:00 +02:00
sal_Int32 index = findColumn ( m_primaryKey [ i ] ) ;
2011-08-12 16:56:43 +02:00
bufferQuoteIdentifier ( buf , m_primaryKey [ i ] , * m_ppSettings ) ;
2013-11-19 17:06:06 +02:00
buf . append ( " = " ) ;
2011-08-12 16:56:43 +02:00
bufferQuoteConstant ( buf , getString ( index ) , * m_ppSettings ) ;
2011-08-02 16:10:00 +02:00
}
ret = buf . makeStringAndClear ( ) ;
}
return ret ;
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : insertRow ( ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
MutexGuard guard ( m_refMutex - > mutex ) ;
if ( isLog ( * m_ppSettings , LogLevel : : INFO ) )
{
log ( * m_ppSettings , LogLevel : : INFO , " UpdateableResultSet::insertRow got called " ) ;
}
if ( ! m_insertRow )
throw SQLException (
2013-02-01 09:33:19 +01:00
" pq_resultset.insertRow: moveToInsertRow has not been called ! " ,
2011-08-02 16:10:00 +02:00
* this , OUString ( ) , 1 , Any ( ) ) ;
OUStringBuffer buf ( 128 ) ;
2013-11-19 17:06:06 +02:00
buf . append ( " INSERT INTO " ) ;
2011-08-12 16:56:43 +02:00
bufferQuoteQualifiedIdentifier ( buf , m_schema , m_table , * m_ppSettings ) ;
2013-11-19 17:06:06 +02:00
buf . append ( " ( " ) ;
2011-08-02 16:10:00 +02:00
int columns = 0 ;
2011-08-05 15:58:37 +02:00
for ( UpdateableFieldVector : : size_type i = 0 ; i < m_updateableField . size ( ) ; i + + )
2011-08-02 16:10:00 +02:00
{
if ( m_updateableField [ i ] . isTouched )
{
if ( columns > 0 )
2013-11-19 17:06:06 +02:00
buf . append ( " , " ) ;
2011-08-02 16:10:00 +02:00
columns + + ;
2011-08-12 16:56:43 +02:00
bufferQuoteIdentifier ( buf , m_columnNames [ i ] , * m_ppSettings ) ;
2011-08-02 16:10:00 +02:00
}
}
2013-11-19 17:06:06 +02:00
buf . append ( " ) VALUES ( " ) ;
2011-08-02 16:10:00 +02:00
columns = 0 ;
2011-08-05 15:58:37 +02:00
for ( UpdateableFieldVector : : size_type i = 0 ; i < m_updateableField . size ( ) ; i + + )
2011-08-02 16:10:00 +02:00
{
if ( m_updateableField [ i ] . isTouched )
{
if ( columns > 0 )
2013-11-19 17:06:06 +02:00
buf . append ( " , " ) ;
2011-08-02 16:10:00 +02:00
columns + + ;
2011-08-12 16:56:43 +02:00
bufferQuoteAnyConstant ( buf , m_updateableField [ i ] . value , * m_ppSettings ) ;
2011-08-02 16:10:00 +02:00
// OUString val;
// m_updateableField[i].value >>= val;
// buf.append( val );
2013-04-07 12:06:47 +02:00
// OStringToOUString(val, (*m_ppSettings)->encoding ) );
2011-08-02 16:10:00 +02:00
}
}
2013-11-19 17:06:06 +02:00
buf . append ( " ) " ) ;
2011-08-02 16:10:00 +02:00
Reference < XStatement > stmt =
extractConnectionFromStatement ( m_owner ) - > createStatement ( ) ;
DisposeGuard dispGuard ( stmt ) ;
stmt - > executeUpdate ( buf . makeStringAndClear ( ) ) ;
// reflect the changes !
m_rowCount + + ;
m_data . realloc ( m_rowCount ) ;
m_data [ m_rowCount - 1 ] = Sequence < Any > ( m_fieldCount ) ;
Reference < XGeneratedResultSet > result ( stmt , UNO_QUERY ) ;
if ( result . is ( ) )
{
Reference < XResultSet > rs = result - > getGeneratedValues ( ) ;
if ( rs . is ( ) & & rs - > next ( ) )
{
Reference < XColumnLocate > columnLocate ( rs , UNO_QUERY ) ;
Reference < XRow > xRow ( rs , UNO_QUERY ) ;
2011-08-05 15:58:37 +02:00
for ( int i = 0 ; i < m_fieldCount ; i + + )
2011-08-02 16:10:00 +02:00
{
int field = columnLocate - > findColumn ( m_columnNames [ i ] ) ;
if ( field > = 1 )
{
m_data [ m_rowCount - 1 ] [ i ] < < = xRow - > getString ( field ) ;
// printf( "adding %s %s\n" ,
// OUStringToOString( m_columnNames[i], RTL_TEXTENCODING_ASCII_US).getStr(),
// OUStringToOString( xRow->getString( field ), RTL_TEXTENCODING_ASCII_US).getStr() );
}
}
}
else
{
// do the best we can ( DEFAULT and AUTO increment values fail ! )
for ( int i = 0 ; i < m_fieldCount ; i + + )
{
if ( m_updateableField [ i ] . isTouched )
m_data [ m_rowCount - 1 ] [ i ] = m_updateableField [ i ] . value ;
}
}
}
// cleanup
m_updateableField = UpdateableFieldVector ( ) ;
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateRow ( ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
MutexGuard guard ( m_refMutex - > mutex ) ;
if ( isLog ( * m_ppSettings , LogLevel : : INFO ) )
{
log ( * m_ppSettings , LogLevel : : INFO , " UpdateableResultSet::updateRow got called " ) ;
}
if ( m_insertRow )
throw SQLException (
2013-02-01 09:33:19 +01:00
" pq_resultset.updateRow: moveToCurrentRow has not been called ! " ,
2011-08-02 16:10:00 +02:00
* this , OUString ( ) , 1 , Any ( ) ) ;
OUStringBuffer buf ( 128 ) ;
2013-11-19 17:06:06 +02:00
buf . append ( " UPDATE " ) ;
2011-08-12 16:56:43 +02:00
bufferQuoteQualifiedIdentifier ( buf , m_schema , m_table , * m_ppSettings ) ;
2013-11-19 17:06:06 +02:00
buf . append ( " SET " ) ;
2011-08-02 16:10:00 +02:00
2011-08-05 15:58:37 +02:00
int columns = 0 ;
for ( UpdateableFieldVector : : size_type i = 0 ; i < m_updateableField . size ( ) ; i + + )
2011-08-02 16:10:00 +02:00
{
if ( m_updateableField [ i ] . isTouched )
{
if ( columns > 0 )
2013-11-19 17:06:06 +02:00
buf . append ( " , " ) ;
2011-08-02 16:10:00 +02:00
columns + + ;
buf . append ( m_columnNames [ i ] ) ;
2013-11-19 17:06:06 +02:00
buf . append ( " = " ) ;
2011-08-12 16:56:43 +02:00
bufferQuoteAnyConstant ( buf , m_updateableField [ i ] . value , * m_ppSettings ) ;
2011-08-02 16:10:00 +02:00
// OUString val;
// m_updateableField[i].value >>= val;
// bufferQuoteConstant( buf, val ):
// buf.append( val );
}
}
buf . append ( buildWhereClause ( ) ) ;
Reference < XStatement > stmt = extractConnectionFromStatement ( m_owner ) - > createStatement ( ) ;
DisposeGuard dispGuard ( stmt ) ;
stmt - > executeUpdate ( buf . makeStringAndClear ( ) ) ;
// reflect the changes !
2011-08-05 15:58:37 +02:00
for ( int i = 0 ; i < m_fieldCount ; i + + )
2011-08-02 16:10:00 +02:00
{
if ( m_updateableField [ i ] . isTouched )
m_data [ m_row ] [ i ] = m_updateableField [ i ] . value ;
}
m_updateableField = UpdateableFieldVector ( ) ;
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : deleteRow ( ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
if ( isLog ( * m_ppSettings , LogLevel : : INFO ) )
{
log ( * m_ppSettings , LogLevel : : INFO , " UpdateableResultSet::deleteRow got called " ) ;
}
if ( m_insertRow )
throw SQLException (
2013-02-01 09:33:19 +01:00
" pq_resultset.deleteRow: deleteRow cannot be called when on insert row ! " ,
2011-08-02 16:10:00 +02:00
* this , OUString ( ) , 1 , Any ( ) ) ;
if ( m_row < 0 | | m_row > = m_rowCount )
{
OUStringBuffer buf ( 128 ) ;
buf . appendAscii ( " deleteRow cannot be called on invalid row ( " ) ;
buf . append ( m_row ) ;
buf . appendAscii ( " ) " ) ;
throw SQLException ( buf . makeStringAndClear ( ) , * this , OUString ( ) , 0 , Any ( ) ) ;
}
Reference < XStatement > stmt = extractConnectionFromStatement ( m_owner ) - > createStatement ( ) ;
DisposeGuard dispGuard ( stmt ) ;
OUStringBuffer buf ( 128 ) ;
buf . appendAscii ( " DELETE FROM " ) ;
2011-08-12 16:56:43 +02:00
bufferQuoteQualifiedIdentifier ( buf , m_schema , m_table , * m_ppSettings ) ;
2011-08-02 16:10:00 +02:00
buf . appendAscii ( " " ) ;
buf . append ( buildWhereClause ( ) ) ;
stmt - > executeUpdate ( buf . makeStringAndClear ( ) ) ;
// reflect the changes !
for ( int i = m_row + 1 ; i < m_row ; i + + )
{
m_data [ i - 1 ] = m_data [ i ] ;
}
m_rowCount - - ;
m_data . realloc ( m_rowCount ) ;
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : cancelRowUpdates ( ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
MutexGuard guard ( m_refMutex - > mutex ) ;
m_updateableField = UpdateableFieldVector ( ) ;
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : moveToInsertRow ( ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
m_insertRow = true ;
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : moveToCurrentRow ( ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
m_insertRow = false ;
}
void UpdateableResultSet : : checkUpdate ( sal_Int32 columnIndex )
{
checkColumnIndex ( columnIndex ) ;
if ( m_updateableField . empty ( ) )
m_updateableField = UpdateableFieldVector ( m_fieldCount ) ;
m_updateableField [ columnIndex - 1 ] . isTouched = true ;
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateNull ( sal_Int32 columnIndex ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
MutexGuard guard ( m_refMutex - > mutex ) ;
checkClosed ( ) ;
checkUpdate ( columnIndex ) ;
m_updateableField [ columnIndex - 1 ] . value = Any ( ) ;
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateBoolean ( sal_Int32 columnIndex , sal_Bool x ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
MutexGuard guard ( m_refMutex - > mutex ) ;
checkClosed ( ) ;
checkUpdate ( columnIndex ) ;
Statics & st = getStatics ( ) ;
2013-03-26 21:03:47 +01:00
m_updateableField [ columnIndex - 1 ] . value < < = ( x ? st . TRUE : st . FALSE ) ;
2011-08-02 16:10:00 +02:00
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateByte ( sal_Int32 columnIndex , sal_Int8 x ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
updateInt ( columnIndex , x ) ;
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateShort ( sal_Int32 columnIndex , sal_Int16 x ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
updateInt ( columnIndex , x ) ;
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateInt ( sal_Int32 columnIndex , sal_Int32 x ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
updateLong ( columnIndex , x ) ;
// MutexGuard guard( m_refMutex->mutex );
// checkClosed();
// checkUpdate( columnIndex );
// m_updateableField[columnIndex-1].value <<= OUString::valueOf( x );
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateLong ( sal_Int32 columnIndex , sal_Int64 x ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
MutexGuard guard ( m_refMutex - > mutex ) ;
checkClosed ( ) ;
checkUpdate ( columnIndex ) ;
// OStringBuffer buf( 20 );
// buf.append( "'" );
// buf.append( (sal_Int64) x );
// buf.append( "'" );
2013-08-21 15:07:31 +02:00
m_updateableField [ columnIndex - 1 ] . value < < = OUString : : number ( x ) ;
2011-08-02 16:10:00 +02:00
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateFloat ( sal_Int32 columnIndex , float x ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
MutexGuard guard ( m_refMutex - > mutex ) ;
checkClosed ( ) ;
checkUpdate ( columnIndex ) ;
2013-08-21 15:07:31 +02:00
m_updateableField [ columnIndex - 1 ] . value < < = OUString : : number ( x ) ;
2011-08-02 16:10:00 +02:00
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateDouble ( sal_Int32 columnIndex , double x ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
MutexGuard guard ( m_refMutex - > mutex ) ;
checkClosed ( ) ;
checkUpdate ( columnIndex ) ;
2013-08-21 15:07:31 +02:00
m_updateableField [ columnIndex - 1 ] . value < < = OUString : : number ( x ) ;
2011-08-02 16:10:00 +02:00
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateString ( sal_Int32 columnIndex , const OUString & x ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
MutexGuard guard ( m_refMutex - > mutex ) ;
checkClosed ( ) ;
checkUpdate ( columnIndex ) ;
m_updateableField [ columnIndex - 1 ] . value < < = x ;
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateBytes ( sal_Int32 columnIndex , const : : com : : sun : : star : : uno : : Sequence < sal_Int8 > & x ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
MutexGuard guard ( m_refMutex - > mutex ) ;
checkClosed ( ) ;
checkUpdate ( columnIndex ) ;
size_t len ;
unsigned char * escapedString =
2015-01-17 18:17:00 +01:00
PQescapeBytea ( reinterpret_cast < unsigned char const * > ( x . getConstArray ( ) ) , x . getLength ( ) , & len ) ;
2011-08-02 16:10:00 +02:00
if ( ! escapedString )
{
throw SQLException (
2013-02-01 09:33:19 +01:00
" pq_preparedstatement.setBytes: Error during converting bytesequence to an SQL conform string " ,
2011-08-02 16:10:00 +02:00
* this , OUString ( ) , 1 , Any ( ) ) ;
}
// buf.append( (const sal_Char *)escapedString, len -1 );
m_updateableField [ columnIndex - 1 ] . value < < =
2015-01-17 18:17:00 +01:00
OUString ( reinterpret_cast < char * > ( escapedString ) , len , RTL_TEXTENCODING_ASCII_US ) ;
2011-08-02 16:10:00 +02:00
free ( escapedString ) ;
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateDate ( sal_Int32 columnIndex , const : : com : : sun : : star : : util : : Date & x ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
2013-06-27 12:56:40 +02:00
updateString ( columnIndex , DBTypeConversion : : toDateString ( x ) ) ;
2011-08-02 16:10:00 +02:00
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateTime ( sal_Int32 columnIndex , const : : com : : sun : : star : : util : : Time & x ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
2013-06-27 12:56:40 +02:00
updateString ( columnIndex , DBTypeConversion : : toTimeString ( x ) ) ;
2011-08-02 16:10:00 +02:00
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateTimestamp ( sal_Int32 columnIndex , const : : com : : sun : : star : : util : : DateTime & x ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
2013-06-27 12:56:40 +02:00
updateString ( columnIndex , DBTypeConversion : : toDateTimeString ( x ) ) ;
2011-08-02 16:10:00 +02:00
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateBinaryStream ( sal_Int32 /* columnIndex */ , const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : io : : XInputStream > & /* x */ , sal_Int32 /* length */ ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateCharacterStream ( sal_Int32 /* columnIndex */ , const : : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : io : : XInputStream > & /* x */ , sal_Int32 /* length */ ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateObject ( sal_Int32 /* columnIndex */ , const : : com : : sun : : star : : uno : : Any & /* x */ ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
}
2014-02-25 21:31:58 +01:00
void UpdateableResultSet : : updateNumericObject ( sal_Int32 /* columnIndex */ , const : : com : : sun : : star : : uno : : Any & /* x */ , sal_Int32 /* scale */ ) throw ( SQLException , RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
}
: : com : : sun : : star : : uno : : Reference < : : com : : sun : : star : : sdbc : : XResultSetMetaData > UpdateableResultSet : : getMetaData ( )
2014-02-25 21:31:58 +01:00
throw ( : : com : : sun : : star : : sdbc : : SQLException , : : com : : sun : : star : : uno : : RuntimeException , std : : exception )
2011-08-02 16:10:00 +02:00
{
return m_meta ;
}
Sequence < Type > UpdateableResultSet : : getStaticTypes ( bool updateable )
throw ( com : : sun : : star : : uno : : RuntimeException )
{
if ( updateable )
{
cppu : : OTypeCollection collection (
2014-05-22 23:19:05 +02:00
cppu : : UnoType < XResultSetUpdate > : : get ( ) ,
cppu : : UnoType < XRowUpdate > : : get ( ) ,
// cppu::UnoType<com::sun::star::sdbcx::XRowLocate>::get(),
2011-08-02 16:10:00 +02:00
getStaticTypes ( false /* updateable */ ) ) ;
return collection . getTypes ( ) ;
}
else
{
cppu : : OTypeCollection collection (
2014-05-22 23:19:05 +02:00
cppu : : UnoType < XResultSet > : : get ( ) ,
cppu : : UnoType < XResultSetMetaDataSupplier > : : get ( ) ,
cppu : : UnoType < XRow > : : get ( ) ,
cppu : : UnoType < XColumnLocate > : : get ( ) ,
cppu : : UnoType < XCloseable > : : get ( ) ,
cppu : : UnoType < XPropertySet > : : get ( ) ,
cppu : : UnoType < XFastPropertySet > : : get ( ) ,
cppu : : UnoType < XMultiPropertySet > : : get ( ) ,
cppu : : UnoType < com : : sun : : star : : lang : : XComponent > : : get ( ) , // OComponentHelper
cppu : : UnoType < com : : sun : : star : : lang : : XTypeProvider > : : get ( ) ,
cppu : : UnoType < com : : sun : : star : : uno : : XAggregation > : : get ( ) ,
cppu : : UnoType < com : : sun : : star : : uno : : XWeak > : : get ( ) ) ;
2011-08-02 16:10:00 +02:00
return collection . getTypes ( ) ;
}
}
}
2014-02-18 12:11:15 +00:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */