LibreOffice Module connectivity (master) 1
ACallableStatement.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
23
24using namespace connectivity::ado;
25using namespace com::sun::star::uno;
26using namespace com::sun::star::lang;
27using namespace com::sun::star::beans;
28using namespace com::sun::star::sdbc;
29using namespace com::sun::star::container;
30
31IMPLEMENT_SERVICE_INFO(OCallableStatement,"com.sun.star.sdbcx.ACallableStatement","com.sun.star.sdbc.CallableStatement");
32
33//************ Class: java.sql.CallableStatement
34
35OCallableStatement::OCallableStatement( OConnection* _pConnection, const OUString& sql )
36 : OPreparedStatement( _pConnection, sql )
37{
38 m_Command.put_CommandType(adCmdStoredProc);
39}
40
41
42Any SAL_CALL OCallableStatement::queryInterface( const Type & rType )
43{
45 return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< XRow*>(this));
46}
47
48
50{
51 return m_aValue.isNull();
52}
53
54
55sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex )
56{
57 ADOParameter* pParam = nullptr;
58 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam);
59 if(pParam)
60 pParam->get_Value(&m_aValue);
61 return m_aValue.getBool();
62}
63
64sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex )
65{
66 ADOParameter* pParam = nullptr;
67 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam);
68 if(pParam)
69 pParam->get_Value(&m_aValue);
70 return m_aValue.getInt8();
71}
72
73Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex )
74{
75 ADOParameter* pParam = nullptr;
76 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam);
77 if(pParam)
78 pParam->get_Value(&m_aValue);
80}
81
82css::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex )
83{
84 ADOParameter* pParam = nullptr;
85 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam);
86 if(pParam)
87 pParam->get_Value(&m_aValue);
88 return m_aValue.getDate();
89}
90
91double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex )
92{
93 ADOParameter* pParam = nullptr;
94 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam);
95 if(pParam)
96 pParam->get_Value(&m_aValue);
97 return m_aValue.getDouble();
98}
99
100
101float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex )
102{
103 ADOParameter* pParam = nullptr;
104 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam);
105 if(pParam)
106 pParam->get_Value(&m_aValue);
107 return m_aValue.getFloat();
108}
109
110
111sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex )
112{
113 ADOParameter* pParam = nullptr;
114 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam);
115 if(pParam)
116 pParam->get_Value(&m_aValue);
117 return m_aValue.getInt32();
118}
119
120
121sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex )
122{
123 ADOParameter* pParam = nullptr;
124 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam);
125 if(pParam)
126 pParam->get_Value(&m_aValue);
127 return static_cast<sal_Int64>(m_aValue.getCurrency().int64);
128}
129
130
131Any SAL_CALL OCallableStatement::getObject( sal_Int32 /*columnIndex*/, const Reference< css::container::XNameAccess >& /*typeMap*/ )
132{
133 ::dbtools::throwFeatureNotImplementedSQLException( "XRow::getObject", *this );
134 return Any();
135}
136
137
138sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex )
139{
140 ADOParameter* pParam = nullptr;
141 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam);
142 if(pParam)
143 pParam->get_Value(&m_aValue);
144 return m_aValue.getInt16();
145}
146
147
148OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex )
149{
150 ADOParameter* pParam = nullptr;
151 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam);
152 if(pParam)
153 pParam->get_Value(&m_aValue);
154 return m_aValue.getString();
155}
156
157
158 css::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex )
159{
160 ADOParameter* pParam = nullptr;
161 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam);
162 if(pParam)
163 pParam->get_Value(&m_aValue);
164 return m_aValue.getTime();
165}
166
167
168 css::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex )
169{
170 ADOParameter* pParam = nullptr;
171 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam);
172 if(pParam)
173 pParam->get_Value(&m_aValue);
174 return m_aValue.getDateTime();
175}
176
177
178void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& /*typeName*/ )
179{
180 ADOParameter* pParam = nullptr;
181 m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
182 if(pParam)
183 {
184 pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType()));
185 pParam->put_Direction(adParamOutput);
186 }
187}
188
189void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale )
190{
191 ADOParameter* pParam = nullptr;
192 m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
193 if(pParam)
194 {
195 pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType()));
196 pParam->put_Direction(adParamOutput);
197 pParam->put_NumericScale(static_cast<sal_Int8>(scale));
198 }
199}
200
201
203{
204 ::dbtools::throwFeatureNotImplementedSQLException( "XRow::getBinaryStream", *this );
205 return nullptr;
206}
207
209{
210 ::dbtools::throwFeatureNotImplementedSQLException( "XRow::getCharacterStream", *this );
211 return nullptr;
212}
213
214
215Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 /*columnIndex*/ )
216{
217 ::dbtools::throwFeatureNotImplementedSQLException( "XRow::getArray", *this );
218 return nullptr;
219}
220
221
222Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 /*columnIndex*/ )
223{
225 return nullptr;
226}
227
228Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 /*columnIndex*/ )
229{
231 return nullptr;
232}
233
234
235Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 /*columnIndex*/)
236{
238 return nullptr;
239}
240
241
242void SAL_CALL OCallableStatement::acquire() noexcept
243{
245}
246
247void SAL_CALL OCallableStatement::release() noexcept
248{
250}
251
252
253/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
IMPLEMENT_SERVICE_INFO(OCallableStatement,"com.sun.star.sdbcx.ACallableStatement","com.sun.star.sdbc.CallableStatement")
static DataTypeEnum MapJdbc2ADOType(sal_Int32 _nType, sal_Int32 _nJetEngine)
Definition: adoimp.cxx:131
virtual float SAL_CALL getFloat(sal_Int32 columnIndex) override
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) override
virtual css::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) override
virtual OUString SAL_CALL getString(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL wasNull() override
virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual css::util::Time SAL_CALL getTime(sal_Int32 columnIndex) override
virtual void SAL_CALL registerNumericOutParameter(sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale) override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) override
virtual void SAL_CALL registerOutParameter(sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString &typeName) override
virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) override
virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream(sal_Int32 columnIndex) override
virtual void SAL_CALL release() noexcept override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) override
virtual void SAL_CALL acquire() noexcept override
virtual css::util::Date SAL_CALL getDate(sal_Int32 columnIndex) override
virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) override
virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) override
virtual double SAL_CALL getDouble(sal_Int32 columnIndex) override
sal_Int32 getEngineType() const
css::util::Date getDate() const
css::util::DateTime getDateTime() const
css::util::Time getTime() const
css::uno::Sequence< sal_Int8 > getByteSequence() const
virtual void SAL_CALL release() noexcept override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL acquire() noexcept override
bool put_CommandType(CommandTypeEnum lCmdType)
Definition: Awrapado.cxx:353
Type
void throwFeatureNotImplementedSQLException(const OUString &_rFeatureName, const Reference< XInterface > &_rxContext, const Any &_rNextException)
sal_Int32 scale
Definition: pq_statics.cxx:62
unsigned char sal_Bool
signed char sal_Int8