List:Commits« Previous MessageNext Message »
From:pharvey Date:April 21 2006 5:02am
Subject:Connector/ODBC 5 commit: r92 - MYODBCShell
View as plain text  
Modified:
   MYODBCShell/MYODBCShell.cpp
   MYODBCShell/main.cpp
Log:


Modified: MYODBCShell/MYODBCShell.cpp
===================================================================
--- MYODBCShell/MYODBCShell.cpp	2006-04-21 03:45:19 UTC (rev 91)
+++ MYODBCShell/MYODBCShell.cpp	2006-04-21 05:02:45 UTC (rev 92)
@@ -36,7 +36,7 @@
 MYODBCShell::MYODBCShell()
 {
     bDriverConnect  = false;
-    bVerbose        = false;
+    bVerbose        = true;
     bLabels         = true;
     nResultFormat   = RESULT_FORMAT_NORMAL;
     cDelimiter      = '|';
@@ -549,10 +549,10 @@
         switch ( nResultFormat )
         {
             case RESULT_FORMAT_NORMAL:
-                doHeaderHTMLTable();
+                doHeaderNormal();
                 break;
             case RESULT_FORMAT_HTML:
-                doHeaderNormal();
+                doHeaderHTMLTable();
                 break;
             case RESULT_FORMAT_DELIMITED:
                 doHeaderDelimited();
@@ -563,10 +563,10 @@
         switch ( nResultFormat )
         {
             case RESULT_FORMAT_NORMAL:
-                doBodyHTMLTable();
+                nRows = doBodyNormal();
                 break;
             case RESULT_FORMAT_HTML:
-                nRows = doBodyNormal();
+                doBodyHTMLTable();
                 break;
             case RESULT_FORMAT_DELIMITED:
                 doBodyDelimited();
@@ -610,12 +610,10 @@
         if ( !SQL_SUCCEEDED( SQLColAttribute( hStm, nColumn, SQL_DESC_LABEL, sColumnName,
sizeof(sColumnName), NULL, NULL ) ) && bVerbose )
             doErrors( NULL, NULL, hStm );
 
-        /* SEP */
         stringSepLine += "+";
         for ( nChar=0; nChar <= vectorOptimalDisplayWidths[nColumn]; nChar++ )
stringSepLine += "-";
 
-        /* HDR */
-        stringNameLine += stringFormatBuffer.sprintf( "| %-*.*s",
vectorOptimalDisplayWidths[nColumn], vectorOptimalDisplayWidths[nColumn], sColumnName );
+        stringNameLine += stringFormatBuffer.sprintf( "| %-*.*ls",
vectorOptimalDisplayWidths[nColumn], vectorOptimalDisplayWidths[nColumn], sColumnName );
     }
     stringSepLine  += "+";
     stringNameLine += "|";
@@ -640,17 +638,15 @@
     if ( !SQL_SUCCEEDED( SQLNumResultCols( hStm, &nColumns ) ) )
         nColumns = -1;
 
-    /* ROWS */
     nReturn = SQLFetch( hStm );
     while ( SQL_SUCCEEDED( nReturn ) )
     {
-        /* COLS */
         for ( nColumn = 1; nColumn <= nColumns; nColumn++ )
         {
-            nReturn = SQLGetData( hStm, nColumn, SQL_C_CHAR, (SQLPOINTER)sColumnValue,
sizeof(sColumnValue), &nIndicator );
+            nReturn = SQLGetData( hStm, nColumn, SQL_C_WCHAR, (SQLPOINTER)sColumnValue,
sizeof(sColumnValue), &nIndicator );
             if ( SQL_SUCCEEDED( nReturn ) && nIndicator != SQL_NULL_DATA )
             {
-                *pstreamStdOut << stringFormatBuffer.sprintf( "| %-*.*s",
vectorOptimalDisplayWidths[nColumn], vectorOptimalDisplayWidths[nColumn], sColumnValue );
+                *pstreamStdOut << stringFormatBuffer.sprintf( "| %-*.*ls",
vectorOptimalDisplayWidths[nColumn], vectorOptimalDisplayWidths[nColumn], sColumnValue );
             }
             else if ( nReturn == SQL_ERROR )
             {
@@ -728,7 +724,7 @@
     if ( !SQL_SUCCEEDED( SQLNumResultCols( hStm, &nColumns ) ) )
         nColumns = -1;
 
-    while ( SQLFetch( hStm ) != SQL_SUCCESS )
+    while ( SQL_SUCCEEDED( SQLFetch( hStm ) ) )
     {
         *pstreamStdOut << "<tr>" << endl;
 
@@ -740,11 +736,10 @@
             *pstreamStdOut << "<td>" << endl;
             *pstreamStdOut << "<font face=Arial,Helvetica>" << endl;
 
-            nReturn = SQLGetData( hStm, nColumn, SQL_C_CHAR, (SQLPOINTER)sColumnValue,
sizeof(sColumnValue), &nIndicator );
+            nReturn = SQLGetData( hStm, nColumn, SQL_C_WCHAR, (SQLPOINTER)sColumnValue,
sizeof(sColumnValue), &nIndicator );
             if ( SQL_SUCCEEDED( nReturn ) && nIndicator != SQL_NULL_DATA )
             {
-//                *pstreamStdOut << QString::fromStdWString( sColumnValue )
<< endl;
-                *pstreamStdOut << sColumnValue;
+                *pstreamStdOut << QString::fromStdWString( sColumnValue ) <<
endl;
             }
             else if ( nReturn == SQL_ERROR )
             {
@@ -784,7 +779,7 @@
     for ( SQLINTEGER nColumn = 1; nColumn <= nColumns; nColumn++ )
     {
         SQLColAttribute( hStm, nColumn, SQL_DESC_LABEL, sColumnName, sizeof(sColumnName),
NULL, NULL );
-        *pstreamStdOut << sColumnName;
+        *pstreamStdOut << QString::fromStdWString( sColumnName );
         if ( nColumn < nColumns )
             *pstreamStdOut << cDelimiter;
     }
@@ -802,18 +797,17 @@
     if ( !SQL_SUCCEEDED( SQLNumResultCols( hStm, &nColumns ) ) )
         nColumns = -1;
 
-    while ( SQLFetch( hStm ) != SQL_SUCCESS )
+    while ( SQL_SUCCEEDED( SQLFetch( hStm ) ) )
     {
         for ( SQLINTEGER nColumn = 1; nColumn <= nColumns; nColumn++ )
         {
             SQLINTEGER nIndicator = 0;
             SQLWCHAR   sColumnValue[MAX_DATA_WIDTH] = L"";
 
-            nReturn = SQLGetData( hStm, nColumn, SQL_C_CHAR, (SQLPOINTER)sColumnValue,
sizeof(sColumnValue), &nIndicator );
+            nReturn = SQLGetData( hStm, nColumn, SQL_C_WCHAR, (SQLPOINTER)sColumnValue,
sizeof(sColumnValue), &nIndicator );
             if ( SQL_SUCCEEDED( nReturn ) && nIndicator != SQL_NULL_DATA )
             {
-//                *pstreamStdOut << QString::fromStdWString( sColumnValue );
-                *pstreamStdOut << sColumnValue;
+                *pstreamStdOut << QString::fromStdWString( sColumnValue );
                 if ( nColumn < nColumns )
                     *pstreamStdOut << cDelimiter;
             }
@@ -858,7 +852,7 @@
                                               &nTextLength )) )
         {
             sState[5] = '\0';
-            *pstreamStdErr << "[" << sState << "]" <<
sMessageText << endl;
+            *pstreamStdErr << "[" << QString::fromStdWString( sState )
<< "]" << QString::fromStdWString( sMessageText ) << endl;
             nRecord++;
         }
     }
@@ -876,7 +870,7 @@
                                              &nTextLength )) )
         {
             sState[5] = '\0';
-            *pstreamStdErr << "[" << sState << "]" <<
sMessageText << endl;
+            *pstreamStdErr << "[" << QString::fromStdWString( sState )
<< "]" << QString::fromStdWString( sMessageText ) << endl;
             nRecord++;
         }
     }
@@ -894,7 +888,7 @@
                                              &nTextLength )) )
         {
             sState[5] = '\0';
-            *pstreamStdErr << "[" << sState << "]" <<
sMessageText << endl;
+            *pstreamStdErr << "[" << QString::fromStdWString( sState )
<< "]" << QString::fromStdWString( sMessageText ) << endl;
             nRecord++;
         }
     }

