merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / drivers / postgresql / pq_sequenceresultsetmetadata.cxx
blob66eee79b5dc3fccbbc125f4348b1046a7324bd88
1 #include "pq_sequenceresultsetmetadata.hxx"
3 #include <rtl/ustrbuf.hxx>
5 using rtl::OUStringBuffer;
6 using rtl::OUString;
7 using com::sun::star::uno::Any;
9 using com::sun::star::uno::RuntimeException;
11 using com::sun::star::sdbc::SQLException;
13 namespace pq_sdbc_driver
16 SequenceResultSetMetaData::SequenceResultSetMetaData(
17 const ::rtl::Reference< RefCountedMutex > & refMutex,
18 const ColumnMetaDataVector &metaDataVector,
19 int colCount ) :
20 m_refMutex( refMutex ),
21 m_colCount( colCount ),
22 m_columnData( metaDataVector )
27 // Methods
28 sal_Int32 SequenceResultSetMetaData::getColumnCount( )
29 throw (SQLException, RuntimeException)
31 return m_colCount;
34 sal_Bool SequenceResultSetMetaData::isAutoIncrement( sal_Int32 column )
35 throw (SQLException, RuntimeException)
37 checkColumnIndex( column );
38 return m_columnData[column-1].isAutoIncrement;
41 sal_Bool SequenceResultSetMetaData::isCaseSensitive( sal_Int32 column )
42 throw (SQLException, RuntimeException)
45 return sal_True; // ??? hmm, numeric types or
48 sal_Bool SequenceResultSetMetaData::isSearchable( sal_Int32 column ) throw (SQLException, RuntimeException)
50 return sal_True; // mmm, what types are not searchable ?
53 sal_Bool SequenceResultSetMetaData::isCurrency( sal_Int32 column ) throw (SQLException, RuntimeException)
55 checkColumnIndex( column );
56 return m_columnData[column-1].isCurrency;
59 sal_Int32 SequenceResultSetMetaData::isNullable( sal_Int32 column )
60 throw (SQLException, RuntimeException)
62 checkColumnIndex( column );
63 return m_columnData[column-1].isNullable;
66 sal_Bool SequenceResultSetMetaData::isSigned( sal_Int32 column )
67 throw (SQLException, RuntimeException)
69 return sal_True; //
72 sal_Int32 SequenceResultSetMetaData::getColumnDisplaySize( sal_Int32 column )
73 throw (SQLException, RuntimeException)
75 return 50;
78 ::rtl::OUString SequenceResultSetMetaData::getColumnLabel( sal_Int32 column )
79 throw (SQLException, RuntimeException)
81 checkColumnIndex( column );
82 return m_columnData[column-1].columnName;
85 ::rtl::OUString SequenceResultSetMetaData::getColumnName( sal_Int32 column ) throw (SQLException, RuntimeException)
87 checkColumnIndex( column );
88 return m_columnData[column-1].columnName;
91 ::rtl::OUString SequenceResultSetMetaData::getSchemaName( sal_Int32 column ) throw (SQLException, RuntimeException)
93 checkColumnIndex( column );
94 return m_columnData[column-1].schemaTableName;
99 sal_Int32 SequenceResultSetMetaData::getPrecision( sal_Int32 column )
100 throw (SQLException, RuntimeException)
102 checkColumnIndex( column );
103 return m_columnData[column-1].precision;
106 sal_Int32 SequenceResultSetMetaData::getScale( sal_Int32 column )
107 throw (SQLException, RuntimeException)
109 checkColumnIndex( column );
110 return m_columnData[column-1].scale;
113 ::rtl::OUString SequenceResultSetMetaData::getTableName( sal_Int32 column )
114 throw (SQLException, RuntimeException)
116 checkColumnIndex( column );
117 return m_columnData[column-1].tableName;
120 ::rtl::OUString SequenceResultSetMetaData::getCatalogName( sal_Int32 column )
121 throw (SQLException, RuntimeException)
123 // can do this through XConnection.getCatalog() !
124 return OUString();
126 sal_Int32 SequenceResultSetMetaData::getColumnType( sal_Int32 column )
127 throw (SQLException, RuntimeException)
129 checkColumnIndex( column );
130 return m_columnData[column-1].type;
133 ::rtl::OUString SequenceResultSetMetaData::getColumnTypeName( sal_Int32 column )
134 throw (SQLException, RuntimeException)
136 checkColumnIndex( column );
137 return m_columnData[column-1].typeName;
141 sal_Bool SequenceResultSetMetaData::isReadOnly( sal_Int32 column )
142 throw (SQLException, RuntimeException)
144 return sal_False;
147 sal_Bool SequenceResultSetMetaData::isWritable( sal_Int32 column )
148 throw (SQLException, RuntimeException)
150 return ! isReadOnly( column ); // what's the sense if this method ?
153 sal_Bool SequenceResultSetMetaData::isDefinitelyWritable( sal_Int32 column )
154 throw (SQLException, RuntimeException)
156 return isWritable(column); // uhh, now it becomes really esoteric ....
158 ::rtl::OUString SequenceResultSetMetaData::getColumnServiceName( sal_Int32 column )
159 throw (SQLException, RuntimeException)
161 return OUString();
165 void SequenceResultSetMetaData::checkColumnIndex(sal_Int32 columnIndex)
166 throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
168 if( columnIndex < 1 || columnIndex > m_colCount )
170 OUStringBuffer buf(128);
172 buf.appendAscii( "pq_sequenceresultsetmetadata: index out of range (expected 1 to " );
173 buf.append( m_colCount );
174 buf.appendAscii( ", got " );
175 buf.append( columnIndex );
176 throw SQLException(
177 buf.makeStringAndClear(), *this, OUString(), 1, Any() );