22#include <osl/diagnose.h>
24#include <com/sun/star/sdbc/DataType.hpp>
34#include <com/sun/star/sdbc/ColumnValue.hpp>
51OPreparedStatement::OPreparedStatement(
OConnection* _pConnection)
113 return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType,
114 static_cast< XPreparedStatement*
>(
this),
115 static_cast< XParameters*
>(
this),
116 static_cast< XResultSetMetaDataSupplier*
>(
this));
131 ::osl::MutexGuard aGuard(
m_aMutex );
143 ::osl::MutexGuard aGuard(
m_aMutex );
152 ::osl::MutexGuard aGuard(
m_aMutex );
166 ::osl::MutexGuard aGuard(
m_aMutex );
172 const sal_Int32 res(xRS->getRowCountResult());
190 ::osl::MutexGuard aGuard(
m_aMutex );
199 ::osl::MutexGuard aGuard(
m_aMutex );
260 ::osl::MutexGuard aGuard(
m_aMutex );
298 case DataType::DECIMAL:
299 case DataType::NUMERIC:
300 setString(parameterIndex,::comphelper::getString(x));
311 setNull(parameterIndex,sqlType);
319 const OUString sError(
m_pConnection->getResources().getResourceStringWithSubstitution(
320 STR_UNKNOWN_PARA_TYPE,
321 "$position$", OUString::number(parameterIndex)
353 x->readBytes(aSeq,length);
360 ::osl::MutexGuard aGuard(
m_aMutex );
377 m_pConnection->throwGenericSQLException(STR_INVALID_PARA_COUNT,*
this);
398 else if (
static_cast<sal_Int32
>(
m_aParameterRow->size()) <= parameterIndex )
402 for ( ;
i <= parameterIndex; ++
i)
412 ::osl::MutexGuard aGuard(
m_aMutex );
418 *((*m_aParameterRow)[parameterIndex]) =
x;
423 OSL_ENSURE(
SQL_ISRULE(pParameter,parameter),
"OResultSet::AddParameter: Argument is not a parameter");
424 OSL_ENSURE(pParameter->
count() > 0,
"OResultSet: Error in Parse Tree");
426 OUString sParameterName;
428 sal_Int32
eType = DataType::VARCHAR;
429 sal_uInt32 nPrecision = 255;
430 sal_Int32 nScale = 0;
431 sal_Int32
nNullable = ColumnValue::NULLABLE;
468 OUString sColumnName,sTableRange;
470 if ( !sColumnName.isEmpty() )
473 if(xNameAccess->hasByName(sColumnName))
474 xNameAccess->getByName(sColumnName) >>= xProp;
484 std::vector< OSQLParseNode*> aParseNodes;
486 if ( aParseNodes.empty() )
493 OSQLTable xTable = rTabs.begin()->second;
494 for (
auto const& parseNode : aParseNodes)
496 describeColumn(parseNode,parseNode->getParent()->getChild(0),xTable);
509 sal_uInt16 nParaCount=0;
513 for (
size_t j = 1; j <
nCount; j++)
515 sal_uInt32 nParameter = (*m_aAssignValues).getParameterIndex(j);
527 for ( ;
i < nParamColumns; ++
i )
541 sal_Int32 nParameter = -1;
549 nParameter =
AddParameter(pRow_Value_Constructor_Elem,xCol);
static double toDouble(std::string_view rString)
IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbc.driver.file.PreparedStatement","com.sun.star.sdbc.PreparedStatement")
ORowSetValueDecorator decorates an ORowSetValue so the value is "refcounted".
const ::rtl::Reference< OSQLColumns > & getParameters() const
const ::rtl::Reference< OSQLColumns > & getSelectColumns() const
const OSQLTables & getTables() const
void getColumnRange(const OSQLParseNode *_pColumnRef, OUString &_rColumnName, OUString &_rTableRange) const
return the columname and the table range
bool isCaseSensitive() const
OSQLStatementType getStatementType() const
virtual void SAL_CALL setTimestamp(sal_Int32 parameterIndex, const css::util::DateTime &x) override
virtual void SAL_CALL release() noexcept override
virtual void SAL_CALL setBinaryStream(sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length) override
virtual ~OPreparedStatement() override
virtual rtl::Reference< OResultSet > createResultSet() override
virtual void SAL_CALL setDate(sal_Int32 parameterIndex, const css::util::Date &x) override
virtual void SAL_CALL setRef(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XRef > &x) override
sal_uInt32 AddParameter(connectivity::OSQLParseNode const *pParameter, const css::uno::Reference< css::beans::XPropertySet > &_xCol)
void setParameter(sal_Int32 parameterIndex, const ORowSetValue &x)
css::uno::Reference< css::sdbc::XResultSetMetaData > m_xMetaData
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery() override
virtual void SAL_CALL setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) override
virtual void construct(const OUString &sql) override
virtual void SAL_CALL setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString &typeName) override
::rtl::Reference< OResultSet > makeResultSet()
void checkAndResizeParameters(sal_Int32 parameterIndex)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual void SAL_CALL setBytes(sal_Int32 parameterIndex, const css::uno::Sequence< sal_Int8 > &x) override
virtual void SAL_CALL setByte(sal_Int32 parameterIndex, sal_Int8 x) override
virtual void SAL_CALL setClob(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XClob > &x) override
void describeColumn(OSQLParseNode const *_pParameter, OSQLParseNode const *_pNode, const OSQLTable &_xTable)
virtual void SAL_CALL setBoolean(sal_Int32 parameterIndex, sal_Bool x) override
virtual void SAL_CALL setArray(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XArray > &x) override
virtual void SAL_CALL setDouble(sal_Int32 parameterIndex, double x) override
::rtl::Reference< connectivity::OSQLColumns > m_xParamColumns
virtual void SAL_CALL setShort(sal_Int32 parameterIndex, sal_Int16 x) override
virtual void SAL_CALL setBlob(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XBlob > &x) override
virtual void SAL_CALL setCharacterStream(sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length) override
virtual void SAL_CALL setString(sal_Int32 parameterIndex, const OUString &x) override
virtual void SAL_CALL setInt(sal_Int32 parameterIndex, sal_Int32 x) override
virtual void SAL_CALL setTime(sal_Int32 parameterIndex, const css::util::Time &x) override
virtual sal_Int32 SAL_CALL executeUpdate() override
virtual void parseParamterElem(const OUString &_sColumnName, OSQLParseNode *pRow_Value_Constructor_Elem) override
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection() override
virtual void SAL_CALL setObject(sal_Int32 parameterIndex, const css::uno::Any &x) override
void initResultSet(OResultSet *)
virtual void initializeResultSet(OResultSet *_pResult) override
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
virtual sal_Bool SAL_CALL execute() override
virtual void SAL_CALL clearParameters() override
OValueRefRow m_aParameterRow
virtual void SAL_CALL disposing() override
void scanParameter(OSQLParseNode *pParseNode, std::vector< OSQLParseNode * > &_rParaNodes)
virtual void SAL_CALL setObjectWithInfo(sal_Int32 parameterIndex, const css::uno::Any &x, sal_Int32 targetSqlType, sal_Int32 scale) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL close() override
virtual void SAL_CALL setFloat(sal_Int32 parameterIndex, float x) override
virtual void SAL_CALL setLong(sal_Int32 parameterIndex, sal_Int64 x) override
virtual void SAL_CALL acquire() noexcept override
static void setBoundedColumns(const OValueRefRow &_rRow, const OValueRefRow &_rSelectRow, const ::rtl::Reference< connectivity::OSQLColumns > &_rxColumns, const css::uno::Reference< css::container::XIndexAccess > &_xNames, bool _bSetColumnMapping, const css::uno::Reference< css::sdbc::XDatabaseMetaData > &_xMetaData, std::vector< sal_Int32 > &_rColMapping)
void setMetaData(const css::uno::Reference< css::sdbc::XResultSetMetaData > &_xMetaData)
virtual void SAL_CALL disposing() override
virtual void SAL_CALL release() noexcept override
std::unique_ptr< OSQLAnalyzer > m_pSQLAnalyzer
std::vector< sal_Int32 > m_aColMapping
connectivity::OSQLParseTreeIterator m_aSQLIterator
css::uno::Reference< css::container::XNameAccess > m_xColNames
virtual void construct(const OUString &sql)
connectivity::OSQLParseNode * m_pParseTree
virtual void initializeResultSet(OResultSet *_pResult)
rtl::Reference< OConnection > m_pConnection
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
rtl::Reference< OFileTable > m_pTable
css::uno::WeakReference< css::sdbc::XResultSet > m_xResultSet
ORefAssignValues m_aAssignValues
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
std::vector< sal_Int32 > m_aParameterIndexes
css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xDBMetaData
virtual void SAL_CALL acquire() noexcept override
void SetAssignValue(const OUString &aColumnName, const OUString &aValue, bool bSetNull=false, sal_uInt32 nParameter=SQL_NO_PARAMETER)
OValueRefRow m_aEvaluateRow
mutable::osl::Mutex m_aMutex
Sequence< sal_Int8 > aSeq
std::map< OUString, OSQLTable, comphelper::UStringMixLess > OSQLTables
ORefVector< css::uno::Reference< css::beans::XPropertySet > > OSQLColumns
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
css::uno::Reference< css::sdbcx::XColumnsSupplier > OSQLTable
void checkDisposed(bool _bThrow)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
#define PROPERTY_ID_ISNULLABLE
#define PROPERTY_ID_PRECISION
#define PROPERTY_ID_SCALE
#define SQL_ISRULE(pParseNode, eRule)