Kaydet (Commit) e95e07ef authored tarafından Lionel Elie Mamane's avatar Lionel Elie Mamane

tdf#96461 ODBC SQLBindParameter: correct DecimalDigits for time(date) values

Change-Id: I33c63d2c002d9abcbadb16bcd460996ef3212f4a
Reviewed-on: https://gerrit.libreoffice.org/20686Reviewed-by: 's avatarLionel Elie Mamane <lionel@mamane.lu>
Tested-by: 's avatarLionel Elie Mamane <lionel@mamane.lu>
üst 455e35df
...@@ -289,6 +289,12 @@ void OPreparedStatement::setParameterPre(sal_Int32 parameterIndex) ...@@ -289,6 +289,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) 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 ); ::osl::MutexGuard aGuard( m_aMutex );
setParameterPre(parameterIndex); setParameterPre(parameterIndex);
...@@ -298,7 +304,7 @@ template <typename T> void OPreparedStatement::setScalarParameter(const sal_Int3 ...@@ -298,7 +304,7 @@ template <typename T> void OPreparedStatement::setScalarParameter(const sal_Int3
TnoRef *bindBuf = static_cast< TnoRef* >( allocBindBuf(parameterIndex, sizeof(i_Value)) ); TnoRef *bindBuf = static_cast< TnoRef* >( allocBindBuf(parameterIndex, sizeof(i_Value)) );
*bindBuf = 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));
} }
...@@ -442,7 +448,7 @@ void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const css:: ...@@ -442,7 +448,7 @@ void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const css::
else else
nColSize = 18; nColSize = 18;
TIME_STRUCT x(OTools::TimeToOdbcTime(aVal)); 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);
} }
...@@ -476,7 +482,7 @@ void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const ...@@ -476,7 +482,7 @@ void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const
nColSize = 29; nColSize = 29;
TIMESTAMP_STRUCT x(OTools::DateTimeToTimestamp(aVal)); 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);
} }
......
...@@ -81,6 +81,7 @@ namespace connectivity ...@@ -81,6 +81,7 @@ namespace connectivity
void initBoundParam () throw(::com::sun::star::sdbc::SQLException); void initBoundParam () throw(::com::sun::star::sdbc::SQLException);
void setParameterPre(sal_Int32 parameterIndex); 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, 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, SQLULEN _nColumnSize, sal_Int32 _nScale, const void* _pData, SQLULEN _nDataLen, SQLLEN _nDataAllocLen);
// Wrappers for special cases // Wrappers for special cases
void setParameter(sal_Int32 parameterIndex, sal_Int32 _nType, sal_Int16 _nScale, const OUString &_sData); void setParameter(sal_Int32 parameterIndex, sal_Int32 _nType, sal_Int16 _nScale, const OUString &_sData);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment