diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-07-05 10:05:34 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-07-05 10:05:34 +0000 |
commit | cebffff0d887e7d54f2efaa4cf9a46f807529cee (patch) | |
tree | 7ed22e17fc7a54a2410ea714895b844a4ab8ca79 /connectivity | |
parent | 0cdfb99fc2120bd133cb592b8fbbfb55a26b041d (diff) |
#89259# check for special types
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/adabas/BTables.cxx | 35 | ||||
-rw-r--r-- | connectivity/source/drivers/odbc/OPreparedStatement.cxx | 34 | ||||
-rw-r--r-- | connectivity/source/drivers/odbc/OResultSet.cxx | 11 | ||||
-rw-r--r-- | connectivity/source/drivers/odbc/OTools.cxx | 35 | ||||
-rw-r--r-- | connectivity/source/inc/odbc/OBoundParam.hxx | 11 | ||||
-rw-r--r-- | connectivity/source/inc/odbc/OTools.hxx | 8 |
6 files changed, 95 insertions, 39 deletions
diff --git a/connectivity/source/drivers/adabas/BTables.cxx b/connectivity/source/drivers/adabas/BTables.cxx index 7dee06e5094f..96dc0faf0c6d 100644 --- a/connectivity/source/drivers/adabas/BTables.cxx +++ b/connectivity/source/drivers/adabas/BTables.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BTables.cxx,v $ * - * $Revision: 1.18 $ + * $Revision: 1.19 $ * - * last change: $Author: oj $ $Date: 2001-07-03 13:01:47 $ + * last change: $Author: oj $ $Date: 2001-07-05 11:03:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -327,15 +327,30 @@ void OTables::createTable( const Reference< XPropertySet >& descriptor ) aTypeName = xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)); - if(aTypeName.hasValue() && getString(aTypeName).getLength()) - aSql += getString(aTypeName); - else - aSql += getTypeString(xColProp) + ::rtl::OUString::createFromAscii(" "); + sal_Int32 nDataType = 0; + xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nDataType; - switch(getINT32(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))) + switch(nDataType) + { + case DataType::VARBINARY: + aSql += ::rtl::OUString::createFromAscii("VAR"); + /* run through*/ + case DataType::BINARY: + aSql += ::rtl::OUString::createFromAscii("CHAR"); + break; + default: + if(aTypeName.hasValue() && getString(aTypeName).getLength()) + aSql += getString(aTypeName); + else + aSql += getTypeString(xColProp) + ::rtl::OUString::createFromAscii(" "); + } + + switch(nDataType) { case DataType::CHAR: case DataType::VARCHAR: + case DataType::FLOAT: + case DataType::REAL: aSql += ::rtl::OUString::createFromAscii("(") + ::rtl::OUString::valueOf(getINT32(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))) + ::rtl::OUString::createFromAscii(")"); @@ -349,6 +364,12 @@ void OTables::createTable( const Reference< XPropertySet >& descriptor ) + ::rtl::OUString::valueOf(getINT32(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))) + ::rtl::OUString::createFromAscii(")"); break; + case DataType::BINARY: + case DataType::VARBINARY: + aSql += ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))) + + ::rtl::OUString::createFromAscii(") BYTE"); + break; } ::rtl::OUString aDefault = getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE))); if(getINT32(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))) == ColumnValue::NO_NULLS) diff --git a/connectivity/source/drivers/odbc/OPreparedStatement.cxx b/connectivity/source/drivers/odbc/OPreparedStatement.cxx index fe07c0f82f5c..ec0d0edaaf03 100644 --- a/connectivity/source/drivers/odbc/OPreparedStatement.cxx +++ b/connectivity/source/drivers/odbc/OPreparedStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: OPreparedStatement.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: oj $ $Date: 2001-06-26 11:30:44 $ + * last change: $Author: oj $ $Date: 2001-07-05 11:04:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -392,7 +392,7 @@ void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x checkParameterIndex(parameterIndex); OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); - sal_Int8* bindBuf = allocBindBuf(parameterIndex, 4); + sal_Int8* bindBuf = allocBindBuf(parameterIndex, sizeof(sal_Int8)); PREP_BIND_PARAM(sal_Int8,SQL_TINYINT); } // ------------------------------------------------------------------------- @@ -410,7 +410,7 @@ void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date& checkParameterIndex(parameterIndex); - sal_Int8* bindBuf = allocBindBuf (parameterIndex, 32); + sal_Int8* bindBuf = allocBindBuf (parameterIndex, sizeof(DATE_STRUCT)); OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); DATE_STRUCT x = OTools::DateToOdbcDate(aData); @@ -431,7 +431,7 @@ void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time& // the bound data in native format. checkParameterIndex(parameterIndex); - sal_Int8* bindBuf = allocBindBuf (parameterIndex, 32); + sal_Int8* bindBuf = allocBindBuf (parameterIndex, sizeof(TIME_STRUCT)); OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); TIME_STRUCT x = OTools::TimeToOdbcTime(aVal); @@ -451,7 +451,7 @@ void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const // the bound data in native format. checkParameterIndex(parameterIndex); - sal_Int8* bindBuf = allocBindBuf (parameterIndex, 32); + sal_Int8* bindBuf = allocBindBuf (parameterIndex, sizeof(TIMESTAMP_STRUCT)); OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); TIMESTAMP_STRUCT x = OTools::DateTimeToTimestamp(aVal); @@ -472,7 +472,7 @@ void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x checkParameterIndex(parameterIndex); OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); - sal_Int8* bindBuf = allocBindBuf (parameterIndex, 8); + sal_Int8* bindBuf = allocBindBuf (parameterIndex, sizeof(double)); PREP_BIND_PARAM(double,DataType::DOUBLE); } @@ -491,7 +491,7 @@ void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) checkParameterIndex(parameterIndex); OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); - sal_Int8* bindBuf = allocBindBuf (parameterIndex, 8); + sal_Int8* bindBuf = allocBindBuf (parameterIndex, sizeof(float)); PREP_BIND_PARAM(float,DataType::FLOAT); } // ------------------------------------------------------------------------- @@ -509,7 +509,7 @@ void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x checkParameterIndex(parameterIndex); OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); - sal_Int8* bindBuf = allocBindBuf (parameterIndex, 4); + sal_Int8* bindBuf = allocBindBuf (parameterIndex, sizeof(sal_Int32)); PREP_BIND_PARAM(sal_Int32,DataType::INTEGER); } // ------------------------------------------------------------------------- @@ -528,7 +528,7 @@ void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 a checkParameterIndex(parameterIndex); OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); - sal_Int8 *bindBuf = allocBindBuf (parameterIndex, 8); + sal_Int8 *bindBuf = allocBindBuf (parameterIndex, sizeof(float)); float x = (float)aVal; PREP_BIND_PARAM(float,DataType::BIGINT); } @@ -1104,6 +1104,20 @@ void OPreparedStatement::setBinary (sal_Int32 parameterIndex,sal_Int32 SQLtype, // the bound data in native format. checkParameterIndex(parameterIndex); + +// SQLRETURN nRetcode; +// SWORD fSqlType; +// SWORD fCType; +// SDWORD nMaxLen = 0; +// SQLUINTEGER nColumnSize=0; +// SQLSMALLINT nDecimalDigits=0; +// SQLSMALLINT nNullable=0; +// nRetcode = (*(T3SQLDescribeParam)m_pConnection->getOdbcFunction(ODBC3SQLDescribeParam))(m_aStatementHandle, +// (SQLUSMALLINT)parameterIndex,&fSqlType,&nColumnSize,&nDecimalDigits,&nNullable); +// +// OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); + +// sal_Int8* bindBuf = allocBindBuf (parameterIndex,(nColumnSize > x.getLength()) ? nColumnSize : x.getLength()); sal_Int8* bindBuf = allocBindBuf (parameterIndex,x.getLength()); // Get the buffer needed for the length diff --git a/connectivity/source/drivers/odbc/OResultSet.cxx b/connectivity/source/drivers/odbc/OResultSet.cxx index 8bccec8bc6fc..db143d297f5d 100644 --- a/connectivity/source/drivers/odbc/OResultSet.cxx +++ b/connectivity/source/drivers/odbc/OResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: OResultSet.cxx,v $ * - * $Revision: 1.29 $ + * $Revision: 1.30 $ * - * last change: $Author: fs $ $Date: 2001-06-25 13:50:14 $ + * last change: $Author: oj $ $Date: 2001-07-05 11:04:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1665,10 +1665,12 @@ void OResultSet::fillRow(sal_Int32 _nToColumn) ::std::vector< ORowSetValue >::iterator pColumn = m_aRow.begin() + nColumn; ::std::vector< ORowSetValue >::iterator pColumnEnd = m_aRow.begin() + _nToColumn + 1; + sal_Int32 nDataType; for (; pColumn < pColumnEnd; ++nColumn, ++pColumn) { - pColumn->setTypeKind(xMeta->getColumnType(nColumn)); - switch (pColumn->getTypeKind()) + nDataType = xMeta->getColumnType(nColumn); + + switch (nDataType) { case DataType::CHAR: case DataType::VARCHAR: @@ -1718,6 +1720,7 @@ void OResultSet::fillRow(sal_Int32 _nToColumn) *pColumn = getBytes(nColumn); break; } + pColumn->setTypeKind(nDataType); } m_nLastColumnPos = _nToColumn; m_bFetchData = sal_True; diff --git a/connectivity/source/drivers/odbc/OTools.cxx b/connectivity/source/drivers/odbc/OTools.cxx index ae982a0fdaaa..dd17f31c49ed 100644 --- a/connectivity/source/drivers/odbc/OTools.cxx +++ b/connectivity/source/drivers/odbc/OTools.cxx @@ -2,9 +2,9 @@ * * $RCSfile: OTools.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: oj $ $Date: 2001-05-21 14:30:18 $ + * last change: $Author: oj $ $Date: 2001-07-05 11:04:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -109,7 +109,7 @@ void OTools::getValue( OConnection* _pConnection, void OTools::bindParameter( OConnection* _pConnection, SQLHANDLE _hStmt, sal_Int32 nPos, - sal_Int8* pDataBuffer, + sal_Int8*& pDataBuffer, sal_Int8* pLenBuffer, SQLSMALLINT _nJDBCtype, sal_Bool _bUseWChar, @@ -123,7 +123,7 @@ void OTools::bindParameter( OConnection* _pConnection, SWORD fSqlType; SWORD fCType; SDWORD nMaxLen = 0; - void* pData = pDataBuffer; + // void*& pData = pDataBuffer; SDWORD* pLen = (SDWORD*)pLenBuffer; SQLUINTEGER nColumnSize=0; SQLSMALLINT nDecimalDigits=0; @@ -131,9 +131,9 @@ void OTools::bindParameter( OConnection* _pConnection, OTools::getBindTypes(_bUseWChar,_bUseOldTimeDate,_nJDBCtype,fSqlType,fCType,nColumnSize,nDecimalDigits); - OTools::bindData(fSqlType,_bUseWChar,pData,pLen,_pValue,_nTextEncoding); + OTools::bindData(fSqlType,_bUseWChar,pDataBuffer,pLen,_pValue,_nTextEncoding); if(fSqlType == SQL_LONGVARCHAR || fSqlType == SQL_LONGVARBINARY) - memcpy(pData,&nPos,sizeof(nPos)); + memcpy(pDataBuffer,&nPos,sizeof(nPos)); nRetcode = (*(T3SQLDescribeParam)_pConnection->getOdbcFunction(ODBC3SQLDescribeParam))(_hStmt,(SQLUSMALLINT)nPos,&fSqlType,&nColumnSize,&nDecimalDigits,&nNullable); @@ -144,7 +144,7 @@ void OTools::bindParameter( OConnection* _pConnection, fSqlType, nColumnSize, nDecimalDigits, - pData, + pDataBuffer, nMaxLen, pLen); @@ -153,7 +153,7 @@ void OTools::bindParameter( OConnection* _pConnection, // ----------------------------------------------------------------------------- void OTools::bindData( SWORD fSqlType, sal_Bool _bUseWChar, - void *&_pData, + sal_Int8 *&_pData, SDWORD*& pLen, const void* _pValue, rtl_TextEncoding _nTextEncoding) @@ -170,7 +170,7 @@ void OTools::bindData( SWORD fSqlType, *((rtl::OUString*)_pData) = *(::rtl::OUString*)_pValue; // Zeiger auf Char* - _pData = (void*)((rtl::OUString*)_pData)->getStr(); + _pData = (sal_Int8*)((rtl::OUString*)_pData)->getStr(); } else { @@ -190,7 +190,7 @@ void OTools::bindData( SWORD fSqlType, *pLen = nMaxLen; *((rtl::OUString*)_pData) = aString; // Zeiger auf Char* - _pData = (void*)((rtl::OUString*)_pData)->getStr(); + _pData = (sal_Int8*)((rtl::OUString*)_pData)->getStr(); } else { @@ -223,8 +223,19 @@ void OTools::bindData( SWORD fSqlType, break; case SQL_BINARY: case SQL_VARBINARY: - _pData = (void*)((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getConstArray(); - *pLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength(); + { + const ::com::sun::star::uno::Sequence< sal_Int8 >* pSeq = static_cast< const ::com::sun::star::uno::Sequence< sal_Int8 >* >(_pValue); + OSL_ENSURE(pSeq,"OTools::bindData: Sequence is null!"); + + if(pSeq) + { + // memcpy(_pData,pSeq->getConstArray(),pSeq->getLength()); + _pData = (sal_Int8*)((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getConstArray(); + *pLen = pSeq->getLength(); + } + // _pData = (sal_Int8*)((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getConstArray(); + // *pLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength(); + } break; case SQL_LONGVARBINARY: { diff --git a/connectivity/source/inc/odbc/OBoundParam.hxx b/connectivity/source/inc/odbc/OBoundParam.hxx index d7badbf6f207..2ca03350d79f 100644 --- a/connectivity/source/inc/odbc/OBoundParam.hxx +++ b/connectivity/source/inc/odbc/OBoundParam.hxx @@ -2,9 +2,9 @@ * * $RCSfile: OBoundParam.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 16:14:27 $ + * last change: $Author: oj $ $Date: 2001-07-05 11:05:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,6 +75,8 @@ namespace connectivity public: OBoundParam() { + paramLength = NULL; + binaryData = NULL; pA1=0; pA2=0; pB1=0; @@ -84,6 +86,11 @@ namespace connectivity pS1=0; pS2=0; } + ~OBoundParam() + { + delete [] binaryData; + delete [] paramLength; + } //-------------------------------------------------------------------- // initialize // Perform an necessary initialization diff --git a/connectivity/source/inc/odbc/OTools.hxx b/connectivity/source/inc/odbc/OTools.hxx index 671c513d0fa7..510a18f478a8 100644 --- a/connectivity/source/inc/odbc/OTools.hxx +++ b/connectivity/source/inc/odbc/OTools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: OTools.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-05-21 14:30:34 $ + * last change: $Author: oj $ $Date: 2001-07-05 11:05:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -245,7 +245,7 @@ namespace connectivity static void bindData( SWORD fSqlType, sal_Bool _bUseWChar, - void *&_pData, + sal_Int8 *&_pData, SDWORD*& pLen, const void* _pValue, rtl_TextEncoding _nTextEncoding); @@ -253,7 +253,7 @@ namespace connectivity static void bindParameter( OConnection* _pConnection, SQLHANDLE _hStmt, sal_Int32 nPos, - sal_Int8* pDataBuffer, + sal_Int8*& pDataBuffer, sal_Int8* pLenBuffer, SQLSMALLINT _nJDBCtype, sal_Bool _bUseWChar, |