From 84fe40e3699adea7b7ef6476d324d63aada9c5ad Mon Sep 17 00:00:00 2001 From: "Andrzej J.R. Hunt" Date: Thu, 29 Aug 2013 10:49:01 +0100 Subject: Implement set[Date|Time]. (firebird-sdbc) Change-Id: Ia519b2ec9c6be94f6f21bbd2951a295da8079479 --- .../source/drivers/firebird/PreparedStatement.cxx | 34 +++++++++++++--------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'connectivity') diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index c38e8d3f8e2d..0069d7129a12 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.cxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx @@ -390,26 +390,32 @@ void SAL_CALL OPreparedStatement::setDouble(sal_Int32 nIndex, double nValue) setValue< double >(nIndex, nValue, SQL_DOUBLE); // TODO: SQL_D_FLOAT? } -// ------------------------------------------------------------------------- - -void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date& aData ) throw(SQLException, RuntimeException) +void SAL_CALL OPreparedStatement::setDate(sal_Int32 nIndex, const Date& rDate) + throw(SQLException, RuntimeException) { - (void) parameterIndex; - (void) aData; - ::osl::MutexGuard aGuard( m_pConnection->getMutex() ); - checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); + struct tm aCTime; + aCTime.tm_mday = rDate.Day; + aCTime.tm_mon = rDate.Month; + aCTime.tm_year = rDate.Year; -} -// ------------------------------------------------------------------------- + ISC_DATE aISCDate; + isc_encode_sql_date(&aCTime, &aISCDate); + setValue< ISC_DATE >(nIndex, aISCDate, SQL_TYPE_DATE); +} -void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time& aVal ) throw(SQLException, RuntimeException) +void SAL_CALL OPreparedStatement::setTime( sal_Int32 nIndex, const Time& rTime) + throw(SQLException, RuntimeException) { - (void) parameterIndex; - (void) aVal; - ::osl::MutexGuard aGuard( m_pConnection->getMutex() ); - checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); + struct tm aCTime; + aCTime.tm_sec = rTime.Seconds; + aCTime.tm_min = rTime.Minutes; + aCTime.tm_hour = rTime.Hours; + + ISC_TIME aISCTime; + isc_encode_sql_time(&aCTime, &aISCTime); + setValue< ISC_TIME >(nIndex, aISCTime, SQL_TYPE_TIME); } void SAL_CALL OPreparedStatement::setTimestamp(sal_Int32 nIndex, const DateTime& rTimestamp) -- cgit