summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorOcke Janssen <Ocke.Janssen@sun.com>2009-11-11 12:32:55 +0100
committerOcke Janssen <Ocke.Janssen@sun.com>2009-11-11 12:32:55 +0100
commit540920f1b130375207a5362105fb3afbcf3bac3b (patch)
tree88a87aa206c41953e5b32b8f3b47024561e4afc2 /connectivity
parent3ee76c2144ab24a04b172a4695c3a7e5abfda105 (diff)
#i102791# fix decimal for odbc
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/odbcbase/OPreparedStatement.cxx37
-rw-r--r--connectivity/source/drivers/odbcbase/OTools.cxx3
-rw-r--r--connectivity/source/inc/odbc/OPreparedStatement.hxx3
3 files changed, 29 insertions, 14 deletions
diff --git a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
index 6e9d87e933ca..03d9912e4e22 100644
--- a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
+++ b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
@@ -343,9 +343,9 @@ void OPreparedStatement::setParameter(sal_Int32 parameterIndex,sal_Int32 _nType,
case SQL_NUMERIC:
++nRealSize;
break;
- case SQL_BINARY:
- case SQL_VARBINARY:
- nRealSize=1; //dummy buffer, binary data isn't copied
+ case SQL_BINARY:
+ case SQL_VARBINARY:
+ nRealSize=1; //dummy buffer, binary data isn't copied
break;
default:
break;
@@ -474,15 +474,17 @@ void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 s
}
// -------------------------------------------------------------------------
-void SAL_CALL OPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException)
+void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x ) throw(SQLException, RuntimeException)
{
- ::dbtools::throwFunctionNotSupportedException( "XParameters::setClob", *this );
+ if ( x.is() )
+ setStream(parameterIndex, x->getCharacterStream(), (SQLLEN)x->length(), DataType::LONGVARCHAR);
}
// -------------------------------------------------------------------------
-void SAL_CALL OPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException)
+void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x ) throw(SQLException, RuntimeException)
{
- ::dbtools::throwFunctionNotSupportedException( "XParameters::setBlob", *this );
+ if ( x.is() )
+ setStream(parameterIndex, x->getBinaryStream(), (SQLLEN)x->length(), DataType::LONGVARCHAR);
}
// -------------------------------------------------------------------------
@@ -497,7 +499,12 @@ void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Re
::dbtools::throwFunctionNotSupportedException( "XParameters::setRef", *this );
}
// -------------------------------------------------------------------------
-
+void OPreparedStatement::setDecimal( sal_Int32 parameterIndex, const ::rtl::OUString& x )
+{
+ ::rtl::OString aString(::rtl::OUStringToOString(x,getOwnConnection()->getTextEncoding()));
+ setParameter(parameterIndex,DataType::DECIMAL,aString.getLength(),(void*)&x);
+}
+// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
{
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
@@ -522,6 +529,12 @@ void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, c
setNull(parameterIndex,sqlType);
break;
case DataType::DECIMAL:
+ {
+ ORowSetValue aValue;
+ aValue.fill(x);
+ setDecimal(parameterIndex,aValue);
+ }
+ break;
case DataType::NUMERIC:
{
ORowSetValue aValue;
@@ -569,13 +582,13 @@ void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequ
void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
{
- setStream (parameterIndex, x, length, DataType::LONGVARCHAR);
+ setStream(parameterIndex, x, length, DataType::LONGVARCHAR);
}
// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
{
- setStream (parameterIndex, x, length, DataType::LONGVARBINARY);
+ setStream(parameterIndex, x, length, DataType::LONGVARBINARY);
}
// -------------------------------------------------------------------------
@@ -834,10 +847,10 @@ sal_Int32 OPreparedStatement::getPrecision ( sal_Int32 sqlType)
// Sets an input stream as a parameter, using the given SQL type
//--------------------------------------------------------------------
-void OPreparedStatement::setStream (
+void OPreparedStatement::setStream(
sal_Int32 ParameterIndex,
const Reference< XInputStream>& x,
- sal_Int32 length,
+ SQLLEN length,
sal_Int32 SQLtype)
throw(SQLException)
{
diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx
index 3cadb33cf188..daa6d28a0acf 100644
--- a/connectivity/source/drivers/odbcbase/OTools.cxx
+++ b/connectivity/source/drivers/odbcbase/OTools.cxx
@@ -135,6 +135,7 @@ void OTools::bindData( SQLSMALLINT _nOdbcType,
{
case SQL_CHAR:
case SQL_VARCHAR:
+ case SQL_DECIMAL:
if(_bUseWChar)
{
*pLen = SQL_NTS;
@@ -160,7 +161,7 @@ void OTools::bindData( SQLSMALLINT _nOdbcType,
*pLen = sizeof(sal_Int64);
_nColumnSize = *pLen;
break;
- case SQL_DECIMAL:
+
case SQL_NUMERIC:
if(_bUseWChar)
{
diff --git a/connectivity/source/inc/odbc/OPreparedStatement.hxx b/connectivity/source/inc/odbc/OPreparedStatement.hxx
index 9e6f6ca8a61f..d167c9edb9a0 100644
--- a/connectivity/source/inc/odbc/OPreparedStatement.hxx
+++ b/connectivity/source/inc/odbc/OPreparedStatement.hxx
@@ -89,7 +89,7 @@ namespace connectivity
void FreeParams();
void putParamData (sal_Int32 index) throw(::com::sun::star::sdbc::SQLException);
void setStream (sal_Int32 ParameterIndex,const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x,
- sal_Int32 length,sal_Int32 SQLtype) throw(::com::sun::star::sdbc::SQLException);
+ SQLLEN length,sal_Int32 SQLtype) throw(::com::sun::star::sdbc::SQLException);
sal_Int32 getParamLength ( sal_Int32 index);
sal_Int8* getLengthBuf (sal_Int32 index);
sal_Int8* getDataBuf (sal_Int32 index);
@@ -102,6 +102,7 @@ namespace connectivity
sal_Bool isPrepared() const { return m_bPrepared;}
void prepareStatement();
void checkParameterIndex(sal_Int32 _parameterIndex);
+ void setDecimal( sal_Int32 parameterIndex, const ::rtl::OUString& x );
/**
creates the driver specific resultset (factory)