Handle Procedure calls.
authorHiroshi Inoue
Wed, 27 Jun 2001 07:38:07 +0000 (07:38 +0000)
committerHiroshi Inoue
Wed, 27 Jun 2001 07:38:07 +0000 (07:38 +0000)
Now the version is 7.01.0006.

src/interfaces/odbc/convert.c
src/interfaces/odbc/info.c
src/interfaces/odbc/psqlodbc.h
src/interfaces/odbc/psqlodbc.rc
src/interfaces/odbc/statement.c
src/interfaces/odbc/statement.h

index 09c6ca81f558a0affde9a8aaf91aed3ad1cc13e5..69d3043b9527e2cb3b56d187cba7d70cbcea60f1 100644 (file)
@@ -1056,7 +1056,30 @@ copy_statement_with_parameters(StatementClass *stmt)
 
            if (!end)
                continue;
-
+           /* procedure calls */
+           if (stmt->statement_type == STMT_TYPE_PROCCALL)
+           {
+               while (isspace((unsigned char) old_statement[++opos]));
+               if (old_statement[opos] == '?')
+               {
+                   param_number++;
+                   while (isspace((unsigned char) old_statement[++opos]));
+                   if (old_statement[opos] != '=')
+                   {
+                       opos--;
+                       continue;
+                   }
+                   while (isspace((unsigned char) old_statement[++opos]));
+               }
+               if (strnicmp(&old_statement[opos], "call", 4))
+               {
+                   opos--;
+                   continue;
+               }
+               opos += (4 - 1);
+               CVT_APPEND_STR("SELECT");
+               continue; 
+           }
            *end = '\0';
 
            esc = convert_escape(begin);
@@ -1075,6 +1098,9 @@ copy_statement_with_parameters(StatementClass *stmt)
            *end = '}';
            continue;
        }
+       /* End of a procedure call */
+       else if (oldchar == '}' && stmt->statement_type == STMT_TYPE_PROCCALL)
+           continue;
 
        /*
         * Can you have parameter markers inside of quotes?  I dont think
index 39a0a49a9889e31bcb409335c8aaddcc3cc4d5a2..a18778ceddbc6b800ece3c340304171dfee31b5d 100644 (file)
@@ -802,7 +802,7 @@ SQLGetFunctions(
 {
    static char *func = "SQLGetFunctions";
 
-   mylog("%s: entering...\n", func);
+   mylog("%s: entering...%u\n", func);
 
    if (fFunction == SQL_API_ALL_FUNCTIONS)
    {
index c14b32045bfaa9d275dc6d1e7728b9b2f2155e01..156ec458c2d4374c3403e1386294008cb92ca29f 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Comments:       See "notice.txt" for copyright and license information.
  *
- * $Id: psqlodbc.h,v 1.43 2001/05/17 02:56:37 inoue Exp $
+ * $Id: psqlodbc.h,v 1.44 2001/06/27 07:38:07 inoue Exp $
  *
  */
 
@@ -42,7 +42,7 @@ typedef UInt4 Oid;
 #define DRIVERNAME                 "PostgreSQL ODBC"
 #define DBMS_NAME                  "PostgreSQL"
 
-#define POSTGRESDRIVERVERSION      "07.01.0005"
+#define POSTGRESDRIVERVERSION      "07.01.0006"
 
 #ifdef WIN32
 #define DRIVER_FILE_NAME           "PSQLODBC.DLL"
index 6f42f402da68dd0d37da4395eac0600827fc5739..85bfcdb2893749b4c8b357b8b1e23b5a7835ae46 100644 (file)
@@ -342,8 +342,8 @@ END
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 7,1,0,5
- PRODUCTVERSION 7,1,0,5
+ FILEVERSION 7,1,0,6
+ PRODUCTVERSION 7,1,0,6
  FILEFLAGSMASK 0x3L
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -365,14 +365,14 @@ BEGIN
             VALUE "CompanyName", "Insight Distribution Systems\0"
 #endif
             VALUE "FileDescription", "PostgreSQL Driver\0"
-            VALUE "FileVersion", " 07.01.0005\0"
+            VALUE "FileVersion", " 07.01.0006\0"
             VALUE "InternalName", "psqlodbc\0"
             VALUE "LegalCopyright", "\0"
             VALUE "LegalTrademarks", "ODBC(TM) is a trademark of Microsoft Corporation.  Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation.\0"
             VALUE "OriginalFilename", "psqlodbc.dll\0"
             VALUE "PrivateBuild", "\0"
             VALUE "ProductName", "Microsoft Open Database Connectivity\0"
-            VALUE "ProductVersion", " 07.01.0005\0"
+            VALUE "ProductVersion", " 07.01.0006\0"
             VALUE "SpecialBuild", "\0"
         END
     END
index 473d570988001e251ee911aa16fbdf81624cca08..165700dc09d12371bb832a84ff54eb15621f1a40 100644 (file)
@@ -81,6 +81,9 @@ static struct
    {
        STMT_TYPE_REVOKE, "REVOKE"
    },
+   {
+       STMT_TYPE_PROCCALL, "{"
+   },
    {
        0, NULL
    }
@@ -1054,6 +1057,31 @@ SC_execute(StatementClass *self)
            CC_abort(conn);
    }
 
+   if (self->statement_type == STMT_TYPE_PROCCALL &&
+       (self->errornumber == STMT_OK ||
+        self->errornumber == STMT_INFO_ONLY) &&
+       self->parameters &&
+       self->parameters[0].buflen > 0 &&
+       self->parameters[0].paramType == SQL_PARAM_OUTPUT)
+   {   /* get the return value of the procedure call */
+       RETCODE ret;
+       HSTMT hstmt = (HSTMT) self;
+       ret = SQLBindCol(hstmt, 1, self->parameters[0].CType, self->parameters[0].buffer, self->parameters[0].buflen, self->parameters[0].used);
+       if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) 
+           SC_fetch(hstmt);
+       else
+       {
+           self->errornumber = STMT_EXEC_ERROR;
+           self->errormsg = "BindCol to Procedure return failed.";
+       }
+       if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) 
+           SQLBindCol(hstmt, 1, self->parameters[0].CType, NULL, 0, NULL);
+       else
+       {
+           self->errornumber = STMT_EXEC_ERROR;
+           self->errormsg = "SC_fetch to get a Procedure return failed.";
+       }
+   }
    if (self->errornumber == STMT_OK)
        return SQL_SUCCESS;
    else if (self->errornumber == STMT_INFO_ONLY)
index 3f2fef5db7dfe321e4c04540f60fd62321e120f5..f27c4cc138d0f749f0e67c22928edf188eba8a99 100644 (file)
@@ -98,6 +98,7 @@ enum
    STMT_TYPE_DROP,
    STMT_TYPE_GRANT,
    STMT_TYPE_REVOKE,
+   STMT_TYPE_PROCCALL
 };
 
 #define STMT_UPDATE(stmt)  (stmt->statement_type > STMT_TYPE_SELECT)