1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * Effective License of whole file:
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software Foundation.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
22 * The Contents of this file are made available subject to the terms of
23 * the GNU Lesser General Public License Version 2.1
25 * Copyright: 2000 by Sun Microsystems, Inc.
27 * Contributor(s): Joerg Budischewski
29 * All parts contributed on or after August 2011:
31 * This Source Code Form is subject to the terms of the Mozilla Public
32 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
35 ************************************************************************/
37 #include "pq_preparedstatement.hxx"
38 #include "pq_resultset.hxx"
39 #include "pq_tools.hxx"
40 #include "pq_statics.hxx"
41 #include "pq_statement.hxx"
43 #include <rtl/strbuf.hxx>
44 #include <rtl/ustrbuf.hxx>
47 #include <cppuhelper/typeprovider.hxx>
48 #include <cppuhelper/queryinterface.hxx>
50 #include <com/sun/star/beans/PropertyAttribute.hpp>
52 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
53 #include <com/sun/star/sdbc/ResultSetType.hpp>
57 #include <connectivity/dbconversion.hxx>
60 using osl::MutexGuard
;
63 using com::sun::star::uno::Any
;
64 using com::sun::star::uno::makeAny
;
65 using com::sun::star::uno::Type
;
66 using com::sun::star::uno::RuntimeException
;
67 using com::sun::star::uno::Exception
;
68 using com::sun::star::uno::Sequence
;
69 using com::sun::star::uno::Reference
;
70 using com::sun::star::uno::XInterface
;
71 using com::sun::star::uno::UNO_QUERY
;
73 using com::sun::star::lang::IllegalArgumentException
;
75 using com::sun::star::sdbc::XWarningsSupplier
;
76 using com::sun::star::sdbc::XCloseable
;
77 using com::sun::star::sdbc::XPreparedStatement
;
78 using com::sun::star::sdbc::XParameters
;
79 using com::sun::star::sdbc::XResultSet
;
80 using com::sun::star::sdbc::XRef
;
81 using com::sun::star::sdbc::XBlob
;
82 using com::sun::star::sdbc::XClob
;
83 using com::sun::star::sdbc::XArray
;
84 using com::sun::star::sdbc::XConnection
;
85 using com::sun::star::sdbc::XGeneratedResultSet
;
86 using com::sun::star::sdbc::SQLException
;
88 using com::sun::star::beans::Property
;
89 using com::sun::star::beans::XPropertySetInfo
;
90 using com::sun::star::beans::XPropertySet
;
91 using com::sun::star::beans::XMultiPropertySet
;
92 using com::sun::star::beans::XFastPropertySet
;
94 using namespace dbtools
;
96 namespace pq_sdbc_driver
98 static ::cppu::IPropertyArrayHelper
& getPreparedStatementPropertyArrayHelper()
100 static ::cppu::IPropertyArrayHelper
*pArrayHelper
;
103 MutexGuard
guard( Mutex::getGlobalMutex() );
106 static Property aTable
[] =
109 OUString("CursorName"), 0,
110 ::cppu::UnoType
<OUString
>::get() , 0 ),
112 OUString("EscapeProcessing"), 1,
113 ::getBooleanCppuType() , 0 ),
115 OUString("FetchDirection"), 2,
116 ::cppu::UnoType
<sal_Int32
>::get() , 0 ),
118 OUString("FetchSize"), 3,
119 ::cppu::UnoType
<sal_Int32
>::get() , 0 ),
121 OUString("MaxFieldSize"), 4,
122 ::cppu::UnoType
<sal_Int32
>::get() , 0 ),
124 OUString("MaxRows"), 5,
125 ::cppu::UnoType
<sal_Int32
>::get() , 0 ),
127 OUString("QueryTimeOut"), 6,
128 ::cppu::UnoType
<sal_Int32
>::get() , 0 ),
130 OUString("ResultSetConcurrency"), 7,
131 ::cppu::UnoType
<sal_Int32
>::get() , 0 ),
133 OUString("ResultSetType"), 8,
134 ::cppu::UnoType
<sal_Int32
>::get() , 0 )
136 OSL_ASSERT( sizeof(aTable
)/ sizeof(Property
) == PREPARED_STATEMENT_SIZE
);
137 static ::cppu::OPropertyArrayHelper
arrayHelper( aTable
, PREPARED_STATEMENT_SIZE
, sal_True
);
138 pArrayHelper
= &arrayHelper
;
141 return *pArrayHelper
;
144 static bool isOperator( char c
)
146 static const char * operators
= "<>=()!/&%.,;";
148 const char * w
= operators
;
149 while (*w
&& *w
!= c
)
156 static bool isNamedParameterStart( const OString
& o
, int index
)
158 return o
[index
] == ':' && (
159 isWhitespace( o
[index
-1] ) || isOperator(o
[index
-1]) );
162 static bool isQuoted( const OString
& str
)
164 return str
[0] == '"' || str
[0] == '\'';
167 PreparedStatement::PreparedStatement(
168 const ::rtl::Reference
< RefCountedMutex
> & refMutex
,
169 const Reference
< XConnection
> & conn
,
170 struct ConnectionSettings
*pSettings
,
171 const OString
& stmt
)
172 : OComponentHelper(refMutex
->mutex
)
173 , OPropertySetHelper(OComponentHelper::rBHelper
)
175 , m_pSettings(pSettings
)
177 , m_refMutex(refMutex
)
178 , m_multipleResultAvailable(false)
179 , m_multipleResultUpdateCount(0)
180 , m_lastOidInserted( InvalidOid
)
182 m_props
[PREPARED_STATEMENT_QUERY_TIME_OUT
] = makeAny( (sal_Int32
)0 );
183 m_props
[PREPARED_STATEMENT_MAX_ROWS
] = makeAny( (sal_Int32
)0 );
184 m_props
[PREPARED_STATEMENT_RESULT_SET_CONCURRENCY
] = makeAny(
185 com::sun::star::sdbc::ResultSetConcurrency::READ_ONLY
);
186 m_props
[PREPARED_STATEMENT_RESULT_SET_TYPE
] = makeAny(
187 com::sun::star::sdbc::ResultSetType::SCROLL_INSENSITIVE
);
189 splitSQL( m_stmt
, m_splittedStatement
);
191 for( int i
= 0, max
= m_splittedStatement
.size(); i
< max
; i
++ )
193 const OString
&str
= m_splittedStatement
[i
];
194 // ignore quoted strings ....
195 if( ! isQuoted( str
) )
197 // the ':' cannot be the first or the last part of the
199 // the ? cannot be the first part of the token , so we start
201 for( int index
= 1 ; index
< str
.getLength() ; index
++ )
203 if( str
[index
] == '?' ||
204 isNamedParameterStart( str
, index
)
212 m_vars
= OStringVector ( elements
);
215 PreparedStatement::~PreparedStatement()
217 POSTGRE_TRACE( "dtor PreparedStatement" );
220 void PreparedStatement::checkColumnIndex( sal_Int32 parameterIndex
)
222 if( parameterIndex
< 1 || parameterIndex
> (sal_Int32
) m_vars
.size() )
224 OUStringBuffer
buf( 128 );
225 buf
.appendAscii( "pq_preparedstatement: parameter index out of range (expected 1 to " );
226 buf
.append( (sal_Int32
) m_vars
.size() );
227 buf
.appendAscii( ", got " );
228 buf
.append( parameterIndex
);
229 buf
.appendAscii( ", statement '" );
230 buf
.append( OStringToOUString( m_stmt
, m_pSettings
->encoding
) );
231 buf
.appendAscii( "')" );
232 throw SQLException( buf
.makeStringAndClear(), *this, OUString(), 1, Any () );
235 void PreparedStatement::checkClosed() throw (SQLException
, RuntimeException
)
237 if( ! m_pSettings
|| ! m_pSettings
->pConnection
)
239 "pq_driver: PreparedStatement or connection has already been closed !",
240 *this, OUString(),1,Any());
243 Any
PreparedStatement::queryInterface( const Type
& reqType
) throw (RuntimeException
, std::exception
)
247 ret
= OComponentHelper::queryInterface( reqType
);
248 if( ! ret
.hasValue() )
249 ret
= ::cppu::queryInterface( reqType
,
250 static_cast< XWarningsSupplier
* > ( this ),
251 static_cast< XPreparedStatement
* > ( this ),
252 static_cast< com::sun::star::sdbc::XResultSetMetaDataSupplier
* > ( this ),
253 static_cast< XParameters
* > ( this ),
254 static_cast< XCloseable
* > ( this ),
255 static_cast< XGeneratedResultSet
* > ( this ),
256 static_cast< XPropertySet
* > ( this ),
257 static_cast< XMultiPropertySet
* > ( this ),
258 static_cast< XFastPropertySet
* > ( this ) );
263 Sequence
< Type
> PreparedStatement::getTypes() throw ( RuntimeException
, std::exception
)
265 static cppu::OTypeCollection
*pCollection
;
268 MutexGuard
guard( osl::Mutex::getGlobalMutex() );
271 static cppu::OTypeCollection
collection(
272 getCppuType( (Reference
< XWarningsSupplier
> *) 0 ),
273 getCppuType( (Reference
< XPreparedStatement
> *) 0 ),
274 getCppuType( (Reference
< com::sun::star::sdbc::XResultSetMetaDataSupplier
> *) 0 ),
275 getCppuType( (Reference
< XParameters
> *) 0 ),
276 getCppuType( (Reference
< XCloseable
> *) 0 ),
277 getCppuType( (Reference
< XGeneratedResultSet
> *) 0 ),
278 getCppuType( (Reference
< XPropertySet
>*) 0 ),
279 getCppuType( (Reference
< XFastPropertySet
> *) 0 ),
280 getCppuType( (Reference
< XMultiPropertySet
> *) 0 ),
281 OComponentHelper::getTypes());
282 pCollection
= &collection
;
285 return pCollection
->getTypes();
288 Sequence
< sal_Int8
> PreparedStatement::getImplementationId() throw ( RuntimeException
, std::exception
)
290 return css::uno::Sequence
<sal_Int8
>();
293 void PreparedStatement::close( ) throw (SQLException
, RuntimeException
, std::exception
)
295 // let the connection die without acquired mutex !
296 Reference
< XConnection
> r
;
297 Reference
< XCloseable
> resultSet
;
299 MutexGuard
guard( m_refMutex
->mutex
);
302 m_connection
.clear();
304 resultSet
= m_lastResultset
;
305 m_lastResultset
.clear();
313 void PreparedStatement::raiseSQLException(
314 const char * errorMsg
, const char *errorType
)
315 throw( SQLException
)
317 OUStringBuffer
buf(128);
318 buf
.appendAscii( "pq_driver: ");
321 buf
.appendAscii( "[" );
322 buf
.appendAscii( errorType
);
323 buf
.appendAscii( "]" );
326 OUString( errorMsg
, strlen(errorMsg
) , m_pSettings
->encoding
) );
327 buf
.appendAscii( " (caused by statement '" );
328 buf
.appendAscii( m_executedStatement
.getStr() );
329 buf
.appendAscii( "')" );
330 OUString error
= buf
.makeStringAndClear();
331 log( m_pSettings
, LogLevel::ERROR
, error
);
332 throw SQLException( buf
.makeStringAndClear(), *this, OUString(), 1, Any() );
335 Reference
< XResultSet
> PreparedStatement::executeQuery( )
336 throw (SQLException
, RuntimeException
, std::exception
)
338 Reference
< XCloseable
> lastResultSet
= m_lastResultset
;
339 if( lastResultSet
.is() )
340 lastResultSet
->close();
344 raiseSQLException( "not a query" );
346 return Reference
< XResultSet
> ( m_lastResultset
, com::sun::star::uno::UNO_QUERY
);
349 sal_Int32
PreparedStatement::executeUpdate( )
350 throw (SQLException
, RuntimeException
, std::exception
)
354 raiseSQLException( "not a command" );
356 return m_multipleResultUpdateCount
;
359 sal_Bool
PreparedStatement::execute( )
360 throw (SQLException
, RuntimeException
, std::exception
)
362 osl::MutexGuard
guard( m_refMutex
->mutex
);
364 OStringBuffer
buf( m_stmt
.getLength() *2 );
366 OStringVector::size_type vars
= 0;
367 for( OStringVector::size_type i
= 0 ; i
< m_splittedStatement
.size() ; ++i
)
369 // LEM TODO: instead of this manual mucking with SQL
370 // could we use PQexecParams / PQExecPrepared / ...?
371 // Only snafu is giving the types of the parameters and
372 // that it needs $1, $2, etc instead of "?"
373 const OString
&str
= m_splittedStatement
[i
];
374 // printf( "Splitted %d %s\n" , i , str.getStr() );
375 if( isQuoted( str
) )
382 for( index
= 1 ; index
< str
.getLength() ; index
++ )
384 if( str
[index
] == '?' )
386 buf
.append( str
.getStr()+start
, index
- start
);
387 buf
.append( m_vars
[vars
] );
393 if ( isNamedParameterStart( str
, index
) )
395 buf
.append( str
.getStr()+start
, index
-start
);
396 buf
.append( m_vars
[vars
] );
398 // skip to the end of the named parameter
399 while ( index
< str
.getLength()
400 && !( isWhitespace(str
[index
])
401 || isOperator (str
[index
])))
410 // if( index +1 >= str.getLength() )
412 buf
.append( str
.getStr() + start
, index
-start
);
417 m_executedStatement
= buf
.makeStringAndClear();
419 m_lastResultset
.clear();
420 m_lastTableInserted
= OUString();
422 struct CommandData data
;
423 data
.refMutex
= m_refMutex
;
424 data
.ppSettings
= &m_pSettings
;
425 data
.pLastOidInserted
= &m_lastOidInserted
;
426 data
.pLastQuery
= &m_lastQuery
;
427 data
.pMultipleResultUpdateCount
= &m_multipleResultUpdateCount
;
428 data
.pMultipleResultAvailable
= &m_multipleResultAvailable
;
429 data
.pLastTableInserted
= &m_lastTableInserted
;
430 data
.pLastResultset
= &m_lastResultset
;
432 data
.tableSupplier
= Reference
< com::sun::star::sdbcx::XTablesSupplier
>( m_connection
, UNO_QUERY
);
433 data
.concurrency
= extractIntProperty( this, getStatics().RESULT_SET_CONCURRENCY
);
435 return executePostgresCommand( m_executedStatement
, &data
); // see pq_statement.cxx
438 Reference
< XConnection
> PreparedStatement::getConnection( )
439 throw (SQLException
, RuntimeException
, std::exception
)
441 Reference
< XConnection
> ret
;
443 MutexGuard
guard( m_refMutex
->mutex
);
451 void PreparedStatement::setNull( sal_Int32 parameterIndex
, sal_Int32 sqlType
)
452 throw (SQLException
, RuntimeException
, std::exception
)
455 MutexGuard
guard( m_refMutex
->mutex
);
457 checkColumnIndex( parameterIndex
);
458 m_vars
[parameterIndex
-1] = OString( "NULL" );
461 void PreparedStatement::setObjectNull(
462 sal_Int32 parameterIndex
, sal_Int32 sqlType
, const OUString
& typeName
)
463 throw (SQLException
, RuntimeException
, std::exception
)
465 (void) sqlType
; (void) typeName
;
466 MutexGuard
guard( m_refMutex
->mutex
);
468 checkColumnIndex( parameterIndex
);
469 m_vars
[parameterIndex
-1] = OString( "NULL" );
473 void PreparedStatement::setBoolean( sal_Int32 parameterIndex
, sal_Bool x
)
474 throw (SQLException
, RuntimeException
, std::exception
)
476 MutexGuard
guard(m_refMutex
->mutex
);
478 checkColumnIndex( parameterIndex
);
480 m_vars
[parameterIndex
-1] = OString( "'t'" );
482 m_vars
[parameterIndex
-1] = OString( "'f'" );
485 void PreparedStatement::setByte( sal_Int32 parameterIndex
, sal_Int8 x
)
486 throw (SQLException
, RuntimeException
, std::exception
)
488 setInt(parameterIndex
,x
);
491 void PreparedStatement::setShort( sal_Int32 parameterIndex
, sal_Int16 x
)
492 throw (SQLException
, RuntimeException
, std::exception
)
494 setInt(parameterIndex
, x
);
497 void PreparedStatement::setInt( sal_Int32 parameterIndex
, sal_Int32 x
)
498 throw (SQLException
, RuntimeException
, std::exception
)
500 // printf( "setString %d %d\n ", parameterIndex, x);
501 MutexGuard
guard(m_refMutex
->mutex
);
503 checkColumnIndex( parameterIndex
);
504 OStringBuffer
buf( 20 );
506 buf
.append( (sal_Int32
) x
);
508 m_vars
[parameterIndex
-1] = buf
.makeStringAndClear();
511 void PreparedStatement::setLong( sal_Int32 parameterIndex
, sal_Int64 x
)
512 throw (SQLException
, RuntimeException
, std::exception
)
514 MutexGuard
guard(m_refMutex
->mutex
);
516 checkColumnIndex( parameterIndex
);
517 OStringBuffer
buf( 20 );
519 buf
.append( (sal_Int64
) x
);
521 m_vars
[parameterIndex
-1] = buf
.makeStringAndClear();
524 void PreparedStatement::setFloat( sal_Int32 parameterIndex
, float x
)
525 throw (SQLException
, RuntimeException
, std::exception
)
527 MutexGuard
guard(m_refMutex
->mutex
);
529 checkColumnIndex( parameterIndex
);
530 OStringBuffer
buf( 20 );
534 m_vars
[parameterIndex
-1] = buf
.makeStringAndClear();
537 void PreparedStatement::setDouble( sal_Int32 parameterIndex
, double x
)
538 throw (SQLException
, RuntimeException
, std::exception
)
540 MutexGuard
guard(m_refMutex
->mutex
);
542 checkColumnIndex( parameterIndex
);
543 OStringBuffer
buf( 20 );
547 m_vars
[parameterIndex
-1] = buf
.makeStringAndClear();
550 void PreparedStatement::setString( sal_Int32 parameterIndex
, const OUString
& x
)
551 throw (SQLException
, RuntimeException
, std::exception
)
553 // printf( "setString %d %s\n ", parameterIndex,
554 // OUStringToOString( x , RTL_TEXTENCODING_ASCII_US ).getStr());
555 MutexGuard
guard(m_refMutex
->mutex
);
557 checkColumnIndex( parameterIndex
);
558 OStringBuffer
buf( 20 );
560 OString y
= OUStringToOString( x
, m_pSettings
->encoding
);
561 buf
.ensureCapacity( y
.getLength() * 2 + 2 );
562 int len
= PQescapeString( ((char*)buf
.getStr())+1, y
.getStr() , y
.getLength() );
563 buf
.setLength( 1 + len
);
565 m_vars
[parameterIndex
-1] = buf
.makeStringAndClear();
568 void PreparedStatement::setBytes(
569 sal_Int32 parameterIndex
, const Sequence
< sal_Int8
>& x
)
570 throw (SQLException
, RuntimeException
, std::exception
)
572 MutexGuard
guard(m_refMutex
->mutex
);
574 checkColumnIndex( parameterIndex
);
575 OStringBuffer
buf( 20 );
578 unsigned char * escapedString
=
579 PQescapeBytea( (unsigned char *)x
.getConstArray(), x
.getLength(), &len
);
580 if( ! escapedString
)
583 "pq_preparedstatement.setBytes: Error during converting bytesequence to an SQL conform string",
584 *this, OUString(), 1, Any() );
586 buf
.append( (const sal_Char
*)escapedString
, len
-1 );
587 free( escapedString
);
589 m_vars
[parameterIndex
-1] = buf
.makeStringAndClear();
593 void PreparedStatement::setDate( sal_Int32 parameterIndex
, const ::com::sun::star::util::Date
& x
)
594 throw (SQLException
, RuntimeException
, std::exception
)
596 setString( parameterIndex
, DBTypeConversion::toDateString( x
) );
599 void PreparedStatement::setTime( sal_Int32 parameterIndex
, const ::com::sun::star::util::Time
& x
)
600 throw (SQLException
, RuntimeException
, std::exception
)
602 setString( parameterIndex
, DBTypeConversion::toTimeString( x
) );
605 void PreparedStatement::setTimestamp(
606 sal_Int32 parameterIndex
, const ::com::sun::star::util::DateTime
& x
)
607 throw (SQLException
, RuntimeException
, std::exception
)
609 setString( parameterIndex
, DBTypeConversion::toDateTimeString( x
) );
612 void PreparedStatement::setBinaryStream(
613 sal_Int32 parameterIndex
,
614 const Reference
< ::com::sun::star::io::XInputStream
>& x
,
616 throw (SQLException
, RuntimeException
, std::exception
)
618 (void) parameterIndex
; (void)x
; (void) length
;
620 "pq_preparedstatement: setBinaryStream not implemented",
621 *this, OUString(), 1, Any () );
624 void PreparedStatement::setCharacterStream(
625 sal_Int32 parameterIndex
,
626 const Reference
< ::com::sun::star::io::XInputStream
>& x
,
628 throw (SQLException
, RuntimeException
, std::exception
)
630 (void) parameterIndex
; (void)x
; (void) length
;
632 "pq_preparedstatement: setCharacterStream not implemented",
633 *this, OUString(), 1, Any () );
636 void PreparedStatement::setObject( sal_Int32 parameterIndex
, const Any
& x
)
637 throw (SQLException
, RuntimeException
, std::exception
)
639 if( ! implSetObject( this, parameterIndex
, x
))
642 buf
.append( "pq_preparedstatement::setObject: can't convert value of type " );
643 buf
.append( x
.getValueTypeName() );
644 throw SQLException( buf
.makeStringAndClear(), *this, OUString(), 1, Any () );
648 void PreparedStatement::setObjectWithInfo(
649 sal_Int32 parameterIndex
,
651 sal_Int32 targetSqlType
,
653 throw (SQLException
, RuntimeException
, std::exception
)
656 if( com::sun::star::sdbc::DataType::DECIMAL
== targetSqlType
||
657 com::sun::star::sdbc::DataType::NUMERIC
== targetSqlType
)
659 double myDouble
= 0.0;
663 myString
= OUString::number( myDouble
);
669 if( !myString
.isEmpty() )
671 // printf( "setObjectWithInfo %s\n", OUStringToOString(myString,RTL_TEXTENCODING_ASCII_US).getStr());
672 setString( parameterIndex
, myString
);
677 buf
.append( "pq_preparedstatement::setObjectWithInfo: can't convert value of type " );
678 buf
.append( x
.getValueTypeName() );
679 buf
.append( " to type DECIMAL or NUMERIC" );
680 throw SQLException( buf
.makeStringAndClear(), *this, OUString(), 1, Any () );
685 setObject( parameterIndex
, x
);
690 void PreparedStatement::setRef(
691 sal_Int32 parameterIndex
,
692 const Reference
< XRef
>& x
)
693 throw (SQLException
, RuntimeException
, std::exception
)
695 (void) parameterIndex
; (void)x
;
697 "pq_preparedstatement: setRef not implemented",
698 *this, OUString(), 1, Any () );
701 void PreparedStatement::setBlob(
702 sal_Int32 parameterIndex
,
703 const Reference
< XBlob
>& x
)
704 throw (SQLException
, RuntimeException
, std::exception
)
706 (void) parameterIndex
; (void)x
;
708 "pq_preparedstatement: setBlob not implemented",
709 *this, OUString(), 1, Any () );
712 void PreparedStatement::setClob(
713 sal_Int32 parameterIndex
,
714 const Reference
< XClob
>& x
)
715 throw (SQLException
, RuntimeException
, std::exception
)
717 (void) parameterIndex
; (void)x
;
719 "pq_preparedstatement: setClob not implemented",
720 *this, OUString(), 1, Any () );
723 void PreparedStatement::setArray(
724 sal_Int32 parameterIndex
,
725 const Reference
< XArray
>& x
)
726 throw (SQLException
, RuntimeException
, std::exception
)
728 setString( parameterIndex
, array2String( x
->getArray( 0 ) ) );
731 void PreparedStatement::clearParameters( )
732 throw (SQLException
, RuntimeException
, std::exception
)
734 MutexGuard
guard(m_refMutex
->mutex
);
735 m_vars
= OStringVector ( m_vars
.size() );
738 Any
PreparedStatement::getWarnings( )
739 throw (SQLException
,RuntimeException
, std::exception
)
744 void PreparedStatement::clearWarnings( )
745 throw (SQLException
, RuntimeException
, std::exception
)
749 Reference
< ::com::sun::star::sdbc::XResultSetMetaData
> PreparedStatement::getMetaData()
750 throw (SQLException
,RuntimeException
, std::exception
)
752 Reference
< com::sun::star::sdbc::XResultSetMetaData
> ret
;
753 Reference
< com::sun::star::sdbc::XResultSetMetaDataSupplier
> supplier( m_lastResultset
, UNO_QUERY
);
755 ret
= supplier
->getMetaData();
759 ::cppu::IPropertyArrayHelper
& PreparedStatement::getInfoHelper()
761 return getPreparedStatementPropertyArrayHelper();
765 sal_Bool
PreparedStatement::convertFastPropertyValue(
766 Any
& rConvertedValue
, Any
& rOldValue
, sal_Int32 nHandle
, const Any
& rValue
)
767 throw (IllegalArgumentException
)
770 rOldValue
= m_props
[nHandle
];
773 case PREPARED_STATEMENT_CURSOR_NAME
:
776 bRet
= ( rValue
>>= val
);
777 rConvertedValue
= makeAny( val
);
780 case PREPARED_STATEMENT_ESCAPE_PROCESSING
:
783 bRet
= ( rValue
>>= val
);
784 rConvertedValue
= makeAny( val
);
787 case PREPARED_STATEMENT_FETCH_DIRECTION
:
788 case PREPARED_STATEMENT_FETCH_SIZE
:
789 case PREPARED_STATEMENT_MAX_FIELD_SIZE
:
790 case PREPARED_STATEMENT_MAX_ROWS
:
791 case PREPARED_STATEMENT_QUERY_TIME_OUT
:
792 case PREPARED_STATEMENT_RESULT_SET_CONCURRENCY
:
793 case PREPARED_STATEMENT_RESULT_SET_TYPE
:
796 bRet
= ( rValue
>>= val
);
797 rConvertedValue
= makeAny( val
);
802 OUStringBuffer
buf(128);
803 buf
.appendAscii( "pq_statement: Invalid property handle (" );
804 buf
.append( nHandle
);
805 buf
.appendAscii( ")" );
806 throw IllegalArgumentException( buf
.makeStringAndClear(), *this, 2 );
813 void PreparedStatement::setFastPropertyValue_NoBroadcast(
814 sal_Int32 nHandle
,const Any
& rValue
) throw (Exception
, std::exception
)
816 m_props
[nHandle
] = rValue
;
819 void PreparedStatement::getFastPropertyValue( Any
& rValue
, sal_Int32 nHandle
) const
821 rValue
= m_props
[nHandle
];
824 Reference
< XPropertySetInfo
> PreparedStatement::getPropertySetInfo()
825 throw(RuntimeException
, std::exception
)
827 return OPropertySetHelper::createPropertySetInfo( getPreparedStatementPropertyArrayHelper() );
830 void PreparedStatement::disposing()
836 Reference
< XResultSet
> PreparedStatement::getResultSet( )
837 throw (::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
)
839 return Reference
< XResultSet
> ( m_lastResultset
, com::sun::star::uno::UNO_QUERY
);
841 sal_Int32
PreparedStatement::getUpdateCount( )
842 throw (::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
)
844 return m_multipleResultUpdateCount
;
846 sal_Bool
PreparedStatement::getMoreResults( )
847 throw (::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
)
852 Reference
< XResultSet
> PreparedStatement::getGeneratedValues( )
853 throw (SQLException
, RuntimeException
, std::exception
)
855 osl::MutexGuard
guard( m_refMutex
->mutex
);
856 return getGeneratedValuesFromLastInsert(
857 m_pSettings
, m_connection
, m_lastOidInserted
, m_lastTableInserted
, m_lastQuery
);
863 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */