3 Replies Latest reply on May 29, 2014 10:14 AM by TSGal

    ODBC driver incorrectly returns error when SQLFreeStmt with SQL_CLOSE called more than once

    barefootguru

      Summary

      ODBC driver incorrectly returns error when SQLFreeStmt with SQL_CLOSE called more than once

      Product

      FileMaker Server

      Version

      12.0v3

      Operating system version

      Windows Server 2008 R2 Enterprise SP1

      Description of the issue

      When calling SQLFreeStmt with the SQL_CLOSE option more than once, the driver is returning an error.  According to the MS ODBC API that is a driver bug.

      This causes SAS to report an error when retrieving ODBC data, even though the pull is successful.

      Steps to reproduce the problem

      Development captured an ODBC trace to investigate why we see an ERROR in the SAS log when everything appears to have run successful:
      "...
      ODBC: Exit duget, rc = X_WEOF, table is onlynumeric, statement 1, connection 0
      ACCESS ENGINE:  Enter yoeclos
      ODBC: Enter dugett, table is onlynumeric, statement 1, connection 0
      ODBC: ENTER SQLFreeStmt
                  0x025b15f8
                           0
      ODBC: EXIT SQLFreeStmt with return code 0 (SQL_SUCCESS)
                  0x025b15f8
                           0
      ODBC: Close cursor from statement 1 on connection 0
      ODBC: Exit dugett, rc = SUCCESS
      ODBC: Enter dudesct, table is onlynumeric, statement 1, connection 0
      ODBC: ENTER SQLFreeStmt
                  0x025b15f8
                           0
      ODBC: EXIT SQLFreeStmt with return code -1 (SQL_ERROR)
                  0x025b15f8
                           0
      ODBC: Exit du, rc = DBU_CLOSERR
      ACCESS ENGINE: Exit yoeclos with rc=0x8012780b
      ERROR: CLI close cursor error: [FileMaker][FileMaker] No cursor open for statement
      ..."

      Basically, we are calling SQLFreeStmt with the SQL_CLOSE option more than once and the driver is returning an error.  According to the MS ODBC API that is a driver bug.

      http://msdn.microsoft.com/en-us/library/ms709284(v=vs.85).aspx

      StatementHandle
      [Input] Statement handle
      Option
      [Input] One of the following options:
      SQL_ CLOSE: Closes the cursor associated with StatementHandle (if one was defined) and discards all pending results. The application can reopen this cursor later by executing a SELECT statement again with the same or different parameter values. If no cursor is open, this option has no effect for the application.

      Configuration information

      Workstation used to pull ODBC data is:

      Windows 7 64-bit with 64-bit SAS 9.3 T1M2 and 64-bit FileMaker Pro ODBC driver 12.0.103.00

        • 1. Re: ODBC driver incorrectly returns error when SQLFreeStmt with SQL_CLOSE called more than once
          barefootguru

               The above applies to the 32-bit ODBC driver, not the 64-bit one.

                

               (The 64-bit driver doesn't work at all:  http://forums.filemaker.com/posts/1aebf59f35)

          • 2. Re: ODBC driver incorrectly returns error when SQLFreeStmt with SQL_CLOSE called more than once
            NickNick

                 i had a similar problem whe i had tried to connect with php and sql statements (dynamic sql) to a filemaker server advanced 12v3  file

                 the system is a 32 bit server, like the client, my pc, when i have the filemaker odbc driver)

                 and opened this issue:

                 http://forums.filemaker.com/posts/9798844217 MORE THAN SIX MONTHS AGO

                 Sincerely it's a shame that nobody tried to explain something and help me to solve the problem, infact the only feedback i had is a question about a kind of filemaker server because i've forget to write advanced.

                 Now i explain another time: is filemaker server advanced 12v3, the php connection with microsoft classes is ok if i use the PURE SQL without statement, but because is impossible to make a application without use SQL STATEMENT (to avoid sql injection, SQL parametrized with field dynamic like query for login and passowrd account and other, for instance) i necessarily need to use that.

                 but when i try to write something like this:

                 Description of the issue:

                 I've tried to use php odbc to connect to filemaker database
                 with the following piece of code:

                 $server = <ipServer>;
                 $database = "<dbName";
                 $user = "<user>";
                 $password = "<password>";

                 $connection = odbc_connect("Driver=FileMaker ODBC;Server=$server;Database=$database;", $user, $password);
                 $sql = "SELECT <FIELDS> FROM <TABLE> WHERE <FIELD> = ?";

                 $cond = <conditionValue>;

                 $statement = odbc_prepare($connection, $sql);

                 if(!$statement) {
                 die("could not prepare statement ".$statement);
                 }
                 $resultSet = odbc_execute($statement, array($cond));

                 odbc_close($connection);

                 but this row:
                 $resultSet = odbc_execute($statement, array($cond));

                 give the following error:

                 Warning: odbc_execute() [function.odbc-execute]: SQL error: [FileMaker][FileMaker] No cursor open for statement, SQL state HY000 in SQLFreeStmt in test.php

                 and like the case above IS A PROBLEM OF FILEMAKER DRIVER; i tried to install the driver ODBC of filemaker 13 but i have had exactly the same problem.

                 i have seen the code in this site:

                 http://pr-web-01.qatar.cmu.edu/src/php-5.2.6/ext/odbc/php_odbc.c

                 and saw that the problem was connected with this instruction:
                 /* Close cursor, needed for doing multiple selects */
                 rc = SQLFreeStmt(result->stmt, SQL_CLOSE);

                 like, not be surprised about this, the problem of this issues.

                 For another time:
                 Could you help me to solve?

                  

                  

            • 3. Re: ODBC driver incorrectly returns error when SQLFreeStmt with SQL_CLOSE called more than once
              TSGal

                   Nick Nick:

                   I have responded to your original post, and all future responses will continue to occur at:

              FileMaker Server

                   TSGal
                   FileMaker, Inc.