Modified: MYODBCShell/main.cpp
===================================================================
--- MYODBCShell/main.cpp	2006-04-21 03:45:19 UTC (rev 91)
+++ MYODBCShell/main.cpp	2006-04-21 05:02:45 UTC (rev 92)
@@ -151,24 +151,35 @@
     }
 
     QString stringLine;
-    QString stringCommand;
+    QString stringCommand = QString::null;
 
     do
     {
         if ( !bBatch )
-            *shell.pstreamStdOut << "MYODBCShell> "; 
+        {
+            *shell.pstreamStdOut << "MYODBCShell> ";
+            shell.pstreamStdOut->flush();
+        }
 
+        if ( bBatch && shell.pstreamStdIn->atEnd() )
+            break;
+
         stringLine = shell.pstreamStdIn->readLine();
 
         if ( stringLine.isEmpty() )
         {
-            shell.doCommand( stringCommand );
+            if ( !stringCommand.isEmpty() )
+                shell.doCommand( stringCommand );
             stringCommand = QString::null;
         }
         else if ( stringLine == "quit" )
             break;
         else
-            stringCommand += ( " " + stringLine );
+        {
+            if ( !stringCommand.isEmpty() )
+                stringCommand += '\n';
+            stringCommand += stringLine;
+        }
 
     } while ( 1 );
 

Thread
Connector/ODBC 5 commit: r92 - MYODBCShellpharvey21 Apr