diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2015-12-13 19:21:30 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2015-12-21 13:16:00 +0100 |
commit | e0efbbfa4c9789b19fea0c268c6c07b320c546a1 (patch) | |
tree | 4b311bb5e26e5ff4f0431255ae3e5bd641ded53c /connectivity | |
parent | 4117730cc8e3f99087346be15b9b5a3479139a73 (diff) |
tdf#96461 ODBC SQLBindParameter: correct DecimalDigits for time(date) values
Change-Id: I33c63d2c002d9abcbadb16bcd460996ef3212f4a
Reviewed-on: https://gerrit.libreoffice.org/20687
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit fabfd88b11bb6253e9631664d9adb47c119f9e7d)
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/odbc/OPreparedStatement.cxx | 12 | ||||
-rw-r--r-- | connectivity/source/inc/odbc/OPreparedStatement.hxx | 1 |
2 files changed, 10 insertions, 3 deletions
diff --git a/connectivity/source/drivers/odbc/OPreparedStatement.cxx b/connectivity/source/drivers/odbc/OPreparedStatement.cxx index f5ff4e37cb41..7beb3ea1bedc 100644 --- a/connectivity/source/drivers/odbc/OPreparedStatement.cxx +++ b/connectivity/source/drivers/odbc/OPreparedStatement.cxx @@ -291,6 +291,12 @@ void OPreparedStatement::setParameterPre(sal_Int32 parameterIndex) template <typename T> void OPreparedStatement::setScalarParameter(const sal_Int32 parameterIndex, const sal_Int32 i_nType, const SQLULEN i_nColSize, const T i_Value) { + setScalarParameter(parameterIndex, i_nType, i_nColSize, invalid_scale, i_Value); +} + + +template <typename T> void OPreparedStatement::setScalarParameter(const sal_Int32 parameterIndex, const sal_Int32 i_nType, const SQLULEN i_nColSize, sal_Int32 i_nScale, const T i_Value) +{ ::osl::MutexGuard aGuard( m_aMutex ); setParameterPre(parameterIndex); @@ -299,7 +305,7 @@ template <typename T> void OPreparedStatement::setScalarParameter(const sal_Int3 TnoRef *bindBuf = static_cast< TnoRef* >( allocBindBuf(parameterIndex, sizeof(i_Value)) ); *bindBuf = i_Value; - setParameter(parameterIndex, i_nType, i_nColSize, invalid_scale, bindBuf, sizeof(i_Value), sizeof(i_Value)); + setParameter(parameterIndex, i_nType, i_nColSize, i_nScale, bindBuf, sizeof(i_Value), sizeof(i_Value)); } @@ -443,7 +449,7 @@ void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const css:: else nColSize = 18; TIME_STRUCT x(OTools::TimeToOdbcTime(aVal)); - setScalarParameter<TIME_STRUCT&>(parameterIndex, DataType::TIME, nColSize, x); + setScalarParameter<TIME_STRUCT&>(parameterIndex, DataType::TIME, nColSize, (nColSize == 8)? 0 : nColSize-9, x); } @@ -477,7 +483,7 @@ void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const nColSize = 29; TIMESTAMP_STRUCT x(OTools::DateTimeToTimestamp(aVal)); - setScalarParameter<TIMESTAMP_STRUCT&>(parameterIndex, DataType::TIMESTAMP, nColSize, x); + setScalarParameter<TIMESTAMP_STRUCT&>(parameterIndex, DataType::TIMESTAMP, nColSize, (nColSize <= 19)? 0 : nColSize-20, x); } diff --git a/connectivity/source/inc/odbc/OPreparedStatement.hxx b/connectivity/source/inc/odbc/OPreparedStatement.hxx index 59968836c6d3..d8f95525546c 100644 --- a/connectivity/source/inc/odbc/OPreparedStatement.hxx +++ b/connectivity/source/inc/odbc/OPreparedStatement.hxx @@ -81,6 +81,7 @@ namespace connectivity void initBoundParam () throw(::com::sun::star::sdbc::SQLException); void setParameterPre(sal_Int32 parameterIndex); template <typename T> void setScalarParameter(sal_Int32 parameterIndex, sal_Int32 _nType, SQLULEN _nColumnSize, const T i_Value); + template <typename T> void setScalarParameter(sal_Int32 parameterIndex, sal_Int32 _nType, SQLULEN _nColumnSize, sal_Int32 _nScale, const T i_Value); void setParameter(sal_Int32 parameterIndex, sal_Int32 _nType, SQLULEN _nColumnSize, sal_Int32 _nScale, const void* _pData, SQLULEN _nDataLen, SQLLEN _nDataAllocLen); void setParameter(sal_Int32 parameterIndex, sal_Int32 _nType, sal_Int32 _nColumnSize, sal_Int32 _nByteSize, void* _pData); // Wrappers for special cases |