23#include <com/sun/star/sdbc/ColumnValue.hpp>
24#include <com/sun/star/sdbc/SQLException.hpp>
25#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
26#include <com/sun/star/sdbc/XRow.hpp>
27#include <com/sun/star/sdbc/DataType.hpp>
38OResultSetMetaData::~OResultSetMetaData()
45 if( !sTable.isEmpty() )
49 OUString sSql =
"SELECT charset.RDB$CHARACTER_SET_NAME "
50 "FROM RDB$CHARACTER_SETS charset "
51 "JOIN RDB$FIELDS fields "
52 "ON (fields.RDB$CHARACTER_SET_ID = charset.RDB$CHARACTER_SET_ID) "
53 "JOIN RDB$RELATION_FIELDS relfields "
54 "ON (fields.RDB$FIELD_NAME = relfields.RDB$FIELD_SOURCE) "
55 "WHERE relfields.RDB$RELATION_NAME = '"
56 + sTable.replaceAll(
"'",
"''") +
"' AND "
57 "relfields.RDB$FIELD_NAME = '"+ sColumnName.replaceAll(
"'",
"''") +
"'";
62 xStmt->executeQuery(sSql);
66 OUString sCharset = xRow->getString(1).trim();
78 throw SQLException(
"Invalid column specified", *
this, OUString(), 0,
Any());
96 short aType =
m_pSqlda->sqlvar[column-1].sqltype & ~1;
100 if(aType == SQL_TEXT || aType == SQL_VARYING)
106 m_pSqlda->sqlvar[column-1].sqlsubtype,
107 -(
m_pSqlda->sqlvar[column-1].sqlscale),
131 char* pColumnName =
m_pSqlda->sqlvar[column - 1].sqlname;
132 sal_Int32 nColumnNameLength =
m_pSqlda->sqlvar[column - 1].sqlname_length;
134 if (
m_pSqlda->sqlvar[column - 1].aliasname_length > 0)
136 pColumnName =
m_pSqlda->sqlvar[column - 1].aliasname;
137 nColumnNameLength =
m_pSqlda->sqlvar[column - 1].aliasname_length;
139 OUString sRet(pColumnName, nColumnNameLength, RTL_TEXTENCODING_UTF8);
147 return OUString(
m_pSqlda->sqlvar[column-1].relname,
148 m_pSqlda->sqlvar[column-1].relname_length,
149 RTL_TEXTENCODING_UTF8);
162 m_pSqlda->sqlvar[column-1].sqlsubtype,
163 -(
m_pSqlda->sqlvar[column-1].sqlscale) );
172 OUString sRet(
m_pSqlda->sqlvar[column-1].aliasname,
173 m_pSqlda->sqlvar[column-1].aliasname_length,
174 RTL_TEXTENCODING_UTF8);
193 if( sTable.isEmpty() )
198 OUString sSql =
"SELECT RDB$IDENTITY_TYPE FROM RDB$RELATION_FIELDS "
199 "WHERE RDB$RELATION_NAME = '"
200 + sTable.replaceAll(
"'",
"''") +
"' AND "
201 "RDB$FIELD_NAME = '"+ sColumnName.replaceAll(
"'",
"''") +
"'";
206 xStmt->executeQuery(sSql);
210 int iType = xRow->getShort(1);
216 SAL_WARN(
"connectivity.firebird",
"Column '"
218 <<
"' not found in database");
235 if(
nType != DataType::NUMERIC &&
nType != DataType::DECIMAL )
241 OUString sSql =
"SELECT RDB$FIELD_PRECISION FROM RDB$FIELDS "
242 " INNER JOIN RDB$RELATION_FIELDS "
243 " ON RDB$RELATION_FIELDS.RDB$FIELD_SOURCE = RDB$FIELDS.RDB$FIELD_NAME "
244 "WHERE RDB$RELATION_FIELDS.RDB$RELATION_NAME = '"
246 "RDB$RELATION_FIELDS.RDB$FIELD_NAME = '"
247 + sColumnName.replaceAll(
"'",
"''") +
"'";
251 xStmt->executeQuery(sSql);
255 return static_cast<sal_Int32
>(xRow->getShort(1));
259 SAL_WARN(
"connectivity.firebird",
"Column '"
261 <<
"' not found in database");
269 return -(
m_pSqlda->sqlvar[column-1].sqlscale);
274 if (
m_pSqlda->sqlvar[column-1].sqltype & 1)
275 return ColumnValue::NULLABLE;
277 return ColumnValue::NO_NULLS;
sal_Int32 getSdbcType() const
OUString getColumnTypeName() const
#define SAL_WARN(area, stream)
OUString sanitizeIdentifier(std::u16string_view rIdentifier)
Make sure an identifier is safe to use within the database.