xref: /AOO41X/main/connectivity/source/drivers/odbcbase/OTools.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
30*cdf0e10cSrcweir #include "odbc/OTools.hxx"
31*cdf0e10cSrcweir #include "odbc/OFunctions.hxx"
32*cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
33*cdf0e10cSrcweir #include <osl/diagnose.h>
34*cdf0e10cSrcweir #include "odbc/OConnection.hxx"
35*cdf0e10cSrcweir #include "diagnose_ex.h"
36*cdf0e10cSrcweir #include <rtl/logfile.hxx>
37*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include <string.h>
41*cdf0e10cSrcweir #include <string>
42*cdf0e10cSrcweir #include <algorithm>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir using namespace connectivity::odbc;
45*cdf0e10cSrcweir using namespace com::sun::star::uno;
46*cdf0e10cSrcweir using namespace com::sun::star::sdbc;
47*cdf0e10cSrcweir using namespace com::sun::star::util;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir void OTools::getValue(	OConnection* _pConnection,
50*cdf0e10cSrcweir 						SQLHANDLE _aStatementHandle,
51*cdf0e10cSrcweir 						sal_Int32 columnIndex,
52*cdf0e10cSrcweir 						SQLSMALLINT _nType,
53*cdf0e10cSrcweir 						sal_Bool &_bWasNull,
54*cdf0e10cSrcweir 						const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
55*cdf0e10cSrcweir 						void* _pValue,
56*cdf0e10cSrcweir 						SQLLEN _nSize) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::getValue" );
59*cdf0e10cSrcweir 	SQLLEN pcbValue = SQL_NULL_DATA;
60*cdf0e10cSrcweir 	OTools::ThrowException(_pConnection,
61*cdf0e10cSrcweir 							(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
62*cdf0e10cSrcweir 										(SQLUSMALLINT)columnIndex,
63*cdf0e10cSrcweir 										_nType,
64*cdf0e10cSrcweir 										_pValue,
65*cdf0e10cSrcweir 										_nSize,
66*cdf0e10cSrcweir 										&pcbValue),
67*cdf0e10cSrcweir 							_aStatementHandle,SQL_HANDLE_STMT,_xInterface,sal_False);
68*cdf0e10cSrcweir 	_bWasNull = pcbValue == SQL_NULL_DATA;
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir // -----------------------------------------------------------------------------
71*cdf0e10cSrcweir void OTools::bindParameter(	OConnection* _pConnection,
72*cdf0e10cSrcweir 							SQLHANDLE _hStmt,
73*cdf0e10cSrcweir 							sal_Int32 nPos,
74*cdf0e10cSrcweir 							sal_Int8*& pDataBuffer,
75*cdf0e10cSrcweir 							sal_Int8* pLenBuffer,
76*cdf0e10cSrcweir 							SQLSMALLINT _nODBCtype,
77*cdf0e10cSrcweir 							sal_Bool _bUseWChar,
78*cdf0e10cSrcweir 							sal_Bool _bUseOldTimeDate,
79*cdf0e10cSrcweir 							const void* _pValue,
80*cdf0e10cSrcweir 							const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
81*cdf0e10cSrcweir 							rtl_TextEncoding _nTextEncoding)
82*cdf0e10cSrcweir 							 throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
83*cdf0e10cSrcweir {
84*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::bindParameter" );
85*cdf0e10cSrcweir 	SQLRETURN nRetcode;
86*cdf0e10cSrcweir 	SQLSMALLINT fSqlType;
87*cdf0e10cSrcweir 	SQLSMALLINT fCType;
88*cdf0e10cSrcweir 	SQLLEN  nMaxLen = 0;
89*cdf0e10cSrcweir 	//	void*&   pData   = pDataBuffer;
90*cdf0e10cSrcweir 	SQLLEN* pLen    = (SQLLEN*)pLenBuffer;
91*cdf0e10cSrcweir 	SQLULEN nColumnSize=0;
92*cdf0e10cSrcweir 	SQLSMALLINT	nDecimalDigits=0;
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 	OTools::getBindTypes(_bUseWChar,_bUseOldTimeDate,_nODBCtype,fCType,fSqlType);
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 	OTools::bindData(_nODBCtype,_bUseWChar,pDataBuffer,pLen,_pValue,_nTextEncoding,nColumnSize);
97*cdf0e10cSrcweir 	if ((nColumnSize == 0) && (fSqlType == SQL_CHAR || fSqlType == SQL_VARCHAR || fSqlType == SQL_LONGVARCHAR))
98*cdf0e10cSrcweir 		nColumnSize = 1;
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	if(fSqlType == SQL_LONGVARCHAR || fSqlType == SQL_LONGVARBINARY)
101*cdf0e10cSrcweir 		memcpy(pDataBuffer,&nPos,sizeof(nPos));
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 	// 20.09.2001 OJ: Problems with mysql. mysql returns only CHAR as parameter type
104*cdf0e10cSrcweir 	//	nRetcode = (*(T3SQLDescribeParam)_pConnection->getOdbcFunction(ODBC3SQLDescribeParam))(_hStmt,(SQLUSMALLINT)nPos,&fSqlType,&nColumnSize,&nDecimalDigits,&nNullable);
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 	nRetcode = (*(T3SQLBindParameter)_pConnection->getOdbcFunction(ODBC3SQLBindParameter))(_hStmt,
107*cdf0e10cSrcweir 				  (SQLUSMALLINT)nPos,
108*cdf0e10cSrcweir 				  SQL_PARAM_INPUT,
109*cdf0e10cSrcweir 				  fCType,
110*cdf0e10cSrcweir 				  fSqlType,
111*cdf0e10cSrcweir 				  nColumnSize,
112*cdf0e10cSrcweir 				  nDecimalDigits,
113*cdf0e10cSrcweir 				  pDataBuffer,
114*cdf0e10cSrcweir 				  nMaxLen,
115*cdf0e10cSrcweir 				  pLen);
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	OTools::ThrowException(_pConnection,nRetcode,_hStmt,SQL_HANDLE_STMT,_xInterface);
118*cdf0e10cSrcweir }
119*cdf0e10cSrcweir // -----------------------------------------------------------------------------
120*cdf0e10cSrcweir void OTools::bindData(	SQLSMALLINT _nOdbcType,
121*cdf0e10cSrcweir 						sal_Bool _bUseWChar,
122*cdf0e10cSrcweir 						sal_Int8 *&_pData,
123*cdf0e10cSrcweir 						SQLLEN*& pLen,
124*cdf0e10cSrcweir 						const void* _pValue,
125*cdf0e10cSrcweir 						rtl_TextEncoding _nTextEncoding,
126*cdf0e10cSrcweir 						SQLULEN& _nColumnSize)
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::bindData" );
129*cdf0e10cSrcweir 	_nColumnSize = 0;
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 	switch (_nOdbcType)
132*cdf0e10cSrcweir 	{
133*cdf0e10cSrcweir 		case SQL_CHAR:
134*cdf0e10cSrcweir 		case SQL_VARCHAR:
135*cdf0e10cSrcweir 		case SQL_DECIMAL:
136*cdf0e10cSrcweir 			if(_bUseWChar)
137*cdf0e10cSrcweir 			{
138*cdf0e10cSrcweir 				*pLen = SQL_NTS;
139*cdf0e10cSrcweir 				::rtl::OUString sStr(*(::rtl::OUString*)_pValue);
140*cdf0e10cSrcweir 				_nColumnSize = sStr.getLength();
141*cdf0e10cSrcweir 				*((rtl::OUString*)_pData) = sStr;
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 				// Zeiger auf Char*
144*cdf0e10cSrcweir 				_pData = (sal_Int8*)((rtl::OUString*)_pData)->getStr();
145*cdf0e10cSrcweir 			}
146*cdf0e10cSrcweir 			else
147*cdf0e10cSrcweir 			{
148*cdf0e10cSrcweir 				::rtl::OString aString(::rtl::OUStringToOString(*(::rtl::OUString*)_pValue,_nTextEncoding));
149*cdf0e10cSrcweir 				*pLen = SQL_NTS;
150*cdf0e10cSrcweir 				_nColumnSize = aString.getLength();
151*cdf0e10cSrcweir                 memcpy(_pData,aString.getStr(),aString.getLength());
152*cdf0e10cSrcweir 				((sal_Int8*)_pData)[aString.getLength()] = '\0';
153*cdf0e10cSrcweir 			}
154*cdf0e10cSrcweir 			break;
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 		case SQL_BIGINT:
157*cdf0e10cSrcweir 			*((sal_Int64*)_pData) = *(sal_Int64*)_pValue;
158*cdf0e10cSrcweir 			*pLen = sizeof(sal_Int64);
159*cdf0e10cSrcweir 			_nColumnSize = *pLen;
160*cdf0e10cSrcweir 			break;
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 		case SQL_NUMERIC:
163*cdf0e10cSrcweir 			if(_bUseWChar)
164*cdf0e10cSrcweir 			{
165*cdf0e10cSrcweir 				::rtl::OUString aString = rtl::OUString::valueOf(*(double*)_pValue);
166*cdf0e10cSrcweir 				_nColumnSize = aString.getLength();
167*cdf0e10cSrcweir 				*pLen = _nColumnSize;
168*cdf0e10cSrcweir 				*((rtl::OUString*)_pData) = aString;
169*cdf0e10cSrcweir 				// Zeiger auf Char*
170*cdf0e10cSrcweir 				_pData = (sal_Int8*)((rtl::OUString*)_pData)->getStr();
171*cdf0e10cSrcweir 			}
172*cdf0e10cSrcweir 			else
173*cdf0e10cSrcweir 			{
174*cdf0e10cSrcweir 				::rtl::OString aString = ::rtl::OString::valueOf(*(double*)_pValue);
175*cdf0e10cSrcweir 				_nColumnSize = aString.getLength();
176*cdf0e10cSrcweir 				*pLen = _nColumnSize;
177*cdf0e10cSrcweir                 memcpy(_pData,aString.getStr(),aString.getLength());
178*cdf0e10cSrcweir 				((sal_Int8*)_pData)[_nColumnSize] = '\0';
179*cdf0e10cSrcweir 			}	break;
180*cdf0e10cSrcweir 		case SQL_BIT:
181*cdf0e10cSrcweir 		case SQL_TINYINT:
182*cdf0e10cSrcweir 			*((sal_Int8*)_pData) = *(sal_Int8*)_pValue;
183*cdf0e10cSrcweir 			*pLen = sizeof(sal_Int8);
184*cdf0e10cSrcweir 			break;
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir 		case SQL_SMALLINT:
187*cdf0e10cSrcweir 			*((sal_Int16*)_pData) = *(sal_Int16*)_pValue;
188*cdf0e10cSrcweir 			*pLen = sizeof(sal_Int16);
189*cdf0e10cSrcweir 			break;
190*cdf0e10cSrcweir 		case SQL_INTEGER:
191*cdf0e10cSrcweir 			*((sal_Int32*)_pData) = *(sal_Int32*)_pValue;
192*cdf0e10cSrcweir 			*pLen = sizeof(sal_Int32);
193*cdf0e10cSrcweir 			break;
194*cdf0e10cSrcweir 		case SQL_FLOAT:
195*cdf0e10cSrcweir 			*((float*)_pData) = *(float*)_pValue;
196*cdf0e10cSrcweir 			*pLen = sizeof(float);
197*cdf0e10cSrcweir 			break;
198*cdf0e10cSrcweir 		case SQL_REAL:
199*cdf0e10cSrcweir 		case SQL_DOUBLE:
200*cdf0e10cSrcweir 			*((double*)_pData) = *(double*)_pValue;
201*cdf0e10cSrcweir 			*pLen = sizeof(double);
202*cdf0e10cSrcweir 			break;
203*cdf0e10cSrcweir 		case SQL_BINARY:
204*cdf0e10cSrcweir 		case SQL_VARBINARY:
205*cdf0e10cSrcweir 			{
206*cdf0e10cSrcweir 				const ::com::sun::star::uno::Sequence< sal_Int8 >* pSeq = static_cast< const ::com::sun::star::uno::Sequence< sal_Int8 >* >(_pValue);
207*cdf0e10cSrcweir 				OSL_ENSURE(pSeq,"OTools::bindData: Sequence is null!");
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 				if(pSeq)
210*cdf0e10cSrcweir 				{
211*cdf0e10cSrcweir 					_pData = (sal_Int8*)pSeq->getConstArray();
212*cdf0e10cSrcweir 					*pLen = pSeq->getLength();
213*cdf0e10cSrcweir 				}
214*cdf0e10cSrcweir 			}
215*cdf0e10cSrcweir 			break;
216*cdf0e10cSrcweir 		case SQL_LONGVARBINARY:
217*cdf0e10cSrcweir 			{
218*cdf0e10cSrcweir 				sal_Int32 nLen = 0;
219*cdf0e10cSrcweir                 nLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength();
220*cdf0e10cSrcweir 				*pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen);
221*cdf0e10cSrcweir 			}
222*cdf0e10cSrcweir 			break;
223*cdf0e10cSrcweir 		case SQL_LONGVARCHAR:
224*cdf0e10cSrcweir 		{
225*cdf0e10cSrcweir 			sal_Int32 nLen = 0;
226*cdf0e10cSrcweir 			if(_bUseWChar)
227*cdf0e10cSrcweir 				nLen = sizeof(sal_Unicode) * ((::rtl::OUString*)_pValue)->getLength();
228*cdf0e10cSrcweir 			else
229*cdf0e10cSrcweir 			{
230*cdf0e10cSrcweir 				::rtl::OString aString(::rtl::OUStringToOString(*(::rtl::OUString*)_pValue,_nTextEncoding));
231*cdf0e10cSrcweir 				nLen = aString.getLength();
232*cdf0e10cSrcweir 			}
233*cdf0e10cSrcweir 			*pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen);
234*cdf0e10cSrcweir 		}   break;
235*cdf0e10cSrcweir 		case SQL_DATE:
236*cdf0e10cSrcweir 			*(DATE_STRUCT*)_pData = *(DATE_STRUCT*)_pValue;
237*cdf0e10cSrcweir 			*pLen = (SQLLEN)sizeof(DATE_STRUCT);
238*cdf0e10cSrcweir 			_nColumnSize = 10;
239*cdf0e10cSrcweir 			break;
240*cdf0e10cSrcweir 		case SQL_TIME:
241*cdf0e10cSrcweir 			*(TIME_STRUCT*)_pData = *(TIME_STRUCT*)_pValue;
242*cdf0e10cSrcweir 			*pLen = (SQLLEN)sizeof(TIME_STRUCT);
243*cdf0e10cSrcweir 			_nColumnSize = 8;
244*cdf0e10cSrcweir 			break;
245*cdf0e10cSrcweir 		case SQL_TIMESTAMP:
246*cdf0e10cSrcweir 			*(TIMESTAMP_STRUCT*)_pData = *(TIMESTAMP_STRUCT*)_pValue;
247*cdf0e10cSrcweir 			*pLen = (SQLLEN)sizeof(TIMESTAMP_STRUCT);
248*cdf0e10cSrcweir 			_nColumnSize = 19;
249*cdf0e10cSrcweir 			break;
250*cdf0e10cSrcweir 	}
251*cdf0e10cSrcweir }
252*cdf0e10cSrcweir // -------------------------------------------------------------------------
253*cdf0e10cSrcweir void OTools::bindValue(	OConnection* _pConnection,
254*cdf0e10cSrcweir 						SQLHANDLE _aStatementHandle,
255*cdf0e10cSrcweir 						sal_Int32 columnIndex,
256*cdf0e10cSrcweir 						SQLSMALLINT _nType,
257*cdf0e10cSrcweir 						SQLSMALLINT _nMaxLen,
258*cdf0e10cSrcweir 						const void* _pValue,
259*cdf0e10cSrcweir 						void* _pData,
260*cdf0e10cSrcweir 						SQLLEN *pLen,
261*cdf0e10cSrcweir 						const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
262*cdf0e10cSrcweir 						rtl_TextEncoding _nTextEncoding,
263*cdf0e10cSrcweir 						sal_Bool _bUseOldTimeDate) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
264*cdf0e10cSrcweir {
265*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::bindValue" );
266*cdf0e10cSrcweir 	SQLRETURN nRetcode;
267*cdf0e10cSrcweir 	SQLSMALLINT   fSqlType;
268*cdf0e10cSrcweir 	SQLSMALLINT   fCType;
269*cdf0e10cSrcweir 	SQLLEN nMaxLen = _nMaxLen;
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir 	OTools::getBindTypes(	sal_False,
272*cdf0e10cSrcweir 							_bUseOldTimeDate,
273*cdf0e10cSrcweir 							_nType,
274*cdf0e10cSrcweir 							fCType,
275*cdf0e10cSrcweir 							fSqlType);
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir 	if (columnIndex != 0 && !_pValue)
278*cdf0e10cSrcweir 	{
279*cdf0e10cSrcweir 		*pLen = SQL_NULL_DATA;
280*cdf0e10cSrcweir 		nRetcode = (*(T3SQLBindCol)_pConnection->getOdbcFunction(ODBC3SQLBindCol))(_aStatementHandle,
281*cdf0e10cSrcweir 								(SQLUSMALLINT)columnIndex,
282*cdf0e10cSrcweir 								fCType,
283*cdf0e10cSrcweir 								_pData,
284*cdf0e10cSrcweir 								nMaxLen,
285*cdf0e10cSrcweir 								pLen
286*cdf0e10cSrcweir 								);
287*cdf0e10cSrcweir 	}
288*cdf0e10cSrcweir 	else
289*cdf0e10cSrcweir 	{
290*cdf0e10cSrcweir 		try
291*cdf0e10cSrcweir 		{
292*cdf0e10cSrcweir 			switch (_nType)
293*cdf0e10cSrcweir 			{
294*cdf0e10cSrcweir 				case SQL_CHAR:
295*cdf0e10cSrcweir 				case SQL_VARCHAR:
296*cdf0e10cSrcweir 				//if(GetODBCConnection()->m_bUserWChar)
297*cdf0e10cSrcweir //				{
298*cdf0e10cSrcweir //					_nMaxLen = rCol.GetPrecision();
299*cdf0e10cSrcweir //					*pLen = SQL_NTS;
300*cdf0e10cSrcweir //					*((rtl::OUString*)pData) = (rtl::OUString)_aValue;
301*cdf0e10cSrcweir //
302*cdf0e10cSrcweir //					// Zeiger auf Char*
303*cdf0e10cSrcweir //					pData = (void*)((rtl::OUString*)pData)->getStr();
304*cdf0e10cSrcweir //				}
305*cdf0e10cSrcweir //				else
306*cdf0e10cSrcweir 				{
307*cdf0e10cSrcweir 					::rtl::OString aString(::rtl::OUStringToOString(*(::rtl::OUString*)_pValue,_nTextEncoding));
308*cdf0e10cSrcweir 					*pLen = SQL_NTS;
309*cdf0e10cSrcweir 					*((::rtl::OString*)_pData) = aString;
310*cdf0e10cSrcweir 					_nMaxLen = (SQLSMALLINT)aString.getLength();
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir 					// Zeiger auf Char*
313*cdf0e10cSrcweir 					_pData = (void*)aString.getStr();
314*cdf0e10cSrcweir 				}	break;
315*cdf0e10cSrcweir 				case SQL_BIGINT:
316*cdf0e10cSrcweir 					*((sal_Int64*)_pData) = *(sal_Int64*)_pValue;
317*cdf0e10cSrcweir 					*pLen = sizeof(sal_Int64);
318*cdf0e10cSrcweir 					break;
319*cdf0e10cSrcweir 				case SQL_DECIMAL:
320*cdf0e10cSrcweir 				case SQL_NUMERIC:
321*cdf0e10cSrcweir 				//if(GetODBCConnection()->m_bUserWChar)
322*cdf0e10cSrcweir //				{
323*cdf0e10cSrcweir //					rtl::OUString aString(rtl::OUString(SdbTools::ToString(ODbTypeConversion::toDouble(*pVariable),rCol.GetScale())));
324*cdf0e10cSrcweir //					*pLen = _nMaxLen;
325*cdf0e10cSrcweir //					*((rtl::OUString*)_pData) = aString;
326*cdf0e10cSrcweir //					// Zeiger auf Char*
327*cdf0e10cSrcweir //					_pData = (void*)((rtl::OUString*)_pData)->getStr();
328*cdf0e10cSrcweir //				}
329*cdf0e10cSrcweir //				else
330*cdf0e10cSrcweir 				{
331*cdf0e10cSrcweir 					::rtl::OString aString = ::rtl::OString::valueOf(*(double*)_pValue);
332*cdf0e10cSrcweir 					_nMaxLen = (SQLSMALLINT)aString.getLength();
333*cdf0e10cSrcweir 					*pLen = _nMaxLen;
334*cdf0e10cSrcweir 					*((::rtl::OString*)_pData) = aString;
335*cdf0e10cSrcweir 					// Zeiger auf Char*
336*cdf0e10cSrcweir 					_pData = (void*)((::rtl::OString*)_pData)->getStr();
337*cdf0e10cSrcweir 				}	break;
338*cdf0e10cSrcweir 				case SQL_BIT:
339*cdf0e10cSrcweir 				case SQL_TINYINT:
340*cdf0e10cSrcweir 					*((sal_Int8*)_pData) = *(sal_Int8*)_pValue;
341*cdf0e10cSrcweir 					*pLen = sizeof(sal_Int8);
342*cdf0e10cSrcweir 					break;
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir 				case SQL_SMALLINT:
345*cdf0e10cSrcweir 					*((sal_Int16*)_pData) = *(sal_Int16*)_pValue;
346*cdf0e10cSrcweir 					*pLen = sizeof(sal_Int16);
347*cdf0e10cSrcweir 					break;
348*cdf0e10cSrcweir 				case SQL_INTEGER:
349*cdf0e10cSrcweir 					*((sal_Int32*)_pData) = *(sal_Int32*)_pValue;
350*cdf0e10cSrcweir 					*pLen = sizeof(sal_Int32);
351*cdf0e10cSrcweir 					break;
352*cdf0e10cSrcweir 				case SQL_FLOAT:
353*cdf0e10cSrcweir 					*((float*)_pData) = *(float*)_pValue;
354*cdf0e10cSrcweir 					*pLen = sizeof(float);
355*cdf0e10cSrcweir 					break;
356*cdf0e10cSrcweir 				case SQL_REAL:
357*cdf0e10cSrcweir 				case SQL_DOUBLE:
358*cdf0e10cSrcweir 					*((double*)_pData) = *(double*)_pValue;
359*cdf0e10cSrcweir 					*pLen = sizeof(double);
360*cdf0e10cSrcweir 					break;
361*cdf0e10cSrcweir 				case SQL_BINARY:
362*cdf0e10cSrcweir 				case SQL_VARBINARY:
363*cdf0e10cSrcweir                                                 //      if (_pValue == ::getCppuType((const ::com::sun::star::uno::Sequence< sal_Int8 > *)0))
364*cdf0e10cSrcweir 					{
365*cdf0e10cSrcweir                         _pData = (void*)((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getConstArray();
366*cdf0e10cSrcweir                         *pLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength();
367*cdf0e10cSrcweir 					}	break;
368*cdf0e10cSrcweir 				case SQL_LONGVARBINARY:
369*cdf0e10cSrcweir 				{
370*cdf0e10cSrcweir 					_pData = (void*)(columnIndex);
371*cdf0e10cSrcweir 					sal_Int32 nLen = 0;
372*cdf0e10cSrcweir                     nLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength();
373*cdf0e10cSrcweir 					*pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen);
374*cdf0e10cSrcweir 				}
375*cdf0e10cSrcweir 					break;
376*cdf0e10cSrcweir 				case SQL_LONGVARCHAR:
377*cdf0e10cSrcweir 				{
378*cdf0e10cSrcweir 					_pData = (void*)(columnIndex);
379*cdf0e10cSrcweir 					sal_Int32 nLen = 0;
380*cdf0e10cSrcweir 					nLen = ((::rtl::OUString*)_pValue)->getLength();
381*cdf0e10cSrcweir 					*pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen);
382*cdf0e10cSrcweir 				}   break;
383*cdf0e10cSrcweir 				case SQL_DATE:
384*cdf0e10cSrcweir 					*pLen = sizeof(DATE_STRUCT);
385*cdf0e10cSrcweir 					*((DATE_STRUCT*)_pData) = *(DATE_STRUCT*)_pValue;
386*cdf0e10cSrcweir 					break;
387*cdf0e10cSrcweir 				case SQL_TIME:
388*cdf0e10cSrcweir 					*pLen = sizeof(TIME_STRUCT);
389*cdf0e10cSrcweir 					*((TIME_STRUCT*)_pData) = *(TIME_STRUCT*)_pValue;
390*cdf0e10cSrcweir 					break;
391*cdf0e10cSrcweir 				case SQL_TIMESTAMP:
392*cdf0e10cSrcweir 					*pLen = sizeof(TIMESTAMP_STRUCT);
393*cdf0e10cSrcweir 					*((TIMESTAMP_STRUCT*)_pData) = *(TIMESTAMP_STRUCT*)_pValue;
394*cdf0e10cSrcweir                     break;
395*cdf0e10cSrcweir 			}
396*cdf0e10cSrcweir 		}
397*cdf0e10cSrcweir 		catch ( ... )
398*cdf0e10cSrcweir 		{
399*cdf0e10cSrcweir 		}
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 		nRetcode = (*(T3SQLBindCol)_pConnection->getOdbcFunction(ODBC3SQLBindCol))(_aStatementHandle,
402*cdf0e10cSrcweir 								(SQLUSMALLINT)columnIndex,
403*cdf0e10cSrcweir 								fCType,
404*cdf0e10cSrcweir 								_pData,
405*cdf0e10cSrcweir 								nMaxLen,
406*cdf0e10cSrcweir 								pLen
407*cdf0e10cSrcweir 								);
408*cdf0e10cSrcweir 	}
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir 	OTools::ThrowException(_pConnection,nRetcode,_aStatementHandle,SQL_HANDLE_STMT,_xInterface);
411*cdf0e10cSrcweir }
412*cdf0e10cSrcweir // -----------------------------------------------------------------------------
413*cdf0e10cSrcweir void OTools::ThrowException(OConnection* _pConnection,
414*cdf0e10cSrcweir 							SQLRETURN _rRetCode,
415*cdf0e10cSrcweir 							SQLHANDLE _pContext,
416*cdf0e10cSrcweir 							SQLSMALLINT _nHandleType,
417*cdf0e10cSrcweir 							const Reference< XInterface >& _xInterface,
418*cdf0e10cSrcweir 							sal_Bool _bNoFound,
419*cdf0e10cSrcweir 							rtl_TextEncoding _nTextEncoding) throw(SQLException)
420*cdf0e10cSrcweir {
421*cdf0e10cSrcweir 	switch(_rRetCode)
422*cdf0e10cSrcweir 	{
423*cdf0e10cSrcweir 		case SQL_NEED_DATA:
424*cdf0e10cSrcweir 		case SQL_STILL_EXECUTING:
425*cdf0e10cSrcweir 		case SQL_SUCCESS:
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir 		case SQL_SUCCESS_WITH_INFO:
428*cdf0e10cSrcweir 						return;
429*cdf0e10cSrcweir 		case SQL_NO_DATA_FOUND:
430*cdf0e10cSrcweir 								if(_bNoFound)
431*cdf0e10cSrcweir 									return; // no need to throw a exception
432*cdf0e10cSrcweir 		case SQL_ERROR:             break;
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir 		case SQL_INVALID_HANDLE:    OSL_ENSURE(0,"SdbODBC3_SetStatus: SQL_INVALID_HANDLE");
436*cdf0e10cSrcweir 									throw SQLException();
437*cdf0e10cSrcweir 	}
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir 	// Zusaetliche Informationen zum letzten ODBC-Funktionsaufruf vorhanden.
441*cdf0e10cSrcweir 	// SQLError liefert diese Informationen.
442*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::ThrowException" );
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir 	SDB_ODBC_CHAR szSqlState[5];
445*cdf0e10cSrcweir 	SQLINTEGER pfNativeError;
446*cdf0e10cSrcweir 	SDB_ODBC_CHAR szErrorMessage[SQL_MAX_MESSAGE_LENGTH];
447*cdf0e10cSrcweir 	szErrorMessage[0] = '\0';
448*cdf0e10cSrcweir 	SQLSMALLINT pcbErrorMsg = 0;
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir 	// Informationen zur letzten Operation:
451*cdf0e10cSrcweir 	// wenn hstmt != SQL_NULL_HSTMT ist (Benutzung von SetStatus in SdbCursor, SdbTable, ...),
452*cdf0e10cSrcweir 	// dann wird der Status des letzten Statements erfragt, sonst der Status des letzten
453*cdf0e10cSrcweir 	// Statements zu dieser Verbindung [was in unserem Fall wahrscheinlich gleichbedeutend ist,
454*cdf0e10cSrcweir 	// aber das Reference Manual drueckt sich da nicht so klar aus ...].
455*cdf0e10cSrcweir 	// Entsprechend bei hdbc.
456*cdf0e10cSrcweir 	SQLRETURN n = (*(T3SQLGetDiagRec)_pConnection->getOdbcFunction(ODBC3SQLGetDiagRec))(_nHandleType,_pContext,1,
457*cdf0e10cSrcweir 						 szSqlState,
458*cdf0e10cSrcweir 						 &pfNativeError,
459*cdf0e10cSrcweir 						 szErrorMessage,sizeof szErrorMessage - 1,&pcbErrorMsg);
460*cdf0e10cSrcweir     OSL_UNUSED( n );
461*cdf0e10cSrcweir 	OSL_ENSURE(n != SQL_INVALID_HANDLE,"SdbODBC3_SetStatus: SQLError returned SQL_INVALID_HANDLE");
462*cdf0e10cSrcweir 	OSL_ENSURE(n == SQL_SUCCESS || n == SQL_SUCCESS_WITH_INFO || n == SQL_NO_DATA_FOUND || n == SQL_ERROR,"SdbODBC3_SetStatus: SQLError failed");
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir 	// Zum Return Code von SQLError siehe ODBC 2.0 Programmer's Reference Seite 287ff
465*cdf0e10cSrcweir 	throw SQLException(	::rtl::OUString((char *)szErrorMessage,pcbErrorMsg,_nTextEncoding),
466*cdf0e10cSrcweir 									_xInterface,
467*cdf0e10cSrcweir 									::rtl::OUString((char *)szSqlState,5,_nTextEncoding),
468*cdf0e10cSrcweir 									pfNativeError,
469*cdf0e10cSrcweir 									Any()
470*cdf0e10cSrcweir 								);
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir }
473*cdf0e10cSrcweir // -------------------------------------------------------------------------
474*cdf0e10cSrcweir Sequence<sal_Int8> OTools::getBytesValue(OConnection* _pConnection,
475*cdf0e10cSrcweir 										 SQLHANDLE _aStatementHandle,
476*cdf0e10cSrcweir 										 sal_Int32 columnIndex,
477*cdf0e10cSrcweir 										 SQLSMALLINT _fSqlType,
478*cdf0e10cSrcweir 										 sal_Bool &_bWasNull,
479*cdf0e10cSrcweir 										 const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException)
480*cdf0e10cSrcweir {
481*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::getBytesValue" );
482*cdf0e10cSrcweir 	char aCharArray[2048];
483*cdf0e10cSrcweir 	// Erstmal versuchen, die Daten mit dem kleinen Puffer
484*cdf0e10cSrcweir 	// abzuholen:
485*cdf0e10cSrcweir 	SQLLEN nMaxLen = sizeof aCharArray - 1;
486*cdf0e10cSrcweir 	//	GETDATA(SQL_C_CHAR,aCharArray,nMaxLen);
487*cdf0e10cSrcweir 	SQLLEN pcbValue = 0;
488*cdf0e10cSrcweir 	OTools::ThrowException(_pConnection,(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
489*cdf0e10cSrcweir 										(SQLUSMALLINT)columnIndex,
490*cdf0e10cSrcweir 										_fSqlType,
491*cdf0e10cSrcweir 										(SQLPOINTER)aCharArray,
492*cdf0e10cSrcweir 										nMaxLen,
493*cdf0e10cSrcweir 										&pcbValue),
494*cdf0e10cSrcweir 							_aStatementHandle,SQL_HANDLE_STMT,_xInterface);
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir 	_bWasNull = pcbValue == SQL_NULL_DATA;
497*cdf0e10cSrcweir 	if(_bWasNull)
498*cdf0e10cSrcweir 		return Sequence<sal_Int8>();
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 	SQLINTEGER nBytes = pcbValue != SQL_NO_TOTAL ? std::min(pcbValue, nMaxLen) : nMaxLen;
501*cdf0e10cSrcweir 	if ( ((pcbValue == SQL_NO_TOTAL) || pcbValue > nMaxLen) && aCharArray[nBytes-1] == 0  && nBytes > 0 )
502*cdf0e10cSrcweir 		--nBytes;
503*cdf0e10cSrcweir 	Sequence<sal_Int8> aData((sal_Int8*)aCharArray, nBytes);
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir 	// Es handelt sich um Binaerdaten, um einen String, der fuer
507*cdf0e10cSrcweir 	// StarView zu lang ist oder der Treiber kann die Laenge der
508*cdf0e10cSrcweir 	// Daten nicht im voraus bestimmen - also als MemoryStream
509*cdf0e10cSrcweir 	// speichern.
510*cdf0e10cSrcweir 	while ((pcbValue == SQL_NO_TOTAL) || pcbValue > nMaxLen)
511*cdf0e10cSrcweir 	{
512*cdf0e10cSrcweir 		// Bei Strings wird der Puffer nie ganz ausgenutzt
513*cdf0e10cSrcweir 		// (das letzte Byte ist immer ein NULL-Byte, das
514*cdf0e10cSrcweir 		// aber bei pcbValue nicht mitgezaehlt wird)
515*cdf0e10cSrcweir 		if (pcbValue != SQL_NO_TOTAL && (pcbValue - nMaxLen) < nMaxLen)
516*cdf0e10cSrcweir 			nBytes = pcbValue - nMaxLen;
517*cdf0e10cSrcweir 		else
518*cdf0e10cSrcweir 			nBytes = nMaxLen;
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir 		// Solange eine "truncation"-Warnung vorliegt, weiter Daten abholen
521*cdf0e10cSrcweir 		//	GETDATA(SQL_C_CHAR,aCharArray, nLen + 1);
522*cdf0e10cSrcweir 		OTools::ThrowException(_pConnection,(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
523*cdf0e10cSrcweir 										(SQLUSMALLINT)columnIndex,
524*cdf0e10cSrcweir 										SQL_C_BINARY,
525*cdf0e10cSrcweir 										&aCharArray,
526*cdf0e10cSrcweir 										(SQLINTEGER)nBytes,
527*cdf0e10cSrcweir 										&pcbValue),
528*cdf0e10cSrcweir 							_aStatementHandle,SQL_HANDLE_STMT,_xInterface);
529*cdf0e10cSrcweir 		sal_Int32 nLen = aData.getLength();
530*cdf0e10cSrcweir 		aData.realloc(nLen + nBytes);
531*cdf0e10cSrcweir         memcpy(aData.getArray() + nLen, aCharArray, nBytes);
532*cdf0e10cSrcweir 	}
533*cdf0e10cSrcweir 	return aData;
534*cdf0e10cSrcweir }
535*cdf0e10cSrcweir // -------------------------------------------------------------------------
536*cdf0e10cSrcweir ::rtl::OUString OTools::getStringValue(OConnection* _pConnection,
537*cdf0e10cSrcweir 									   SQLHANDLE _aStatementHandle,
538*cdf0e10cSrcweir 									   sal_Int32 columnIndex,
539*cdf0e10cSrcweir 									   SQLSMALLINT _fSqlType,
540*cdf0e10cSrcweir 									   sal_Bool &_bWasNull,
541*cdf0e10cSrcweir 									   const Reference< XInterface >& _xInterface,
542*cdf0e10cSrcweir 									   rtl_TextEncoding _nTextEncoding) throw(SQLException, RuntimeException)
543*cdf0e10cSrcweir {
544*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::getStringValue" );
545*cdf0e10cSrcweir 	::rtl::OUStringBuffer aData;
546*cdf0e10cSrcweir 	switch(_fSqlType)
547*cdf0e10cSrcweir 	{
548*cdf0e10cSrcweir 	case SQL_WVARCHAR:
549*cdf0e10cSrcweir 	case SQL_WCHAR:
550*cdf0e10cSrcweir 	case SQL_WLONGVARCHAR:
551*cdf0e10cSrcweir 		{
552*cdf0e10cSrcweir 			sal_Unicode waCharArray[2048];
553*cdf0e10cSrcweir 			// read the unicode data
554*cdf0e10cSrcweir 			SQLLEN nMaxLen = (sizeof(waCharArray) / sizeof(sal_Unicode)) - 1;
555*cdf0e10cSrcweir 			//	GETDATA(SQL_C_WCHAR, waCharArray, nMaxLen + sizeof(sal_Unicode));
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir 			SQLLEN pcbValue=0;
558*cdf0e10cSrcweir 			OTools::ThrowException(_pConnection,(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
559*cdf0e10cSrcweir 												(SQLUSMALLINT)columnIndex,
560*cdf0e10cSrcweir 												SQL_C_WCHAR,
561*cdf0e10cSrcweir 												&waCharArray,
562*cdf0e10cSrcweir 												(SQLLEN)nMaxLen*sizeof(sal_Unicode),
563*cdf0e10cSrcweir 												&pcbValue),
564*cdf0e10cSrcweir 									_aStatementHandle,SQL_HANDLE_STMT,_xInterface);
565*cdf0e10cSrcweir 			_bWasNull = pcbValue == SQL_NULL_DATA;
566*cdf0e10cSrcweir 			if(_bWasNull)
567*cdf0e10cSrcweir 				return ::rtl::OUString();
568*cdf0e10cSrcweir 			// Bei Fehler bricht der GETDATA-Makro mit return ab,
569*cdf0e10cSrcweir 			// bei NULL mit break!
570*cdf0e10cSrcweir             SQLLEN nRealSize = 0;
571*cdf0e10cSrcweir             if ( pcbValue > -1 )
572*cdf0e10cSrcweir                 nRealSize = pcbValue / sizeof(sal_Unicode);
573*cdf0e10cSrcweir 			SQLLEN nLen = pcbValue != SQL_NO_TOTAL ? std::min(nRealSize, nMaxLen) : (nMaxLen-1);
574*cdf0e10cSrcweir 			waCharArray[nLen] = 0;
575*cdf0e10cSrcweir 			aData.append(waCharArray,nLen);
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir 			// Es handelt sich um Binaerdaten, um einen String, der fuer
578*cdf0e10cSrcweir 			// StarView zu lang ist oder der Treiber kann die Laenge der
579*cdf0e10cSrcweir 			// Daten nicht im voraus bestimmen - also als MemoryStream
580*cdf0e10cSrcweir 			// speichern.
581*cdf0e10cSrcweir 			while ((pcbValue == SQL_NO_TOTAL ) || nLen > nMaxLen)
582*cdf0e10cSrcweir 			{
583*cdf0e10cSrcweir 				// Bei Strings wird der Puffer nie ganz ausgenutzt
584*cdf0e10cSrcweir 				// (das letzte Byte ist immer ein NULL-Byte, das
585*cdf0e10cSrcweir 				// aber bei pcbValue nicht mitgezaehlt wird)
586*cdf0e10cSrcweir 				if (pcbValue != SQL_NO_TOTAL && (pcbValue - nMaxLen) < nMaxLen)
587*cdf0e10cSrcweir 					nLen = pcbValue - nMaxLen;
588*cdf0e10cSrcweir 				else
589*cdf0e10cSrcweir 					nLen = nMaxLen;
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir 				// Solange eine "truncation"-Warnung vorliegt, weiter Daten abholen
592*cdf0e10cSrcweir 				//	GETDATA(SQL_C_CHAR,waCharArray, nLen + 1);
593*cdf0e10cSrcweir 				OTools::ThrowException(_pConnection,(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
594*cdf0e10cSrcweir 												(SQLUSMALLINT)columnIndex,
595*cdf0e10cSrcweir 												SQL_C_WCHAR,
596*cdf0e10cSrcweir 												&waCharArray,
597*cdf0e10cSrcweir 												(SQLLEN)nLen+1,
598*cdf0e10cSrcweir 												&pcbValue),
599*cdf0e10cSrcweir 									_aStatementHandle,SQL_HANDLE_STMT,_xInterface);
600*cdf0e10cSrcweir                 nRealSize = 0;
601*cdf0e10cSrcweir                 if ( pcbValue > -1 )
602*cdf0e10cSrcweir                     nRealSize = pcbValue / sizeof(sal_Unicode);
603*cdf0e10cSrcweir 				nLen = pcbValue != SQL_NO_TOTAL ? std::min(nRealSize, nMaxLen) : (nMaxLen-1);
604*cdf0e10cSrcweir 				waCharArray[nLen] = 0;
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir 				aData.append(::rtl::OUString(waCharArray));
607*cdf0e10cSrcweir 			}
608*cdf0e10cSrcweir 		}
609*cdf0e10cSrcweir 		break;
610*cdf0e10cSrcweir 		default:
611*cdf0e10cSrcweir 		{
612*cdf0e10cSrcweir 			char aCharArray[2048];
613*cdf0e10cSrcweir 			// Erstmal versuchen, die Daten mit dem kleinen Puffer
614*cdf0e10cSrcweir 			// abzuholen:
615*cdf0e10cSrcweir 			SQLLEN nMaxLen = sizeof aCharArray - 1;
616*cdf0e10cSrcweir 			//	GETDATA(SQL_C_CHAR,aCharArray,nMaxLen);
617*cdf0e10cSrcweir 			SQLLEN pcbValue = 0;
618*cdf0e10cSrcweir 			OTools::ThrowException(_pConnection,(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
619*cdf0e10cSrcweir 												(SQLUSMALLINT)columnIndex,
620*cdf0e10cSrcweir 												SQL_C_CHAR,
621*cdf0e10cSrcweir 												&aCharArray,
622*cdf0e10cSrcweir 												nMaxLen,
623*cdf0e10cSrcweir 												&pcbValue),
624*cdf0e10cSrcweir 									_aStatementHandle,SQL_HANDLE_STMT,_xInterface);
625*cdf0e10cSrcweir 			_bWasNull = pcbValue == SQL_NULL_DATA;
626*cdf0e10cSrcweir 			if(_bWasNull)
627*cdf0e10cSrcweir 				return ::rtl::OUString();
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir 			SQLLEN nLen = pcbValue != SQL_NO_TOTAL ? std::min(pcbValue, nMaxLen) : (nMaxLen-1);
630*cdf0e10cSrcweir 			aCharArray[nLen] = 0;
631*cdf0e10cSrcweir 			if ( ((pcbValue == SQL_NO_TOTAL) || pcbValue > nMaxLen) && aCharArray[nLen-1] == 0 && nLen > 0 )
632*cdf0e10cSrcweir 				--nLen;
633*cdf0e10cSrcweir 			aData.append(::rtl::OUString((const sal_Char*)aCharArray,nLen, _nTextEncoding));
634*cdf0e10cSrcweir 
635*cdf0e10cSrcweir 			// Es handelt sich um Binaerdaten, um einen String, der fuer
636*cdf0e10cSrcweir 			// StarView zu lang ist oder der Treiber kann die Laenge der
637*cdf0e10cSrcweir 			// Daten nicht im voraus bestimmen - also als MemoryStream
638*cdf0e10cSrcweir 			// speichern.
639*cdf0e10cSrcweir 			while ((pcbValue == SQL_NO_TOTAL) || pcbValue > nMaxLen)
640*cdf0e10cSrcweir 			{
641*cdf0e10cSrcweir 				// Solange eine "truncation"-Warnung vorliegt, weiter Daten abholen
642*cdf0e10cSrcweir 				//	GETDATA(SQL_C_CHAR,aCharArray, nLen + 1);
643*cdf0e10cSrcweir 				OTools::ThrowException(_pConnection,(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
644*cdf0e10cSrcweir 												(SQLUSMALLINT)columnIndex,
645*cdf0e10cSrcweir 												SQL_C_CHAR,
646*cdf0e10cSrcweir 												&aCharArray,
647*cdf0e10cSrcweir 												(SQLINTEGER)nMaxLen,
648*cdf0e10cSrcweir 												&pcbValue),
649*cdf0e10cSrcweir 									_aStatementHandle,SQL_HANDLE_STMT,_xInterface);
650*cdf0e10cSrcweir 				nLen = pcbValue != SQL_NO_TOTAL ? std::min(pcbValue, nMaxLen) : (nMaxLen-1);
651*cdf0e10cSrcweir 				if ( ((pcbValue == SQL_NO_TOTAL) || pcbValue > nMaxLen) && aCharArray[nLen-1] == 0 && nLen > 0 )
652*cdf0e10cSrcweir 					--nLen;
653*cdf0e10cSrcweir 				aCharArray[nLen] = 0;
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir 				aData.append(::rtl::OUString((const sal_Char*)aCharArray,nLen,_nTextEncoding));
656*cdf0e10cSrcweir 			}
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir 			// delete all blanks
659*cdf0e10cSrcweir 			//	aData.EraseTrailingChars();
660*cdf0e10cSrcweir 		}
661*cdf0e10cSrcweir 	}
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir 	return aData.makeStringAndClear();
664*cdf0e10cSrcweir }
665*cdf0e10cSrcweir // -------------------------------------------------------------------------
666*cdf0e10cSrcweir void OTools::GetInfo(OConnection* _pConnection,
667*cdf0e10cSrcweir 					 SQLHANDLE _aConnectionHandle,
668*cdf0e10cSrcweir 					 SQLUSMALLINT _nInfo,
669*cdf0e10cSrcweir 					 ::rtl::OUString &_rValue,
670*cdf0e10cSrcweir 					 const Reference< XInterface >& _xInterface,
671*cdf0e10cSrcweir 					 rtl_TextEncoding _nTextEncoding) throw(SQLException, RuntimeException)
672*cdf0e10cSrcweir {
673*cdf0e10cSrcweir 	char aValue[512];
674*cdf0e10cSrcweir 	SQLSMALLINT nValueLen=0;
675*cdf0e10cSrcweir 	OTools::ThrowException(_pConnection,
676*cdf0e10cSrcweir 		(*(T3SQLGetInfo)_pConnection->getOdbcFunction(ODBC3SQLGetInfo))(_aConnectionHandle,_nInfo,aValue,(sizeof aValue)-1,&nValueLen),
677*cdf0e10cSrcweir 		_aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
678*cdf0e10cSrcweir 
679*cdf0e10cSrcweir 	_rValue = ::rtl::OUString(aValue,nValueLen,_nTextEncoding);
680*cdf0e10cSrcweir }
681*cdf0e10cSrcweir // -------------------------------------------------------------------------
682*cdf0e10cSrcweir void OTools::GetInfo(OConnection* _pConnection,
683*cdf0e10cSrcweir 					 SQLHANDLE _aConnectionHandle,
684*cdf0e10cSrcweir 					 SQLUSMALLINT _nInfo,
685*cdf0e10cSrcweir 					 sal_Int32 &_rValue,
686*cdf0e10cSrcweir 					 const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException)
687*cdf0e10cSrcweir {
688*cdf0e10cSrcweir 	SQLSMALLINT nValueLen;
689*cdf0e10cSrcweir 	_rValue = 0;	// in case the driver uses only 16 of the 32 bits (as it does, for example, for SQL_CATALOG_LOCATION)
690*cdf0e10cSrcweir 	OTools::ThrowException(_pConnection,
691*cdf0e10cSrcweir 		(*(T3SQLGetInfo)_pConnection->getOdbcFunction(ODBC3SQLGetInfo))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
692*cdf0e10cSrcweir 		_aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
693*cdf0e10cSrcweir }
694*cdf0e10cSrcweir // -------------------------------------------------------------------------
695*cdf0e10cSrcweir void OTools::GetInfo(OConnection* _pConnection,
696*cdf0e10cSrcweir 					 SQLHANDLE _aConnectionHandle,
697*cdf0e10cSrcweir 					 SQLUSMALLINT _nInfo,
698*cdf0e10cSrcweir 					 SQLUINTEGER &_rValue,
699*cdf0e10cSrcweir 					 const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException)
700*cdf0e10cSrcweir {
701*cdf0e10cSrcweir 	SQLSMALLINT nValueLen;
702*cdf0e10cSrcweir 	_rValue = 0;	// in case the driver uses only 16 of the 32 bits (as it does, for example, for SQL_CATALOG_LOCATION)
703*cdf0e10cSrcweir 	OTools::ThrowException(_pConnection,
704*cdf0e10cSrcweir 		(*(T3SQLGetInfo)_pConnection->getOdbcFunction(ODBC3SQLGetInfo))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
705*cdf0e10cSrcweir 		_aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
706*cdf0e10cSrcweir }
707*cdf0e10cSrcweir // -------------------------------------------------------------------------
708*cdf0e10cSrcweir void OTools::GetInfo(OConnection* _pConnection,
709*cdf0e10cSrcweir 					 SQLHANDLE _aConnectionHandle,
710*cdf0e10cSrcweir 					 SQLUSMALLINT _nInfo,
711*cdf0e10cSrcweir 					 SQLUSMALLINT &_rValue,
712*cdf0e10cSrcweir 					 const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException)
713*cdf0e10cSrcweir {
714*cdf0e10cSrcweir 	SQLSMALLINT nValueLen;
715*cdf0e10cSrcweir 	_rValue = 0;	// in case the driver uses only 16 of the 32 bits (as it does, for example, for SQL_CATALOG_LOCATION)
716*cdf0e10cSrcweir 	OTools::ThrowException(_pConnection,
717*cdf0e10cSrcweir 		(*(T3SQLGetInfo)_pConnection->getOdbcFunction(ODBC3SQLGetInfo))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
718*cdf0e10cSrcweir 		_aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
719*cdf0e10cSrcweir }
720*cdf0e10cSrcweir // -------------------------------------------------------------------------
721*cdf0e10cSrcweir void OTools::GetInfo(OConnection* _pConnection,
722*cdf0e10cSrcweir 					 SQLHANDLE _aConnectionHandle,
723*cdf0e10cSrcweir 					 SQLUSMALLINT _nInfo,
724*cdf0e10cSrcweir 					 sal_Bool &_rValue,
725*cdf0e10cSrcweir 					 const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException)
726*cdf0e10cSrcweir {
727*cdf0e10cSrcweir 	SQLSMALLINT nValueLen;
728*cdf0e10cSrcweir 	OTools::ThrowException(_pConnection,
729*cdf0e10cSrcweir 							(*(T3SQLGetInfo)_pConnection->getOdbcFunction(ODBC3SQLGetInfo))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
730*cdf0e10cSrcweir 							_aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
731*cdf0e10cSrcweir }
732*cdf0e10cSrcweir // -------------------------------------------------------------------------
733*cdf0e10cSrcweir sal_Int32 OTools::MapOdbcType2Jdbc(sal_Int32 _nType)
734*cdf0e10cSrcweir {
735*cdf0e10cSrcweir 	sal_Int32 nValue = DataType::VARCHAR;
736*cdf0e10cSrcweir 	switch(_nType)
737*cdf0e10cSrcweir 	{
738*cdf0e10cSrcweir 		case SQL_BIT:
739*cdf0e10cSrcweir 			nValue = DataType::BIT;
740*cdf0e10cSrcweir 			break;
741*cdf0e10cSrcweir 		case SQL_TINYINT:
742*cdf0e10cSrcweir 			nValue = DataType::TINYINT;
743*cdf0e10cSrcweir 			break;
744*cdf0e10cSrcweir 		case SQL_SMALLINT:
745*cdf0e10cSrcweir 			nValue = DataType::SMALLINT;
746*cdf0e10cSrcweir 			break;
747*cdf0e10cSrcweir 		case SQL_INTEGER:
748*cdf0e10cSrcweir 			nValue = DataType::INTEGER;
749*cdf0e10cSrcweir 			break;
750*cdf0e10cSrcweir 		case SQL_BIGINT:
751*cdf0e10cSrcweir 			nValue = DataType::BIGINT;
752*cdf0e10cSrcweir 			break;
753*cdf0e10cSrcweir 		case SQL_FLOAT:
754*cdf0e10cSrcweir 			nValue = DataType::FLOAT;
755*cdf0e10cSrcweir 			break;
756*cdf0e10cSrcweir 		case SQL_REAL:
757*cdf0e10cSrcweir 			nValue = DataType::REAL;
758*cdf0e10cSrcweir 			break;
759*cdf0e10cSrcweir 		case SQL_DOUBLE:
760*cdf0e10cSrcweir 			nValue = DataType::DOUBLE;
761*cdf0e10cSrcweir 			break;
762*cdf0e10cSrcweir 		case SQL_NUMERIC:
763*cdf0e10cSrcweir 			nValue = DataType::NUMERIC;
764*cdf0e10cSrcweir 			break;
765*cdf0e10cSrcweir 		case SQL_DECIMAL:
766*cdf0e10cSrcweir 			nValue = DataType::DECIMAL;
767*cdf0e10cSrcweir 			break;
768*cdf0e10cSrcweir 		case SQL_WCHAR:
769*cdf0e10cSrcweir 		case SQL_CHAR:
770*cdf0e10cSrcweir 			nValue = DataType::CHAR;
771*cdf0e10cSrcweir 			break;
772*cdf0e10cSrcweir 		case SQL_WVARCHAR:
773*cdf0e10cSrcweir 		case SQL_VARCHAR:
774*cdf0e10cSrcweir 			nValue = DataType::VARCHAR;
775*cdf0e10cSrcweir 			break;
776*cdf0e10cSrcweir 		case SQL_WLONGVARCHAR:
777*cdf0e10cSrcweir 		case SQL_LONGVARCHAR:
778*cdf0e10cSrcweir 			nValue = DataType::LONGVARCHAR;
779*cdf0e10cSrcweir 			break;
780*cdf0e10cSrcweir 		case SQL_TYPE_DATE:
781*cdf0e10cSrcweir 		case SQL_DATE:
782*cdf0e10cSrcweir 			nValue = DataType::DATE;
783*cdf0e10cSrcweir 			break;
784*cdf0e10cSrcweir 		case SQL_TYPE_TIME:
785*cdf0e10cSrcweir 		case SQL_TIME:
786*cdf0e10cSrcweir 			nValue = DataType::TIME;
787*cdf0e10cSrcweir 			break;
788*cdf0e10cSrcweir 		case SQL_TYPE_TIMESTAMP:
789*cdf0e10cSrcweir 		case SQL_TIMESTAMP:
790*cdf0e10cSrcweir 			nValue = DataType::TIMESTAMP;
791*cdf0e10cSrcweir 			break;
792*cdf0e10cSrcweir 		case SQL_BINARY:
793*cdf0e10cSrcweir 			nValue = DataType::BINARY;
794*cdf0e10cSrcweir 			break;
795*cdf0e10cSrcweir 		case SQL_VARBINARY:
796*cdf0e10cSrcweir 		case SQL_GUID:
797*cdf0e10cSrcweir 			nValue = DataType::VARBINARY;
798*cdf0e10cSrcweir 			break;
799*cdf0e10cSrcweir 		case SQL_LONGVARBINARY:
800*cdf0e10cSrcweir 			nValue = DataType::LONGVARBINARY;
801*cdf0e10cSrcweir 			break;
802*cdf0e10cSrcweir 		default:
803*cdf0e10cSrcweir 			OSL_ASSERT(!"Invalid type");
804*cdf0e10cSrcweir 	}
805*cdf0e10cSrcweir 	return nValue;
806*cdf0e10cSrcweir }
807*cdf0e10cSrcweir //--------------------------------------------------------------------
808*cdf0e10cSrcweir // jdbcTypeToOdbc
809*cdf0e10cSrcweir // Convert the JDBC SQL type to the correct ODBC type
810*cdf0e10cSrcweir //--------------------------------------------------------------------
811*cdf0e10cSrcweir sal_Int32 OTools::jdbcTypeToOdbc(sal_Int32 jdbcType)
812*cdf0e10cSrcweir {
813*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::jdbcTypeToOdbc" );
814*cdf0e10cSrcweir 	// For the most part, JDBC types match ODBC types.  We'll
815*cdf0e10cSrcweir 	// just convert the ones that we know are different
816*cdf0e10cSrcweir 
817*cdf0e10cSrcweir 	sal_Int32 odbcType = jdbcType;
818*cdf0e10cSrcweir 
819*cdf0e10cSrcweir 	switch (jdbcType)
820*cdf0e10cSrcweir 	{
821*cdf0e10cSrcweir 	case DataType::DATE:
822*cdf0e10cSrcweir 		odbcType = SQL_DATE;
823*cdf0e10cSrcweir 		break;
824*cdf0e10cSrcweir 	case DataType::TIME:
825*cdf0e10cSrcweir 		odbcType = SQL_TIME;
826*cdf0e10cSrcweir 		break;
827*cdf0e10cSrcweir 	case DataType::TIMESTAMP:
828*cdf0e10cSrcweir 		odbcType = SQL_TIMESTAMP;
829*cdf0e10cSrcweir 		break;
830*cdf0e10cSrcweir 	}
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir 	return odbcType;
833*cdf0e10cSrcweir }
834*cdf0e10cSrcweir //-----------------------------------------------------------------------------
835*cdf0e10cSrcweir void OTools::getBindTypes(sal_Bool _bUseWChar,
836*cdf0e10cSrcweir 						  sal_Bool _bUseOldTimeDate,
837*cdf0e10cSrcweir 						  SQLSMALLINT _nOdbcType,
838*cdf0e10cSrcweir 						  SQLSMALLINT& fCType,
839*cdf0e10cSrcweir 						  SQLSMALLINT& fSqlType
840*cdf0e10cSrcweir 						  )
841*cdf0e10cSrcweir {
842*cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::getBindTypes" );
843*cdf0e10cSrcweir 	switch(_nOdbcType)
844*cdf0e10cSrcweir 	{
845*cdf0e10cSrcweir 		case SQL_CHAR:				if(_bUseWChar)
846*cdf0e10cSrcweir 									{
847*cdf0e10cSrcweir 										fCType   = SQL_C_WCHAR;
848*cdf0e10cSrcweir 										fSqlType = SQL_WCHAR;
849*cdf0e10cSrcweir 									}
850*cdf0e10cSrcweir 									else
851*cdf0e10cSrcweir 									{
852*cdf0e10cSrcweir 										fCType   = SQL_C_CHAR;
853*cdf0e10cSrcweir 										fSqlType = SQL_CHAR;
854*cdf0e10cSrcweir 									}
855*cdf0e10cSrcweir 									break;
856*cdf0e10cSrcweir 		case SQL_VARCHAR:			if(_bUseWChar)
857*cdf0e10cSrcweir 									{
858*cdf0e10cSrcweir 										fCType   = SQL_C_WCHAR;
859*cdf0e10cSrcweir 										fSqlType = SQL_WVARCHAR;
860*cdf0e10cSrcweir 									}
861*cdf0e10cSrcweir 									else
862*cdf0e10cSrcweir 									{
863*cdf0e10cSrcweir 										fCType   = SQL_C_CHAR;
864*cdf0e10cSrcweir 										fSqlType = SQL_VARCHAR;
865*cdf0e10cSrcweir 									}
866*cdf0e10cSrcweir 									break;
867*cdf0e10cSrcweir 		case SQL_LONGVARCHAR:		if(_bUseWChar)
868*cdf0e10cSrcweir 									{
869*cdf0e10cSrcweir 										fCType   = SQL_C_WCHAR;
870*cdf0e10cSrcweir 										fSqlType = SQL_WLONGVARCHAR;
871*cdf0e10cSrcweir 									}
872*cdf0e10cSrcweir 									else
873*cdf0e10cSrcweir 									{
874*cdf0e10cSrcweir 										fCType	 = SQL_C_CHAR;
875*cdf0e10cSrcweir 										fSqlType = SQL_LONGVARCHAR;
876*cdf0e10cSrcweir 									}
877*cdf0e10cSrcweir 									break;
878*cdf0e10cSrcweir 		case SQL_DECIMAL:			fCType		= _bUseWChar ? SQL_C_WCHAR : SQL_C_CHAR;
879*cdf0e10cSrcweir 									fSqlType	= SQL_DECIMAL; break;
880*cdf0e10cSrcweir 		case SQL_NUMERIC:			fCType		= _bUseWChar ? SQL_C_WCHAR : SQL_C_CHAR;
881*cdf0e10cSrcweir 									fSqlType	= SQL_NUMERIC; break;
882*cdf0e10cSrcweir 		case SQL_BIT:				fCType		= SQL_C_TINYINT;
883*cdf0e10cSrcweir 									fSqlType	= SQL_INTEGER; break;
884*cdf0e10cSrcweir 		case SQL_TINYINT:			fCType		= SQL_C_TINYINT;
885*cdf0e10cSrcweir 									fSqlType	= SQL_TINYINT; break;
886*cdf0e10cSrcweir 		case SQL_SMALLINT:			fCType		= SQL_C_SHORT;
887*cdf0e10cSrcweir 									fSqlType	= SQL_SMALLINT; break;
888*cdf0e10cSrcweir 		case SQL_INTEGER:			fCType		= SQL_C_LONG;
889*cdf0e10cSrcweir 									fSqlType	= SQL_INTEGER; break;
890*cdf0e10cSrcweir 		case SQL_BIGINT:			fCType		= SQL_C_SBIGINT;
891*cdf0e10cSrcweir 									fSqlType	= SQL_BIGINT; break;
892*cdf0e10cSrcweir 		case SQL_FLOAT:				fCType		= SQL_C_FLOAT;
893*cdf0e10cSrcweir 									fSqlType	= SQL_FLOAT; break;
894*cdf0e10cSrcweir 		case SQL_REAL:				fCType		= SQL_C_DOUBLE;
895*cdf0e10cSrcweir 									fSqlType	= SQL_REAL; break;
896*cdf0e10cSrcweir 		case SQL_DOUBLE:			fCType		= SQL_C_DOUBLE;
897*cdf0e10cSrcweir 									fSqlType	= SQL_DOUBLE; break;
898*cdf0e10cSrcweir 		case SQL_BINARY:			fCType		= SQL_C_BINARY;
899*cdf0e10cSrcweir 									fSqlType	= SQL_BINARY; break;
900*cdf0e10cSrcweir 		case SQL_VARBINARY:
901*cdf0e10cSrcweir 									fCType		= SQL_C_BINARY;
902*cdf0e10cSrcweir 									fSqlType	= SQL_VARBINARY; break;
903*cdf0e10cSrcweir 		case SQL_LONGVARBINARY: 	fCType		= SQL_C_BINARY;
904*cdf0e10cSrcweir 									fSqlType	= SQL_LONGVARBINARY; break;
905*cdf0e10cSrcweir 		case SQL_DATE:
906*cdf0e10cSrcweir 									if(_bUseOldTimeDate)
907*cdf0e10cSrcweir 									{
908*cdf0e10cSrcweir 										fCType		= SQL_C_DATE;
909*cdf0e10cSrcweir 										fSqlType	= SQL_DATE;
910*cdf0e10cSrcweir 									}
911*cdf0e10cSrcweir 									else
912*cdf0e10cSrcweir 									{
913*cdf0e10cSrcweir 										fCType		= SQL_C_TYPE_DATE;
914*cdf0e10cSrcweir 										fSqlType	= SQL_TYPE_DATE;
915*cdf0e10cSrcweir 									}
916*cdf0e10cSrcweir 									break;
917*cdf0e10cSrcweir 		case SQL_TIME:
918*cdf0e10cSrcweir 									if(_bUseOldTimeDate)
919*cdf0e10cSrcweir 									{
920*cdf0e10cSrcweir 										fCType		= SQL_C_TIME;
921*cdf0e10cSrcweir 										fSqlType	= SQL_TIME;
922*cdf0e10cSrcweir 									}
923*cdf0e10cSrcweir 									else
924*cdf0e10cSrcweir 									{
925*cdf0e10cSrcweir 										fCType		= SQL_C_TYPE_TIME;
926*cdf0e10cSrcweir 										fSqlType	= SQL_TYPE_TIME;
927*cdf0e10cSrcweir 									}
928*cdf0e10cSrcweir 									break;
929*cdf0e10cSrcweir 		case SQL_TIMESTAMP:
930*cdf0e10cSrcweir 									if(_bUseOldTimeDate)
931*cdf0e10cSrcweir 									{
932*cdf0e10cSrcweir 										fCType		= SQL_C_TIMESTAMP;
933*cdf0e10cSrcweir 										fSqlType	= SQL_TIMESTAMP;
934*cdf0e10cSrcweir 									}
935*cdf0e10cSrcweir 									else
936*cdf0e10cSrcweir 									{
937*cdf0e10cSrcweir 										fCType		= SQL_C_TYPE_TIMESTAMP;
938*cdf0e10cSrcweir 										fSqlType	= SQL_TYPE_TIMESTAMP;
939*cdf0e10cSrcweir 									}
940*cdf0e10cSrcweir 									break;
941*cdf0e10cSrcweir 		default:						fCType		= SQL_C_BINARY;
942*cdf0e10cSrcweir 										fSqlType	= SQL_LONGVARBINARY; break;
943*cdf0e10cSrcweir 	}
944*cdf0e10cSrcweir }
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir 
947