MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:pharvey Date:June 14 2006 12:41pm
Subject:Connector/ODBC 5 commit: r331 - trunk/MYSQLPlus/MYSQLPlusLib
View as plain text  
Modified:
   trunk/MYSQLPlus/MYSQLPlusLib/MResult.cpp
Log:
- more work to support SQLBindParameter

Modified: trunk/MYSQLPlus/MYSQLPlusLib/MResult.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MResult.cpp	2006-06-13 23:35:17 UTC (rev 330)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MResult.cpp	2006-06-14 12:41:43 UTC (rev 331)
@@ -2770,6 +2770,10 @@
 {
     MYODBCDbgEnter();
 
+    SQL_INTERVAL_STRUCT *   pInterval   =
(SQL_INTERVAL_STRUCT*)pResultPutData->pDescriptorRecordAPD->getDataPtr();
+    SQL_YEAR_MONTH_STRUCT * pYearMonth  =
&((SQL_YEAR_MONTH_STRUCT*)pInterval->intval.year_month);
+    char                    szFormatBuffer[128];
+
     switch ( pResultPutData->pDescriptorRecordIPD->getConciseType() )
     {
         case SQL_CHAR:
@@ -2778,15 +2782,38 @@
         case SQL_WCHAR:
         case SQL_WVARCHAR:
         case SQL_WLONGVARCHAR:
+            /*!
+                \internal MYODBC RULE
+
+                We convert to string formatted as; "YYYY:MM".
+            */
+            sprintf( szFormatBuffer, "'%04d:%02d'", 
+                     pYearMonth->year,
+                     pYearMonth->month );
+            pResultPutData->variantData.setValue( QString::fromAscii( szFormatBuffer )
); ;
+            MYODBCDbgReturn( SQL_SUCCESS );
         case SQL_DECIMAL:
         case SQL_NUMERIC:
         case SQL_TINYINT:
         case SQL_SMALLINT:
         case SQL_INTEGER:
         case SQL_BIGINT:
-        case SQL_INTERVAL_MONTH SQL_INTERVAL_YEAR:
+            /*!
+                \internal MYODBC RULE
+
+                We convert to months. 
+            */
+            if ( pInterval->interval_sign == SQL_FALSE )
+                pResultPutData->variantData.setValue( pYearMonth->year * 12 +
pYearMonth->month );
+            else
+                pResultPutData->variantData.setValue( -(pYearMonth->year * 12 +
pYearMonth->month) );
+
+            MYODBCDbgReturn( SQL_SUCCESS );
+
+        case SQL_INTERVAL_MONTH:
+        case SQL_INTERVAL_YEAR:
         case SQL_INTERVAL_YEAR_TO_MONTH:
-            MYODBCDbgReturn( toSQL( pResultPutData ) );
+            MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_07006, 0,
tr("SQL data type not supported") ) );
     }
 
     /*!
@@ -2803,6 +2830,10 @@
 {
     MYODBCDbgEnter();
 
+    SQL_INTERVAL_STRUCT *   pInterval   =
(SQL_INTERVAL_STRUCT*)pResultPutData->pDescriptorRecordAPD->getDataPtr();
+    SQL_DAY_SECOND_STRUCT * pDaySecond  =
&((SQL_DAY_SECOND_STRUCT*)pInterval->intval.day_second);
+    char                    szFormatBuffer[128];
+
     switch ( pResultPutData->pDescriptorRecordIPD->getConciseType() )
     {
         case SQL_CHAR:
@@ -2811,12 +2842,42 @@
         case SQL_WCHAR:
         case SQL_WVARCHAR:
         case SQL_WLONGVARCHAR:
+            /*!
+                \internal MYODBC RULE
+
+                We convert to string formatted as; "DD:HH:MM:SS:FF".
+            */
+            sprintf( szFormatBuffer, "'%02d:%02d:%02d:%02d:%02d'", 
+                     pDaySecond->day,
+                     pDaySecond->hour,
+                     pDaySecond->minute,
+                     pDaySecond->second,
+                     pDaySecond->fraction );
+            pResultPutData->variantData.setValue( QString::fromAscii( szFormatBuffer )
); ;
+            MYODBCDbgReturn( SQL_SUCCESS );
         case SQL_DECIMAL:
         case SQL_NUMERIC:
         case SQL_TINYINT:
         case SQL_SMALLINT:
         case SQL_INTEGER:
         case SQL_BIGINT:
+            /*!
+                \internal MYODBC RULE
+
+                We convert to seconds (any fraction is truncated). 
+            */
+            if ( pInterval->interval_sign == SQL_FALSE )
+                pResultPutData->variantData.setValue( ((pDaySecond->day * 24 +
pDaySecond->hour) * 60 + pDaySecond->minute) * 60 + pDaySecond->second );
+            else
+                pResultPutData->variantData.setValue( -(((pDaySecond->day * 24 +
pDaySecond->hour) * 60 + pDaySecond->minute) * 60 + pDaySecond->second) );
+
+            if ( pDaySecond->fraction )
+            {
+                getDiagnostic()->doAppend( MDiagnostic::DIA_22015 );
+                MYODBCDbgReturn( SQL_SUCCESS_WITH_INFO );
+            }
+
+            MYODBCDbgReturn( SQL_SUCCESS );
         case SQL_INTERVAL_DAY:
         case SQL_INTERVAL_HOUR:
         case SQL_INTERVAL_MINUTE:
@@ -2827,7 +2888,7 @@
         case SQL_INTERVAL_HOUR_TO_MINUTE:
         case SQL_INTERVAL_HOUR_TO_SECOND:
         case SQL_INTERVAL_MINUTE_TO_SECOND:
-            MYODBCDbgReturn( toSQL( pResultPutData ) );
+            MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_07006, 0,
tr("SQL data type not supported") ) );
     }
 
     /*!
@@ -2859,6 +2920,15 @@
     if ( !pData )
         MYODBCDbgReturn( SQL_SUCCESS );
 
+    /*!
+        \internal
+        \todo
+
+        Current limitations;
+
+            - we assume we are supporting SQLBindParameter (no SQLSetPos) so with this in
mind we format for insert into an SQL statement
+            - we do not support data at execution (no SQLPutData, SQLParamData)
+    */
     switch ( pResultPutData->pDescriptorRecordAPD->getConciseType() )
     {
         case SQL_C_CHAR:

Thread
Connector/ODBC 5 commit: r331 - trunk/MYSQLPlus/MYSQLPlusLibpharvey14 Jun