1 /*************************************************************************
3 * $RCSfile: pq_xcolumns.cxx,v $
7 * last change: $Author: jbu $ $Date: 2004/08/29 08:33:30 $
9 * The Contents of this file are made available subject to the terms of
10 * either of the following licenses
12 * - GNU Lesser General Public License Version 2.1
13 * - Sun Industry Standards Source License Version 1.1
15 * Sun Microsystems Inc., October, 2000
17 * GNU Lesser General Public License Version 2.1
18 * =============================================
19 * Copyright 2000 by Sun Microsystems, Inc.
20 * 901 San Antonio Road, Palo Alto, CA 94303, USA
22 * This library is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU Lesser General Public
24 * License version 2.1, as published by the Free Software Foundation.
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
37 * Sun Industry Standards Source License Version 1.1
38 * =================================================
39 * The contents of this file are subject to the Sun Industry Standards
40 * Source License Version 1.1 (the "License"); You may not use this file
41 * except in compliance with the License. You may obtain a copy of the
42 * License at http://www.openoffice.org/license.html.
44 * Software provided under this License is provided on an "AS IS" basis,
45 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48 * See the License for the specific provisions governing your rights and
49 * obligations concerning the Software.
51 * The Initial Developer of the Original Code is: Joerg Budischewski
53 * Copyright: 2000 by Sun Microsystems, Inc.
55 * All Rights Reserved.
57 * Contributor(s): Joerg Budischewski
60 ************************************************************************/
64 #include <rtl/ustrbuf.hxx>
65 #include <rtl/strbuf.hxx>
67 #include <com/sun/star/sdbc/XRow.hpp>
68 #include <com/sun/star/sdbc/XParameters.hpp>
69 #include <com/sun/star/sdbc/DataType.hpp>
70 #include <com/sun/star/sdbc/ColumnValue.hpp>
72 #include <cppuhelper/implbase1.hxx>
74 #include "pq_xcolumns.hxx"
75 #include "pq_xcolumn.hxx"
76 #include "pq_statics.hxx"
77 #include "pq_tools.hxx"
79 using osl::MutexGuard
;
82 using rtl::OUStringBuffer
;
83 using rtl::OUStringToOString
;
85 using com::sun::star::beans::XPropertySet
;
86 using com::sun::star::beans::XPropertyChangeListener
;
87 using com::sun::star::beans::PropertyChangeEvent
;
89 using com::sun::star::uno::Any
;
90 using com::sun::star::uno::makeAny
;
91 using com::sun::star::uno::UNO_QUERY
;
92 using com::sun::star::uno::Type
;
93 using com::sun::star::uno::XInterface
;
94 using com::sun::star::uno::Reference
;
95 using com::sun::star::uno::Sequence
;
96 using com::sun::star::uno::RuntimeException
;
98 using com::sun::star::container::NoSuchElementException
;
99 using com::sun::star::lang::WrappedTargetException
;
101 using com::sun::star::sdbc::XRow
;
102 using com::sun::star::sdbc::XCloseable
;
103 using com::sun::star::sdbc::XStatement
;
104 using com::sun::star::sdbc::XResultSet
;
105 using com::sun::star::sdbc::XParameters
;
106 using com::sun::star::sdbc::XPreparedStatement
;
107 using com::sun::star::sdbc::XDatabaseMetaData
;
108 using com::sun::star::sdbc::SQLException
;
110 namespace pq_sdbc_driver
112 #define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
114 static Any
isCurrency( const rtl::OUString
& typeName
)
116 sal_Bool b
= typeName
.equalsIgnoreAsciiCaseAscii( "money" );
117 return Any( &b
, getBooleanCppuType() );
120 // static sal_Bool isAutoIncrement8( const rtl::OUString & typeName )
122 // return typeName.equalsIgnoreAsciiCaseAscii( "serial8" ) ||
123 // typeName.equalsIgnoreAsciiCaseAscii( "bigserial" );
126 static Any
isAutoIncrement( const rtl::OUString
& defaultValue
)
128 sal_Bool ret
= sal_False
;
130 ret
= defaultValue
.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "nextval(" ) );
131 // printf( "%s %d\n",
132 // OUStringToOString(defaultValue, RTL_TEXTENCODING_ASCII_US).getStr(),
135 // static const char * const serials[] =
137 // "serial", "serial4", "serial8", "bigserial", 0
139 // s sal_Bool b = sal_False;
140 // for( int i = 0; !b && serials[i] ; i ++ )
142 // b = b || typeName.equalsIgnoreAsciiCaseAscii( serials[i] );
144 return Any ( &ret
, getBooleanCppuType() );
148 const ::rtl::Reference
< RefCountedMutex
> & refMutex
,
149 const ::com::sun::star::uno::Reference
< com::sun::star::sdbc::XConnection
> & origin
,
150 ConnectionSettings
*pSettings
,
151 const rtl::OUString
&schemaName
,
152 const rtl::OUString
&tableName
)
153 : Container( refMutex
, origin
, pSettings
, ASCII_STR( "COLUMN" ) ),
154 m_schemaName( schemaName
),
155 m_tableName( tableName
)
161 rtl::OUString
columnMetaData2SDBCX(
162 ReflectionBase
*pBase
, const com::sun::star::uno::Reference
< com::sun::star::sdbc::XRow
> &xRow
)
164 Statics
& st
= getStatics();
166 // 1. TABLE_CAT string => table catalog (may be NULL)
168 // 2. TABLE_SCHEM string => table schema (may be NULL)
169 // => pg_namespace.nspname
170 // 3. TABLE_NAME string => table name
171 // => pg_class.relname
172 // 4. COLUMN_NAME string => column name
173 // => pg_attribure.attname
174 // 5. DATA_TYPE short => SQL type from java.sql.Types
175 // => pg_type.typname => sdbc.DataType
176 // 6. TYPE_NAME string => Data source dependent type name, for a UDT the
177 // type name is fully qualified
178 // => pg_type.typname
179 // 7. COLUMN_SIZE long => column size. For char or date types this is
180 // the maximum number of characters, for numeric
181 // or decimal types this is precision.
182 // => pg_type.typlen ( TODO: What is about variable size ? )
183 // 8. BUFFER_LENGTH is not used.
185 // 9. DECIMAL_DIGITS long => the number of fractional digits
186 // => don't know ! TODO !
187 // 10. NUM_PREC_RADIX long => Radix (typically either 10 or 2)
189 // 11. NULLABLE long => is NULL allowed?
190 // NO_NULLS - might not allow NULL values
191 // NULABLE - definitely allows NULL values
192 // NULLABLE_UNKNOWN - nullability unknown
193 // => pg_attribute.attnotnull
194 // 12. REMARKS string => comment describing column (may be NULL )
195 // => Don't know, there does not seem to exist something like
197 // 13. COLUMN_DEF string => default value (may be NULL)
198 // => pg_type.typdefault
199 // 14. SQL_DATA_TYPE long => unused
201 // 15. SQL_DATETIME_SUB long => unused
203 // 16. CHAR_OCTET_LENGTH long => for char types the maximum number of
204 // bytes in the column
206 // 17. ORDINAL_POSITION int => index of column in table (starting at 1)
207 // pg_attribute.attnum
208 // 18. IS_NULLABLE string => "NO" means column definitely does not allow
209 // NULL values; "YES" means the column might
210 // allow NULL values. An empty string means
212 // => pg_attribute.attnotnull
214 static const int COLUMN_NAME
= 4;
215 static const int DATA_TYPE
= 5;
216 static const int TYPE_NAME
= 6;
217 static const int COLUMN_SIZE
= 7;
218 static const int DECIMAL_DIGITS
= 9;
219 static const int IS_NULLABLE
= 11;
220 static const int DESCRIPTION
= 12;
221 static const int DEFAULT_VALUE
= 13;
223 OUString name
= xRow
->getString( COLUMN_NAME
);
224 OUString typeName
= xRow
->getString( TYPE_NAME
);
226 pBase
->setPropertyValue_NoBroadcast_public(
227 st
.NAME
, makeAny( name
) );
229 pBase
->setPropertyValue_NoBroadcast_public(
230 st
.TYPE
, makeAny( xRow
->getInt( DATA_TYPE
) ) );
232 pBase
->setPropertyValue_NoBroadcast_public(
233 st
.TYPE_NAME
, makeAny( typeName
) );
235 pBase
->setPropertyValue_NoBroadcast_public(
236 st
.PRECISION
, makeAny( xRow
->getInt( COLUMN_SIZE
) ) );
238 pBase
->setPropertyValue_NoBroadcast_public(
239 st
.SCALE
, makeAny( xRow
->getInt( DECIMAL_DIGITS
) ) );
241 pBase
->setPropertyValue_NoBroadcast_public(
242 st
.IS_NULLABLE
, makeAny( xRow
->getInt( IS_NULLABLE
) ) );
244 pBase
->setPropertyValue_NoBroadcast_public(
245 st
.DEFAULT_VALUE
, makeAny( xRow
->getString( DEFAULT_VALUE
) ) );
247 // pBase->setPropertyValue_NoBroadcast_public(
248 // st.DESCRIPTION, makeAny( xRow->getString( DESCRIPTION ) ) );
250 // if( pBase->getPropertySetInfo()->hasPropertyByName( st.HELP_TEXT ) )
251 // pBase->setPropertyValue_NoBroadcast_public(
252 // st.HELP_TEXT, makeAny( xRow->getString( DESCRIPTION ) ) );
253 // else // for key columns, etc. ...
254 pBase
->setPropertyValue_NoBroadcast_public(
255 st
.DESCRIPTION
, makeAny( xRow
->getString( DESCRIPTION
) ) );
258 // maybe a better criterium than the type name can be found in future
259 pBase
->setPropertyValue_NoBroadcast_public(
260 st
.IS_AUTO_INCREMENT
, isAutoIncrement(xRow
->getString( DEFAULT_VALUE
)) );
262 pBase
->setPropertyValue_NoBroadcast_public(
263 st
.IS_CURRENCY
, isCurrency( typeName
));
268 // class CommentChanger : public cppu::WeakImplHelper1< XPropertyChangeListener >
270 // ::rtl::Reference< RefCountedMutex > m_refMutex;
271 // ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > m_connection;
272 // ConnectionSettings *m_pSettings;
273 // rtl::OUString m_schema;
274 // rtl::OUString m_table;
275 // rtl::OUString m_column;
279 // const ::rtl::Reference< RefCountedMutex > & refMutex,
280 // const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
281 // ConnectionSettings *pSettings,
282 // const rtl::OUString & schema,
283 // const rtl::OUString & table,
284 // const rtl::OUString & column ) :
285 // m_refMutex( refMutex ),
286 // m_connection( connection ),
287 // m_pSettings( pSettings ),
288 // m_schema ( schema ),
289 // m_table ( table ),
290 // m_column ( column )
295 // virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException)
297 // osl::MutexGuard guard( m_refMutex->mutex );
298 // m_connection.clear();
301 // virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException)
303 // osl::MutexGuard guard( m_refMutex->mutex );
304 // OUStringBuffer buf( 128 );
306 // evt.NewValue >>= comment;
307 // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "COMMENT ON COLUMN" ) );
308 // bufferQuoteQualifiedIdentifier( buf, m_schema, m_table , m_column );
309 // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "IS " ) );
310 // bufferQuoteConstant( buf, comment,m_pSettings->encoding);
312 // printf( "changing comment of column %s to %s\n",
313 // OUStringToOString( m_column, RTL_TEXTENCODING_ASCII_US ).getStr(),
314 // OUStringToOString( comment, RTL_TEXTENCODING_ASCII_US ).getStr() );
316 // m_connection->createStatement()->executeUpdate( buf.makeStringAndClear() );
320 void Columns::refresh()
321 throw (::com::sun::star::uno::RuntimeException
)
325 if( isLog( m_pSettings
, LogLevel::INFO
) )
327 rtl::OStringBuffer buf
;
328 buf
.append( "sdbcx.Columns get refreshed for table " );
329 buf
.append( OUStringToOString( m_schemaName
, m_pSettings
->encoding
) );
331 buf
.append( OUStringToOString( m_tableName
, m_pSettings
->encoding
) );
332 log( m_pSettings
, LogLevel::INFO
, buf
.makeStringAndClear().getStr() );
334 osl::MutexGuard
guard( m_refMutex
->mutex
);
336 Statics
&st
= getStatics();
337 Reference
< XDatabaseMetaData
> meta
= m_origin
->getMetaData();
339 Reference
< XResultSet
> rs
=
340 meta
->getColumns( Any(), m_schemaName
, m_tableName
, st
.cPERCENT
);
342 DisposeGuard
disposeIt( rs
);
343 Reference
< XRow
> xRow( rs
, UNO_QUERY
);
347 std::vector
< Any
, Allocator
< Any
> > vec
;
348 sal_Int32 columnIndex
= 0;
352 new Column( m_refMutex
, m_origin
, m_pSettings
);
353 Reference
< com::sun::star::beans::XPropertySet
> prop
= pColumn
;
355 OUString name
= columnMetaData2SDBCX( pColumn
, xRow
);
356 // pColumn->addPropertyChangeListener(
358 // new CommentChanger(
366 vec
.push_back( makeAny( prop
) );
367 map
[ name
] = columnIndex
;
370 m_values
= Sequence
< com::sun::star::uno::Any
> ( & vec
[0] , vec
.size() );
371 m_name2index
.swap( map
);
373 catch ( com::sun::star::sdbc::SQLException
& e
)
375 throw RuntimeException( e
.Message
, e
.Context
);
377 fire( RefreshedBroadcaster( *this ) );
381 void alterColumnByDescriptor(
382 const OUString
& schemaName
,
383 const OUString
& tableName
,
384 rtl_TextEncoding encoding
,
385 const Reference
< XStatement
> &stmt
,
386 const com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
> & past
,
387 const com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
> & future
)
389 Statics
& st
= getStatics();
391 // if( past->getPropertyValue( st.TABLE_NAME ) != future->getPropertyValue( st.TABLE_NAME ) ||
392 // past->getPropertyValue( st.SCHEMA_NAME ) != future->getPropertyValue( st.SCHEMA_NAME ))
394 // OUStringBuffer buf(128);
395 // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Can't move column " ) );
396 // buf.append( extractStringProperty( past, st.COLUMN_NAME ) );
397 // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " from table " ) );
398 // buf.append( extractStringProperty( past, st.TABLE_NAME ) );
399 // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " to table " ) );
400 // buf.append( extractStringProperty( past, st.TABLE_NAME ) );
401 // throw SQLException( buf.makeStringAndClear(), Reference< XInterface > () );
404 // OUString tableName = extractStringProperty( past, st.TABLE_NAME );
405 // OUString schemaName = extractStringProperty( past, st.SCHEMA_NAME );
406 OUString pastColumnName
= extractStringProperty( past
, st
.NAME
);
407 OUString futureColumnName
= extractStringProperty( future
, st
.NAME
);
408 OUString pastTypeName
= sqltype2string( past
);
409 OUString futureTypeName
= sqltype2string( future
);
411 TransactionGuard
transaction( stmt
);
413 OUStringBuffer
buf( 128 );
414 if( ! pastColumnName
.getLength())
416 // create a new column
417 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
418 bufferQuoteQualifiedIdentifier( buf
, schemaName
, tableName
);
419 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ADD COLUMN" ) );
420 bufferQuoteIdentifier( buf
, futureColumnName
);
421 buf
.append( futureTypeName
);
422 transaction
.executeUpdate( buf
.makeStringAndClear() );
426 if( pastTypeName
!= futureTypeName
)
428 throw RuntimeException(
429 ASCII_STR( "Can't modify column types, drop the column and create a new one" ),
430 Reference
< XInterface
> () );
433 if( pastColumnName
!= futureColumnName
)
435 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
436 bufferQuoteQualifiedIdentifier( buf
, schemaName
, tableName
);
437 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "RENAME COLUMN" ) );
438 bufferQuoteIdentifier( buf
, pastColumnName
);
439 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "TO" ) );
440 bufferQuoteIdentifier( buf
, futureColumnName
);
441 transaction
.executeUpdate( buf
.makeStringAndClear() );
445 OUString futureDefaultValue
= extractStringProperty( future
, st
.DEFAULT_VALUE
);
446 OUString pastDefaultValue
= extractStringProperty( past
, st
.DEFAULT_VALUE
);
447 if( futureDefaultValue
!= pastDefaultValue
)
449 buf
= OUStringBuffer( 128 );
450 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
451 bufferQuoteQualifiedIdentifier( buf
, schemaName
, tableName
);
452 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER COLUMN" ) );
453 bufferQuoteIdentifier( buf
, futureColumnName
);
454 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SET DEFAULT " ) );
455 // default value is not quoted, caller needs to quote himself (otherwise
456 // how to pass e.g. nextval('something' ) ????
457 buf
.append( futureDefaultValue
);
458 // bufferQuoteConstant( buf, defaultValue, encoding );
459 transaction
.executeUpdate( buf
.makeStringAndClear() );
462 sal_Int32 futureNullable
= extractIntProperty( future
, st
.IS_NULLABLE
);
463 sal_Int32 pastNullable
= extractIntProperty( past
, st
.IS_NULLABLE
);
464 if( futureNullable
!= pastNullable
)
466 buf
= OUStringBuffer( 128 );
467 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
468 bufferQuoteQualifiedIdentifier( buf
, schemaName
, tableName
);
469 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER COLUMN" ) );
470 bufferQuoteIdentifier( buf
, futureColumnName
);
471 if( futureNullable
== com::sun::star::sdbc::ColumnValue::NO_NULLS
)
473 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SET" ) );
477 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "DROP" ) );
479 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( " NOT NULL" ) );
480 transaction
.executeUpdate( buf
.makeStringAndClear() );
483 // OUString futureComment = extractStringProperty( future, st.HELP_TEXT );
484 // OUString pastComment = extractStringProperty( past, st.HELP_TEXT );
485 // printf( "past Comment %s, futureComment %s\n",
486 // OUStringToOString( pastComment, RTL_TEXTENCODING_ASCII_US ).getStr(),
487 // OUStringToOString( futureComment, RTL_TEXTENCODING_ASCII_US ).getStr() );
488 OUString futureComment
= extractStringProperty( future
, st
.DESCRIPTION
);
489 OUString pastComment
= extractStringProperty( past
, st
.DESCRIPTION
);
491 if( futureComment
!= pastComment
)
493 buf
= OUStringBuffer( 128 );
494 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "COMMENT ON COLUMN" ) );
495 bufferQuoteQualifiedIdentifier( buf
, schemaName
, tableName
, futureColumnName
);
496 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "IS " ) );
497 bufferQuoteConstant( buf
, futureComment
,encoding
);
498 transaction
.executeUpdate( buf
.makeStringAndClear() );
500 transaction
.commit();
503 void Columns::appendByDescriptor(
504 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& future
)
505 throw (::com::sun::star::sdbc::SQLException
,
506 ::com::sun::star::container::ElementExistException
,
507 ::com::sun::star::uno::RuntimeException
)
509 osl::MutexGuard
guard( m_refMutex
->mutex
);
510 Statics
& st
= getStatics();
511 Reference
< XPropertySet
> past
= createDataDescriptor();
512 past
->setPropertyValue( st
.IS_NULLABLE
, makeAny( com::sun::star::sdbc::ColumnValue::NULLABLE
) );
513 alterColumnByDescriptor(
514 m_schemaName
, m_tableName
, m_pSettings
->encoding
, m_origin
->createStatement() , past
, future
);
519 // void Columns::dropByName( const ::rtl::OUString& elementName )
520 // throw (::com::sun::star::sdbc::SQLException,
521 // ::com::sun::star::container::NoSuchElementException,
522 // ::com::sun::star::uno::RuntimeException)
524 // String2IntMap::const_iterator ii = m_name2index.find( elementName );
525 // if( ii == m_name2index.end() )
527 // OUStringBuffer buf( 128 );
528 // buf.appendAscii( "Column " );
529 // buf.append( elementName );
530 // buf.appendAscii( " is unknown in table " );
531 // buf.append( m_schemaName );
532 // buf.appendAscii( "." );
533 // buf.append( m_tableName );
534 // buf.appendAscii( ", so it can't be dropped" );
535 // throw com::sun::star::container::NoSuchElementException(
536 // buf.makeStringAndClear(), *this );
538 // dropByIndex( ii->second );
541 void Columns::dropByIndex( sal_Int32 index
)
542 throw (::com::sun::star::sdbc::SQLException
,
543 ::com::sun::star::lang::IndexOutOfBoundsException
,
544 ::com::sun::star::uno::RuntimeException
)
546 osl::MutexGuard
guard( m_refMutex
->mutex
);
547 if( index
< 0 || index
>= m_values
.getLength() )
549 OUStringBuffer
buf( 128 );
550 buf
.appendAscii( "COLUMNS: Index out of range (allowed 0 to " );
551 buf
.append((sal_Int32
)(m_values
.getLength() -1) );
552 buf
.appendAscii( ", got " );
554 buf
.appendAscii( ")" );
555 throw com::sun::star::lang::IndexOutOfBoundsException(
556 buf
.makeStringAndClear(), *this );
559 Reference
< XPropertySet
> set
;
560 m_values
[index
] >>= set
;
561 Statics
&st
= getStatics();
563 set
->getPropertyValue( st
.NAME
) >>= name
;
565 OUStringBuffer
update( 128 );
566 update
.appendAscii( "ALTER TABLE ONLY");
567 bufferQuoteQualifiedIdentifier( update
, m_schemaName
, m_tableName
);
568 update
.appendAscii( "DROP COLUMN" );
569 bufferQuoteIdentifier( update
, name
);
570 Reference
< XStatement
> stmt
= m_origin
->createStatement( );
571 DisposeGuard
disposeIt( stmt
);
572 stmt
->executeUpdate( update
.makeStringAndClear() );
574 Container::dropByIndex( index
);
578 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> Columns::createDataDescriptor()
579 throw (::com::sun::star::uno::RuntimeException
)
581 return new ColumnDescriptor( m_refMutex
, m_origin
, m_pSettings
);
584 Reference
< com::sun::star::container::XNameAccess
> Columns::create(
585 const ::rtl::Reference
< RefCountedMutex
> & refMutex
,
586 const ::com::sun::star::uno::Reference
< com::sun::star::sdbc::XConnection
> & origin
,
587 ConnectionSettings
*pSettings
,
588 const rtl::OUString
&schemaName
,
589 const rtl::OUString
&tableName
,
592 *ppColumns
= new Columns(
593 refMutex
, origin
, pSettings
, schemaName
, tableName
);
594 Reference
< com::sun::star::container::XNameAccess
> ret
= *ppColumns
;
595 (*ppColumns
)->refresh();
601 //_____________________________________________________________________________________
602 ColumnDescriptors::ColumnDescriptors(
603 const ::rtl::Reference
< RefCountedMutex
> & refMutex
,
604 const ::com::sun::star::uno::Reference
< com::sun::star::sdbc::XConnection
> & origin
,
605 ConnectionSettings
*pSettings
)
606 : Container( refMutex
, origin
, pSettings
, ASCII_STR( "COLUMN-DESCRIPTOR" ) )
610 Reference
< ::com::sun::star::beans::XPropertySet
> ColumnDescriptors::createDataDescriptor()
611 throw (::com::sun::star::uno::RuntimeException
)
613 return new ColumnDescriptor( m_refMutex
, m_origin
, m_pSettings
);