summaryrefslogtreecommitdiffstats
path: root/connectivity
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2012-02-14 18:34:52 +0100
committerLionel Elie Mamane <lionel@mamane.lu>2012-02-14 19:55:22 +0100
commitc1ef5ba65c1b3d9c9bb8c45f68e494493e628837 (patch)
treee804398b530dfd15cad8eaf4273f5719840ea218 /connectivity
parentadded [fr-CH] date acceptance patterns "D/M" and "D.M." (diff)
downloadcore-c1ef5ba65c1b3d9c9bb8c45f68e494493e628837.tar.gz
core-c1ef5ba65c1b3d9c9bb8c45f68e494493e628837.zip
improve OTools::binParameter/bindData interaction
Don't duplicate the decision point for "data at execution or copied data"
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/odbcbase/OTools.cxx11
-rw-r--r--connectivity/source/inc/odbc/OTools.hxx20
2 files changed, 20 insertions, 11 deletions
diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx
index 9e8714cb0ca8..df7407659da5 100644
--- a/connectivity/source/drivers/odbcbase/OTools.cxx
+++ b/connectivity/source/drivers/odbcbase/OTools.cxx
@@ -181,14 +181,15 @@ void OTools::bindParameter( OConnection* _pConnection,
SQLLEN* pLen = (SQLLEN*)pLenBuffer;
SQLULEN nColumnSize=0;
SQLSMALLINT nDecimalDigits=0;
+ bool atExec;
OTools::getBindTypes(_bUseWChar,_bUseOldTimeDate,_nODBCtype,fCType,fSqlType);
- OTools::bindData(_nODBCtype,_bUseWChar,pDataBuffer,pLen,_pValue,_nTextEncoding,nColumnSize);
+ OTools::bindData(_nODBCtype,_bUseWChar,pDataBuffer,pLen,_pValue,_nTextEncoding,nColumnSize, atExec);
if ((nColumnSize == 0) && (fSqlType == SQL_CHAR || fSqlType == SQL_VARCHAR || fSqlType == SQL_LONGVARCHAR))
nColumnSize = 1;
- if(fSqlType == SQL_LONGVARCHAR || fSqlType == SQL_LONGVARBINARY)
+ if (atExec)
memcpy(pDataBuffer,&nPos,sizeof(nPos));
nRetcode = (*(T3SQLBindParameter)_pConnection->getOdbcFunction(ODBC3SQLBindParameter))(_hStmt,
@@ -211,10 +212,12 @@ void OTools::bindData( SQLSMALLINT _nOdbcType,
SQLLEN*& pLen,
const void* _pValue,
rtl_TextEncoding _nTextEncoding,
- SQLULEN& _nColumnSize)
+ SQLULEN& _nColumnSize,
+ bool &atExec)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::bindData" );
_nColumnSize = 0;
+ atExec = false;
switch (_nOdbcType)
{
@@ -307,6 +310,7 @@ void OTools::bindData( SQLSMALLINT _nOdbcType,
nLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength();
*pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen);
}
+ atExec = true;
break;
case SQL_LONGVARCHAR:
{
@@ -319,6 +323,7 @@ void OTools::bindData( SQLSMALLINT _nOdbcType,
nLen = aString.getLength();
}
*pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen);
+ atExec = true;
} break;
case SQL_DATE:
*(DATE_STRUCT*)_pData = *(DATE_STRUCT*)_pValue;
diff --git a/connectivity/source/inc/odbc/OTools.hxx b/connectivity/source/inc/odbc/OTools.hxx
index 7f48373e22f4..ad1fb12931bd 100644
--- a/connectivity/source/inc/odbc/OTools.hxx
+++ b/connectivity/source/inc/odbc/OTools.hxx
@@ -216,13 +216,16 @@ namespace connectivity
SQLLEN _nSize) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
/**
- bindData copies the from pValue to pData
- @param _nOdbcType the ODBC sql type
- @param _bUseWChar true when Unicode should be used
- @param _pData contains a copy of the data to be set
- @param _pValue contains the data to be copied
- @param _nTextEncoding the text encoding
- @param _nColumnSize the columnsize which is a out param
+ bindData copies data from pValue to pData
+ @param _nOdbcType [in] the ODBC sql type
+ @param _bUseWChar [in] true when Unicode should be used
+ @param _pData [in/out] data copy destination
+ @param pLen [out] buffer length of data written to _pData
+ @param _pValue [in] contains the data to be copied
+ @param _nTextEncoding [in] the text encoding
+ @param _nColumnSize [out] columnSize of data written to _pData
+ @param atExec [out] data was not copied, but setup for data-at-execution;
+ caller is responsible for writing a token in _pData
*/
static void bindData( SQLSMALLINT _nOdbcType,
sal_Bool _bUseWChar,
@@ -230,7 +233,8 @@ namespace connectivity
SQLLEN*& pLen,
const void* _pValue,
rtl_TextEncoding _nTextEncoding,
- SQLULEN& _nColumnSize);
+ SQLULEN& _nColumnSize,
+ bool &atExec);
static void bindParameter( OConnection* _pConnection,
SQLHANDLE _hStmt,