update emoji autocorrect entries from po-files
[LibreOffice.git] / connectivity / source / drivers / kab / KPreparedStatement.cxx
blob1d9853dfa5b649d9732c4a292714d74a3e6a0f9d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "KPreparedStatement.hxx"
22 #include "propertyids.hxx"
23 #include <connectivity/dbexception.hxx>
24 #include <connectivity/dbtools.hxx>
25 #include "resource/kab_res.hrc"
26 #include "resource/sharedresources.hxx"
28 using namespace connectivity::kab;
29 using namespace com::sun::star::uno;
30 using namespace com::sun::star::lang;
31 using namespace com::sun::star::sdbc;
32 using namespace com::sun::star::util;
34 IMPLEMENT_SERVICE_INFO(KabPreparedStatement, "com.sun.star.sdbc.drivers.KabPreparedStatement", "com.sun.star.sdbc.PreparedStatement");
36 void KabPreparedStatement::checkAndResizeParameters(sal_Int32 nParams) throw(SQLException)
38 if ( !m_aParameterRow.is() )
39 m_aParameterRow = new OValueVector();
41 if (nParams < 1)
42 ::dbtools::throwInvalidIndexException(*this, Any());
44 if (nParams >= (sal_Int32) (m_aParameterRow->get()).size())
45 (m_aParameterRow->get()).resize(nParams);
48 void KabPreparedStatement::setKabFields() const throw(SQLException)
50 ::rtl::Reference<connectivity::OSQLColumns> xColumns; // selected columns
52 xColumns = m_aSQLIterator.getSelectColumns();
53 if (!xColumns.is())
55 ::connectivity::SharedResources aResources;
56 const OUString sError( aResources.getResourceString(
57 STR_INVALID_COLUMN_SELECTION
58 ) );
59 ::dbtools::throwGenericSQLException(sError,NULL);
61 m_xMetaData->setKabFields(xColumns);
64 void KabPreparedStatement::resetParameters() const throw(SQLException)
66 m_nParameterIndex = 0;
69 void KabPreparedStatement::getNextParameter(OUString &rParameter) const throw(SQLException)
71 if (m_nParameterIndex >= (sal_Int32) (m_aParameterRow->get()).size())
73 ::connectivity::SharedResources aResources;
74 const OUString sError( aResources.getResourceString(
75 STR_INVALID_PARA_COUNT
76 ) );
77 ::dbtools::throwGenericSQLException(sError,*const_cast<KabPreparedStatement *>(this));
78 } // if (m_nParameterIndex >= (sal_Int32) (*m_aParameterRow).size())
80 rParameter = (m_aParameterRow->get())[m_nParameterIndex];
82 m_nParameterIndex++;
85 KabPreparedStatement::KabPreparedStatement(
86 KabConnection* _pConnection,
87 const OUString& sql)
88 : KabPreparedStatement_BASE(_pConnection),
89 m_sSqlStatement(sql),
90 m_bPrepared(false),
91 m_nParameterIndex(0),
92 m_aParameterRow()
96 KabPreparedStatement::~KabPreparedStatement()
100 void KabPreparedStatement::disposing()
102 KabPreparedStatement_BASE::disposing();
104 if (m_aParameterRow.is())
106 m_aParameterRow->get().clear();
107 m_aParameterRow = NULL;
111 Reference< XResultSetMetaData > SAL_CALL KabPreparedStatement::getMetaData() throw(SQLException, RuntimeException, std::exception)
113 ::osl::MutexGuard aGuard( m_aMutex );
114 checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
116 if (!m_xMetaData.is())
118 m_xMetaData = new KabResultSetMetaData;
119 setKabFields();
121 Reference< XResultSetMetaData > xMetaData = m_xMetaData.get();
122 return xMetaData;
125 void SAL_CALL KabPreparedStatement::close() throw(SQLException, RuntimeException, std::exception)
127 ::osl::MutexGuard aGuard( m_aMutex );
128 checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
130 // Reset last warning message
131 try {
132 clearWarnings ();
133 KabCommonStatement::close();
135 catch (SQLException &) {
136 // If we get an error, ignore
139 // Remove this Statement object from the Connection object's
140 // list
143 sal_Bool SAL_CALL KabPreparedStatement::execute() throw(SQLException, RuntimeException, std::exception)
145 ::osl::MutexGuard aGuard( m_aMutex );
146 checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
148 Reference< XResultSet> xRS = KabCommonStatement::executeQuery(m_sSqlStatement);
150 return xRS.is();
153 sal_Int32 SAL_CALL KabPreparedStatement::executeUpdate() throw(SQLException, RuntimeException, std::exception)
155 ::osl::MutexGuard aGuard( m_aMutex );
156 checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
158 // same as in statement with the difference that this statement also can contain parameter
159 return 0;
162 Reference< XConnection > SAL_CALL KabPreparedStatement::getConnection() throw(SQLException, RuntimeException, std::exception)
164 ::osl::MutexGuard aGuard( m_aMutex );
165 checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
167 return m_pConnection;
170 Reference< XResultSet > SAL_CALL KabPreparedStatement::executeQuery() throw(SQLException, RuntimeException, std::exception)
172 ::osl::MutexGuard aGuard( m_aMutex );
173 checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
175 Reference< XResultSet > rs = KabCommonStatement::executeQuery(m_sSqlStatement);
177 return rs;
180 void SAL_CALL KabPreparedStatement::setNull(sal_Int32 parameterIndex, sal_Int32) throw(SQLException, RuntimeException, std::exception)
182 ::osl::MutexGuard aGuard( m_aMutex );
183 checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
185 checkAndResizeParameters(parameterIndex);
187 (m_aParameterRow->get())[parameterIndex - 1].setNull();
190 void SAL_CALL KabPreparedStatement::setObjectNull(sal_Int32, sal_Int32, const OUString&) throw(SQLException, RuntimeException, std::exception)
192 ::dbtools::throwFunctionNotSupportedSQLException("setObjectNull", NULL);
195 void SAL_CALL KabPreparedStatement::setBoolean(sal_Int32, sal_Bool) throw(SQLException, RuntimeException, std::exception)
197 ::dbtools::throwFunctionNotSupportedSQLException("setBoolean", NULL);
200 void SAL_CALL KabPreparedStatement::setByte(sal_Int32, sal_Int8) throw(SQLException, RuntimeException, std::exception)
202 ::dbtools::throwFunctionNotSupportedSQLException("setByte", NULL);
205 void SAL_CALL KabPreparedStatement::setShort(sal_Int32, sal_Int16) throw(SQLException, RuntimeException, std::exception)
207 ::dbtools::throwFunctionNotSupportedSQLException("setShort", NULL);
210 void SAL_CALL KabPreparedStatement::setInt(sal_Int32, sal_Int32) throw(SQLException, RuntimeException, std::exception)
212 ::dbtools::throwFunctionNotSupportedSQLException("setInt", NULL);
215 void SAL_CALL KabPreparedStatement::setLong(sal_Int32, sal_Int64) throw(SQLException, RuntimeException, std::exception)
217 ::dbtools::throwFunctionNotSupportedSQLException("", NULL);
220 void SAL_CALL KabPreparedStatement::setFloat(sal_Int32, float) throw(SQLException, RuntimeException, std::exception)
222 ::dbtools::throwFunctionNotSupportedSQLException("setFloat", NULL);
225 void SAL_CALL KabPreparedStatement::setDouble(sal_Int32, double) throw(SQLException, RuntimeException, std::exception)
227 ::dbtools::throwFunctionNotSupportedSQLException("setDouble", NULL);
230 void SAL_CALL KabPreparedStatement::setString(sal_Int32 parameterIndex, const OUString &x) throw(SQLException, RuntimeException, std::exception)
232 ::osl::MutexGuard aGuard( m_aMutex );
233 checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
235 checkAndResizeParameters(parameterIndex);
237 (m_aParameterRow->get())[parameterIndex - 1] = x;
240 void SAL_CALL KabPreparedStatement::setBytes(sal_Int32, const Sequence< sal_Int8 >&) throw(SQLException, RuntimeException, std::exception)
242 ::dbtools::throwFunctionNotSupportedSQLException("setBytes", NULL);
245 void SAL_CALL KabPreparedStatement::setDate(sal_Int32, const Date&) throw(SQLException, RuntimeException, std::exception)
247 ::dbtools::throwFunctionNotSupportedSQLException("setDate", NULL);
250 void SAL_CALL KabPreparedStatement::setTime(sal_Int32, const css::util::Time&) throw(SQLException, RuntimeException, std::exception)
252 ::dbtools::throwFunctionNotSupportedSQLException("setTime", NULL);
255 void SAL_CALL KabPreparedStatement::setTimestamp(sal_Int32, const DateTime&) throw(SQLException, RuntimeException, std::exception)
258 ::dbtools::throwFunctionNotSupportedSQLException("setTimestamp", NULL);
261 void SAL_CALL KabPreparedStatement::setBinaryStream(sal_Int32, const Reference< ::com::sun::star::io::XInputStream >&, sal_Int32) throw(SQLException, RuntimeException, std::exception)
263 ::dbtools::throwFunctionNotSupportedSQLException("setBinaryStream", NULL);
266 void SAL_CALL KabPreparedStatement::setCharacterStream(sal_Int32, const Reference< ::com::sun::star::io::XInputStream >&, sal_Int32) throw(SQLException, RuntimeException, std::exception)
268 ::dbtools::throwFunctionNotSupportedSQLException("setCharacterStream", NULL);
271 void SAL_CALL KabPreparedStatement::setObject(sal_Int32 parameterIndex, const Any& x) throw(SQLException, RuntimeException, std::exception)
273 if(!::dbtools::implSetObject(this,parameterIndex,x))
275 throw SQLException();
279 void SAL_CALL KabPreparedStatement::setObjectWithInfo(sal_Int32, const Any&, sal_Int32, sal_Int32) throw(SQLException, RuntimeException, std::exception)
281 ::dbtools::throwFunctionNotSupportedSQLException("setObjectWithInfo", NULL);
284 void SAL_CALL KabPreparedStatement::setRef(sal_Int32, const Reference< XRef >&) throw(SQLException, RuntimeException, std::exception)
286 ::dbtools::throwFunctionNotSupportedSQLException("setRef", NULL);
289 void SAL_CALL KabPreparedStatement::setBlob(sal_Int32, const Reference< XBlob >&) throw(SQLException, RuntimeException, std::exception)
291 ::dbtools::throwFunctionNotSupportedSQLException("setBlob", NULL);
294 void SAL_CALL KabPreparedStatement::setClob(sal_Int32, const Reference< XClob >&) throw(SQLException, RuntimeException, std::exception)
296 ::dbtools::throwFunctionNotSupportedSQLException("setClob", NULL);
299 void SAL_CALL KabPreparedStatement::setArray(sal_Int32, const Reference< XArray >&) throw(SQLException, RuntimeException, std::exception)
301 ::dbtools::throwFunctionNotSupportedSQLException("setArray", NULL);
304 void SAL_CALL KabPreparedStatement::clearParameters() throw(SQLException, RuntimeException, std::exception)
306 ::dbtools::throwFunctionNotSupportedSQLException("clearParameters", NULL);
309 void KabPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception, std::exception)
311 switch (nHandle)
313 case PROPERTY_ID_RESULTSETCONCURRENCY:
314 break;
315 case PROPERTY_ID_RESULTSETTYPE:
316 break;
317 case PROPERTY_ID_FETCHDIRECTION:
318 break;
319 case PROPERTY_ID_USEBOOKMARKS:
320 break;
321 default:
322 KabCommonStatement::setFastPropertyValue_NoBroadcast(nHandle,rValue);
326 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */