List:Commits« Previous MessageNext Message »
From:pharvey Date:April 20 2006 11:10pm
Subject:Connector/ODBC 5 commit: r90 - MYODBCShell
View as plain text  
Modified:
   MYODBCShell/MYODBCShell.cpp
   MYODBCShell/MYODBCShell.h
   MYODBCShell/main.cpp
Log:


Modified: MYODBCShell/MYODBCShell.cpp
===================================================================
--- MYODBCShell/MYODBCShell.cpp	2006-04-20 20:58:24 UTC (rev 89)
+++ MYODBCShell/MYODBCShell.cpp	2006-04-20 23:10:27 UTC (rev 90)
@@ -43,7 +43,7 @@
     nMaxDataWidth   = 0;
     hEnv            = NULL;
     hDbc            = NULL;
-    hStmt           = NULL;
+    hStm            = NULL;
     pstreamStdIn    = new QTextStream( stdin );
     pstreamStdOut   = new QTextStream( stdout );
     pstreamStdErr   = new QTextStream( stderr );
@@ -131,7 +131,7 @@
     return bLabels;
 }
 
-RESULT_FORMAT MYODBCShell::getResultFormat()
+MYODBCShell::RESULT_FORMAT MYODBCShell::getResultFormat()
 {
     return nResultFormat;
 }
@@ -152,13 +152,13 @@
 
     if ( hEnv )
     {
-        pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error." ).arg(
__FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error."
).arg( __FILE__ ).arg( __LINE__ ) << endl;
         return false;
     }
 
     if ( !SQL_SUCCEEDED( SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv ) ) )
     {
-        pstreamStdErr << QString( "[%1][%2][ERROR] Could not allocate
SQL_HANDLE_ENV." ).arg( __FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Could not allocate
SQL_HANDLE_ENV." ).arg( __FILE__ ).arg( __LINE__ ) << endl;
         hEnv = NULL;
         return false;
     }
@@ -166,13 +166,13 @@
     if ( !SQL_SUCCEEDED( SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION,
(SQLPOINTER)SQL_OV_ODBC3, 0 ) ) )
     {
         if ( bVerbose ) doErrors( hEnv, NULL, NULL );
-        pstreamStdErr << QString( "[%1][%2][WARNING] Could not SQLSetEnvAttr to set
version to SQL_OV_ODBC3." ).arg( __FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][WARNING] Could not SQLSetEnvAttr to
set version to SQL_OV_ODBC3." ).arg( __FILE__ ).arg( __LINE__ ) << endl;
     }
 
     if ( !SQL_SUCCEEDED( SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc ) ) )
     {
         if ( bVerbose ) doErrors( hEnv, NULL, NULL );
-        pstreamStdErr << QString( "[%1][%2][ERROR] Could not allocate
SQL_HANDLE_DBC." ).arg( __FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Could not allocate
SQL_HANDLE_DBC." ).arg( __FILE__ ).arg( __LINE__ ) << endl;
         SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
         hEnv = NULL;
         hDbc = NULL;
@@ -181,17 +181,17 @@
 
     if ( bDriverConnect )
     {
-        SQLTCHAR    sOut[4096];
+        SQLWCHAR    sOut[4096];
         SQLSMALLINT nLen;
-        nReturn = SQLDriverConnect( hDbc, 0, stringConnect.utf16(),
stringConnect.length(), sOut, 4096, &nLen, SQL_DRIVER_NOPROMPT );
+        nReturn = SQLDriverConnect( hDbc, 0, (SQLWCHAR*)stringConnect.utf16(),
stringConnect.length(), sOut, 4096, &nLen, SQL_DRIVER_NOPROMPT );
     }
-    else
-        nReturn = SQLConnect( hDbc, stringConnect.utf16(), stringConnect.length(),
stringUID.utf16(), stringUID.length(), stringPWD.utf16(), stringPWD.length() );
+    else 
+        nReturn = SQLConnect( hDbc, (SQLWCHAR*)stringConnect.utf16(),
stringConnect.length(), (SQLWCHAR*)stringUID.utf16(), stringUID.length(),
(SQLWCHAR*)stringPWD.utf16(), stringPWD.length() );
 
     if ( !SQL_SUCCEEDED( nReturn ) )
     {
         if ( bVerbose ) doErrors( hEnv, hDbc, NULL );
-        pstreamStdErr << QString( "[%1][%2][ERROR] Could not connect." ).arg(
__FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Could not connect." ).arg(
__FILE__ ).arg( __LINE__ ) << endl;
         SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
         SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
         hEnv = NULL;
@@ -206,7 +206,7 @@
 {
     if ( !hDbc )
     {
-        pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error." ).arg(
__FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error."
).arg( __FILE__ ).arg( __LINE__ ) << endl;
         return false;
     }
 
@@ -227,7 +227,7 @@
 {
     if ( !hDbc )
     {
-        pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error." ).arg(
__FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error."
).arg( __FILE__ ).arg( __LINE__ ) << endl;
         return false;
     }
 
@@ -248,7 +248,7 @@
 {
     SQLUINTEGER nDataWidth                  = 10;
     SQLUINTEGER nOptimalDisplayWidth        = 10;
-    SQLTCHAR    sColumnName[MAX_DATA_WIDTH] = "";   
+    SQLWCHAR    sColumnName[MAX_DATA_WIDTH] = L"";
 
     SQLColAttribute( hStm, nColumn, SQL_DESC_DISPLAY_SIZE, NULL, 0, NULL, &nDataWidth
);
     SQLColAttribute( hStm, nColumn, SQL_DESC_LABEL, sColumnName, sizeof(sColumnName),
NULL, NULL );
@@ -271,7 +271,7 @@
 
     if ( !hDbc )
     {
-        pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error." ).arg(
__FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error."
).arg( __FILE__ ).arg( __LINE__ ) << endl;
         return false;
     }
 
@@ -279,7 +279,7 @@
     if ( !SQL_SUCCEEDED( SQLAllocHandle( SQL_HANDLE_STMT, hDbc, &hStm ) ) )
     {
         if ( bVerbose ) doErrors( hEnv, hDbc, NULL );
-        pstreamStdErr << QString( "[%1][%2][ERROR] Could not allocate
SQL_HANDLE_STMT." ).arg( __FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Could not allocate
SQL_HANDLE_STMT." ).arg( __FILE__ ).arg( __LINE__ ) << endl;
         hStm = NULL;
         return false;
     }
@@ -288,7 +288,7 @@
     {
         if ( bVerbose ) doErrors( hEnv, hDbc, hStm );
         _ftprintf( stderr, "[MYODBCShell]ERROR: Could not SQLPrepare\n" );
-        pstreamStdErr << QString( "[%1][%2][ERROR] Could not SQLPrepare." ).arg(
__FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Could not SQLPrepare." ).arg(
__FILE__ ).arg( __LINE__ ) << endl;
         SQLFreeHandle( SQL_HANDLE_STMT, hStm );
         hStm = NULL;
         return false;
@@ -297,17 +297,17 @@
     nReturn = SQLExecute( hStm );
     if ( nReturn == SQL_NO_DATA )
     {
-        pstreamStdErr << QString( "[%1][%2][INFO] SQLExecute returned SQL_NO_DATA."
).arg( __FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][INFO] SQLExecute returned
SQL_NO_DATA." ).arg( __FILE__ ).arg( __LINE__ ) << endl;
     }
     else if ( nReturn == SQL_SUCCESS_WITH_INFO )
     {
         if ( bVerbose ) doErrors( hEnv, hDbc, hStm );
-        pstreamStdErr << QString( "[%1][%2][INFO] SQLExecute returned
SQL_SUCCESS_WITH_INFO." ).arg( __FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][INFO] SQLExecute returned
SQL_SUCCESS_WITH_INFO." ).arg( __FILE__ ).arg( __LINE__ ) << endl;
     }
     else if ( nReturn != SQL_SUCCESS )
     {
         if ( bVerbose ) doErrors( hEnv, hDbc, hStm );
-        pstreamStdErr << QString( "[%1][%2][ERROR] Could not SQLExecute." ).arg(
__FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Could not SQLExecute." ).arg(
__FILE__ ).arg( __LINE__ ) << endl;
         SQLFreeHandle( SQL_HANDLE_STMT, hStm );
         hStm = NULL;
         return 0;
@@ -334,14 +334,14 @@
     // init
     if ( !hDbc )
     {
-        pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error." ).arg(
__FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error."
).arg( __FILE__ ).arg( __LINE__ ) << endl;
         return false;
     }
 
     if ( !SQL_SUCCEEDED( SQLAllocHandle( SQL_HANDLE_STMT, hDbc, &hStm ) ) )
     {
         if ( bVerbose ) doErrors( hEnv, hDbc, NULL );
-        pstreamStdErr << QString( "[%1][%2][ERROR] Could not allocate
SQL_HANDLE_STMT." ).arg( __FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Could not allocate
SQL_HANDLE_STMT." ).arg( __FILE__ ).arg( __LINE__ ) << endl;
         hStm = NULL;
         return false;
     }
@@ -353,7 +353,7 @@
         if ( !SQL_SUCCEEDED( SQLColumns( hStm, NULL, 0, NULL, 0, stringTable.utf16(),
stringTable.length(), NULL, 0 ) ) )
         {
             if ( bVerbose ) doErrors( hEnv, hDbc, hStm );
-            pstreamStdErr << QString( "[%1][%2][ERROR] Could not SQLColumns."
).arg( __FILE__ ).arg( __LINE___ ) << endl;
+            *pstreamStdErr << QString( "[%1][%2][ERROR] Could not SQLColumns."
).arg( __FILE__ ).arg( __LINE__ ) << endl;
             SQLFreeHandle( SQL_HANDLE_STMT, hStm );
             hStm = NULL;
             return false;
@@ -364,7 +364,7 @@
         if ( !SQL_SUCCEEDED( SQLTables( hStm, NULL, 0, NULL, 0, NULL, 0, NULL, 0 ) ) )
         {
             if ( bVerbose ) doErrors( hEnv, hDbc, hStm );
-            pstreamStdErr << QString( "[%1][%2][ERROR] Could not SQLTables." ).arg(
__FILE__ ).arg( __LINE___ ) << endl;
+            *pstreamStdErr << QString( "[%1][%2][ERROR] Could not SQLTables."
).arg( __FILE__ ).arg( __LINE__ ) << endl;
             SQLFreeHandle( SQL_HANDLE_STMT, hStm );
             hStm = NULL;
             return false;
@@ -383,10 +383,10 @@
 
 bool MYODBCShell::doTables( const QString &stringCommand )
 {
-    SQLTCHAR *      psCatalog       = NULL;
-    SQLTCHAR *      psSchema        = NULL;
-    SQLTCHAR *      psTable         = NULL;
-    SQLTCHAR *      psTableTypes    = NULL;
+    SQLWCHAR *      psCatalog       = NULL;
+    SQLWCHAR *      psSchema        = NULL;
+    SQLWCHAR *      psTable         = NULL;
+    SQLWCHAR *      psTableTypes    = NULL;
     SQLSMALLINT     nCatalog        = 0;
     SQLSMALLINT     nSchema         = 0;
     SQLSMALLINT     nTable          = 0;
@@ -395,14 +395,14 @@
     // init
     if ( !hDbc )
     {
-        pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error." ).arg(
__FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error."
).arg( __FILE__ ).arg( __LINE__ ) << endl;
         return false;
     }
 
     if ( !SQL_SUCCEEDED( SQLAllocHandle( SQL_HANDLE_STMT, hDbc, &hStm ) ) )
     {
         if ( bVerbose ) doErrors( hEnv, hDbc, NULL );
-        pstreamStdErr << QString( "[%1][%2][ERROR] Could not allocate
SQL_HANDLE_STMT." ).arg( __FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Could not allocate
SQL_HANDLE_STMT." ).arg( __FILE__ ).arg( __LINE__ ) << endl;
         hStm = NULL;
         return false;
     }
@@ -437,7 +437,7 @@
     if ( !SQL_SUCCEEDED( SQLTables( hStm, psCatalog, nCatalog, psSchema, nSchema,
psTable, nTable, psTableTypes, nTableTypes ) ) )
     {
         if ( bVerbose ) doErrors( hEnv, hDbc, hStm );
-        pstreamStdErr << QString( "[%1][%2][ERROR] Could not SQLTables." ).arg(
__FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Could not SQLTables." ).arg(
__FILE__ ).arg( __LINE__ ) << endl;
         SQLFreeHandle( SQL_HANDLE_STMT, hStm );
         hStm = NULL;
         return false;
@@ -455,10 +455,10 @@
 
 bool MYODBCShell::doColumns( const QString &stringCommand )
 {
-    SQLTCHAR *      psCatalog   = NULL;
-    SQLTCHAR *      psSchema    = NULL;
-    SQLTCHAR *      psTable     = NULL;
-    SQLTCHAR *      psColumn    = NULL;
+    SQLWCHAR *      psCatalog   = NULL;
+    SQLWCHAR *      psSchema    = NULL;
+    SQLWCHAR *      psTable     = NULL;
+    SQLWCHAR *      psColumn    = NULL;
     SQLSMALLINT     nCatalog    = 0;
     SQLSMALLINT     nSchema     = 0;
     SQLSMALLINT     nTable      = 0;
@@ -467,14 +467,14 @@
     // init
     if ( !hDbc )
     {
-        pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error." ).arg(
__FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error."
).arg( __FILE__ ).arg( __LINE__ ) << endl;
         return false;
     }
 
     if ( !SQL_SUCCEEDED( SQLAllocHandle( SQL_HANDLE_STMT, hDbc, &hStm ) ) )
     {
         if ( bVerbose ) doErrors( hEnv, hDbc, NULL );
-        pstreamStdErr << QString( "[%1][%2][ERROR] Could not allocate
SQL_HANDLE_STMT." ).arg( __FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Could not allocate
SQL_HANDLE_STMT." ).arg( __FILE__ ).arg( __LINE__ ) << endl;
         hStm = NULL;
         return false;
     }
@@ -509,7 +509,7 @@
     if ( !SQL_SUCCEEDED( SQLColumns( hStm, psCatalog, nCatalog, psSchema, nSchema,
psTable, nTable, psColumn, nColumn ) ) )
     {
         if ( bVerbose ) doErrors( hEnv, hDbc, hStm );
-        pstreamStdErr << QString( "[%1][%2][ERROR] Could not SQLColumn." ).arg(
__FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Could not SQLColumn." ).arg(
__FILE__ ).arg( __LINE__ ) << endl;
         SQLFreeHandle( SQL_HANDLE_STMT, hStm );
         hStm = NULL;
         return false;
@@ -532,7 +532,7 @@
 
     if ( !hStm )
     {
-        pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error." ).arg(
__FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Function sequence error."
).arg( __FILE__ ).arg( __LINE__ ) << endl;
         return false;
     }
 
@@ -541,7 +541,7 @@
     if ( SQLNumResultCols( hStm, &nCols ) != SQL_SUCCESS )
     {
         if ( bVerbose ) doErrors( hEnv, hDbc, hStmt );
-        pstreamStdErr << QString( "[%1][%2][ERROR] Could not SQLNumResultCols."
).arg( __FILE__ ).arg( __LINE___ ) << endl;
+        *pstreamStdErr << QString( "[%1][%2][ERROR] Could not SQLNumResultCols."
).arg( __FILE__ ).arg( __LINE__ ) << endl;
         return false;
     }
 
@@ -596,7 +596,7 @@
 {
     SQLINTEGER  nColumn     = 0;
     SQLSMALLINT nColumns    = 0;
-    SQLTCHAR    sColumnName[MAX_DATA_WIDTH]  = "";   
+    SQLWCHAR    sColumnName[MAX_DATA_WIDTH]  = "";   
     QString     stringBuffer;
     QString     stringNameLine;
     SQLUINTEGER nChar;
@@ -635,7 +635,7 @@
     SQLINTEGER  nColumn     = 0;
     SQLSMALLINT nColumns    = 0;
     SQLINTEGER  nIndicator  = 0;
-    SQLTCHAR    sColumnValue[MAX_DATA_WIDTH] = "";
+    SQLWCHAR    sColumnValue[MAX_DATA_WIDTH] = "";
     SQLRETURN   nReturn                 = 0;
     SQLINTEGER  nRows                   = 0;
 
@@ -699,7 +699,7 @@
 bool MYODBCShell::doHeaderHTMLTable()
 {
     SQLSMALLINT     nColumns = 0;
-    SQLTCHAR        sColumnName[MAX_DATA_WIDTH+1] = "";   
+    SQLWCHAR        sColumnName[MAX_DATA_WIDTH] = "";   
 
     streamStdOut << "<table BORDER>" << endl;
     streamStdOut << "<tr BGCOLOR=#000099>" << endl;
@@ -730,14 +730,14 @@
     if ( !SQL_SUCCEEDED( SQLNumResultCols( hStm, &nColumns ) ) )
         nColumns = -1;
 
-    while ( SQLFetch( hStm ) != SQL_SUCCESS ) )
+    while ( SQLFetch( hStm ) != SQL_SUCCESS )
     {
         streamStdOut << "<tr>" << endl;
 
         for ( SQLINTEGER nColumn = 1; nColumn <= nColumns; nColumn++ )
         {
             SQLINTEGER nIndicator = 0;
-            SQLTCHAR   sColumnValue[MAX_DATA_WIDTH] = "";
+            SQLWCHAR   sColumnValue[MAX_DATA_WIDTH] = "";
 
             streamStdOut << "<td>" << endl;
             streamStdOut << "<font face=Arial,Helvetica>" << endl;
@@ -750,6 +750,7 @@
             else if ( nReturn == SQL_ERROR )
             {
                 streamStdOut << endl;
+                if ( bVerbose ) doErrors( NULL, NULL, hStm );
                 bReturn = false;
                 break;
             }
@@ -773,108 +774,91 @@
     return true;
 }
 
-
-+++++++++++++
-
-
-
-
-
-
-/****************************
- * WRITE DELIMITED
- * - this output can be used by the ODBC Text File driver
- * - last column no longer has a delimit char (it is implicit)...
- *   this is consistent with odbctxt
- ***************************/
-void WriteHeaderDelimited( SQLHSTMT hStmt, char cDelimiter )
+bool MYODBCShell::doHeaderDelimited()
 {
-    SQLINTEGER      nCol                            = 0;
-    SQLSMALLINT     nColumns                        = 0;
-    SQLTCHAR         szColumnName[MAX_DATA_WIDTH+1]  = "";   
+    SQLSMALLINT nColumns                     = 0;
+    SQLWCHAR    sColumnName[MAX_DATA_WIDTH]  = "";   
 
-    if ( SQLNumResultCols( hStmt, &nColumns ) != SQL_SUCCESS )
+    if ( !SQL_SUCCEEDED( SQLNumResultCols( hStm, &nColumns ) ) )
         nColumns = -1;
 
-    for ( nCol = 1; nCol <= nColumns; nCol++ )
+    for ( SQLINTEGER nColumn = 1; nColumn <= nColumns; nColumn++ )
     {
-        SQLColAttribute( hStmt, nCol, SQL_DESC_LABEL, szColumnName, sizeof(szColumnName),
NULL, NULL );
-        fputs((char*) szColumnName, stdout );
-        if ( nCol < nColumns )
-            putchar( cDelimiter );
+        SQLColAttribute( hStm, nColumn, SQL_DESC_LABEL, sColumnName, sizeof(sColumnName),
NULL, NULL );
+        streamStdOut << sColumnName;
+        if ( nColumn < nColumns )
+            streamStdOut << cDelimiter;
     }
-    putchar( '\n' );
+    streamStdOut << endl;
+
+    return true;
 }
 
-void WriteBodyDelimited( SQLHSTMT hStmt, char cDelimiter )
+bool MYODBCShell::doBodyDelimited()
 {
-    SQLINTEGER      nCol                            = 0;
-    SQLSMALLINT     nColumns                        = 0;
-    SQLINTEGER          nIndicator                      = 0;
-    SQLTCHAR         szColumnValue[MAX_DATA_WIDTH+1] = "";
-    SQLRETURN       nReturn                         = 0;
-    SQLRETURN       ret;
+    SQLSMALLINT nColumns    = 0;
+    SQLRETURN   nReturn     = 0;
+    bool        bReturn     = true;
 
-    if ( SQLNumResultCols( hStmt, &nColumns ) != SQL_SUCCESS )
+    if ( !SQL_SUCCEEDED( SQLNumResultCols( hStm, &nColumns ) ) )
         nColumns = -1;
 
-    /* ROWS */
-    while (( ret = SQLFetch( hStmt )) == SQL_SUCCESS )
+    while ( SQLFetch( hStm ) != SQL_SUCCESS )
     {
-        /* COLS */
-        for ( nCol = 1; nCol <= nColumns; nCol++ )
+        for ( SQLINTEGER nColumn = 1; nColumn <= nColumns; nColumn++ )
         {
-            nReturn = SQLGetData( hStmt, nCol, SQL_C_CHAR, (SQLPOINTER)szColumnValue,
sizeof(szColumnValue), &nIndicator );
-            if ( nReturn == SQL_SUCCESS && nIndicator != SQL_NULL_DATA )
+            SQLINTEGER nIndicator = 0;
+            SQLWCHAR   sColumnValue[MAX_DATA_WIDTH] = "";
+
+            nReturn = SQLGetData( hStm, nColumn, SQL_C_CHAR, (SQLPOINTER)sColumnValue,
sizeof(sColumnValue), &nIndicator );
+            if ( SQL_SUCCEEDED( nReturn ) && nIndicator != SQL_NULL_DATA )
             {
-                fputs((char*) szColumnValue, stdout );
-                if ( nCol < nColumns )
-                    putchar( cDelimiter );
+                streamStdOut << QString( sColumnValue );
+                if ( nColumn < nColumns )
+                    streamStdOut << cDelimiter;
             }
             else if ( nReturn == SQL_ERROR )
             {
-                ret = SQL_ERROR;
+                streamStdOut << endl;
+                if ( bVerbose ) doErrors( NULL, NULL, hStm );
+                bReturn = false;
                 break;
             }
             else
             {
-                if ( nCol < nColumns )
-                    putchar( cDelimiter );
+                if ( nColumn < nColumns )
+                    streamStdOut << cDelimiter;
             }
         }
-        if (ret != SQL_SUCCESS)
+        if ( !bReturn )
             break;
-        printf( "\n" );
+        streamStdOut << endl;
     }
-    if ( ret == SQL_ERROR )
-    {
-        if ( bVerbose ) doErrors( 0, 0, hStmt );
-    }
+
+    return bReturn;
 }
 
-
-
-int doErrors( SQLHENV hEnv, SQLHDBC hDbc, SQLHSTMT hStmt )
+bool MYODBCShell::doErrors( SQLHENV hEnv, SQLHDBC hDbc, SQLHSTMT hStm )
 {
     SQLSMALLINT nRecord = 1;
-    SQLTCHAR     szState[6];
+    SQLWCHAR    sState[6];
     SQLINTEGER  nNativeError;
-    SQLTCHAR     szMessageText[SQL_MAX_MESSAGE_LENGTH];
+    SQLWCHAR    sMessageText[SQL_MAX_MESSAGE_LENGTH];
     SQLSMALLINT nTextLength;
 
-    if ( hStmt )
+    if ( hStm )
     {
-        while ( SQL_SUCCEEDED(SQLGetDiagRec( SQL_HANDLE_STMT, 
-                                             hStmt, 
-                                             nRecord, 
-                                             szState,
-                                             &nNativeError,
-                                             szMessageText,
-                                             SQL_MAX_MESSAGE_LENGTH,
-                                             &nTextLength )) )
+        while ( SQL_SUCCEEDED( SQLGetDiagRec( SQL_HANDLE_STMT, 
+                                              hStm, 
+                                              nRecord, 
+                                              sState,
+                                              &nNativeError,
+                                              sMessageText,
+                                              SQL_MAX_MESSAGE_LENGTH,
+                                              &nTextLength )) )
         {
-            szState[5] = '\0';
-            _ftprintf( stderr, "[%s]%s\n", szState, szMessageText );
+            sState[5] = '\0';
+            streamStdErr << "[" << sState << "]" << sMessageText
<< endl;
             nRecord++;
         }
     }
@@ -892,7 +876,7 @@
                                              &nTextLength )) )
         {
             szState[5] = '\0';
-            _ftprintf( stderr, "[%s]%s\n", szState, szMessageText );
+            streamStdErr << "[" << sState << "]" << sMessageText
<< endl;
             nRecord++;
         }
     }
@@ -910,7 +894,7 @@
                                              &nTextLength )) )
         {
             szState[5] = '\0';
-            _ftprintf( stderr, "[%s]%s\n", szState, szMessageText );
+            streamStdErr << "[" << sState << "]" << sMessageText
<< endl;
             nRecord++;
         }
     }

Modified: MYODBCShell/MYODBCShell.h
===================================================================
--- MYODBCShell/MYODBCShell.h	2006-04-20 20:58:24 UTC (rev 89)
+++ MYODBCShell/MYODBCShell.h	2006-04-20 23:10:27 UTC (rev 90)
@@ -37,6 +37,8 @@
 #include <QCoreApplication>
 #include <QString>
 #include <QTextStream>
+#include <QVector>
+#include <QStringList>
 
 #include <MYODBCC.h>
 

Modified: MYODBCShell/main.cpp
===================================================================
--- MYODBCShell/main.cpp	2006-04-20 20:58:24 UTC (rev 89)
+++ MYODBCShell/main.cpp	2006-04-20 23:10:27 UTC (rev 90)
@@ -97,7 +97,7 @@
                     break;
                 case 'd':
                     shell.setDelimiter( i->at( 2 ) );
-                    shell.setResultFormat( MYODBCShell::RESULT_FORMAT_DELIMITER );
+                    shell.setResultFormat( MYODBCShell::RESULT_FORMAT_DELIMITED );
                     break;
                 case 'w':
                     shell.setResultFormat( MYODBCShell::RESULT_FORMAT_HTML );
@@ -112,7 +112,7 @@
                     shell.setVerbose( false );
                     break;
                 default:
-                    (*installer.pstreamStdOut) << "[ERROR] Invalid switch "
<< i->at( 1 ) << endl;
+                    *shell.pstreamStdOut << "[ERROR] Invalid switch " <<
i->at( 1 ) << endl;
                     return 1;
             }
         }
@@ -125,7 +125,7 @@
             else if ( shell.getPWD().isNull() )
                 shell.setPWD( *i );
             else
-                (*installer.pstreamStdOut) << "[ERROR] Invalid/extra arg " <<
*i << endl;
+                *shell.pstreamStdOut << "[ERROR] Invalid/extra arg " << *i
<< endl;
         }
     }
 
@@ -135,19 +135,19 @@
 
     if ( !bBatch )
     {
-        shell.pstreamStdOut << "+----" << endl;
-        shell.pstreamStdOut << "| Connected!" << endl;
-        shell.pstreamStdOut << "|" << endl;
-        shell.pstreamStdOut << "| sql-statement" << endl;
-        shell.pstreamStdOut << "| help [table_name]" << endl;
-        shell.pstreamStdOut << "| SQLTables catalog|schema|table|table_type"
<< endl;
-        shell.pstreamStdOut << "| SQLColumns catalog|schema|table|column" <<
endl;
-        shell.pstreamStdOut << "| quit" << endl;
-        shell.pstreamStdOut << "|" << endl;
-        shell.pstreamStdOut << "| NOTE: Blank line causes buffered text" <<
endl;
-        shell.pstreamStdOut << "|       to be processed." << endl;
-        shell.pstreamStdOut << "|" << endl;
-        shell.pstreamStdOut << "+---" << endl;
+        *shell.pstreamStdOut << "+----" << endl;
+        *shell.pstreamStdOut << "| Connected!" << endl;
+        *shell.pstreamStdOut << "|" << endl;
+        *shell.pstreamStdOut << "| sql-statement" << endl;
+        *shell.pstreamStdOut << "| help [table_name]" << endl;
+        *shell.pstreamStdOut << "| SQLTables catalog|schema|table|table_type"
<< endl;
+        *shell.pstreamStdOut << "| SQLColumns catalog|schema|table|column" <<
endl;
+        *shell.pstreamStdOut << "| quit" << endl;
+        *shell.pstreamStdOut << "|" << endl;
+        *shell.pstreamStdOut << "| NOTE: Blank line causes buffered text" <<
endl;
+        *shell.pstreamStdOut << "|       to be processed." << endl;
+        *shell.pstreamStdOut << "|" << endl;
+        *shell.pstreamStdOut << "+---" << endl;
     }
 
     QString stringLine;
@@ -156,7 +156,7 @@
     do
     {
         if ( !bBatch )
-            shell.pstreamStdOut << "MYODBCShell> "; 
+            *shell.pstreamStdOut << "MYODBCShell> "; 
 
         stringLine = shell.pstreamStdIn->readLine();
 
@@ -167,7 +167,6 @@
         }
         else if ( stringLine == "quit" )
             break;
-        }
         else
             stringCommand += ( " " + stringLine );
 

Thread
Connector/ODBC 5 commit: r90 - MYODBCShellpharvey21 Apr