SQLExecute and SQLExecDirect cause process to hang

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf SQLExecute and SQLExecDirect cause process to hang

  • Creator
    Topic
  • #52062
    Chak Kwok Yin
    Participant

    Hi

    I’m now on Solaris 10 with Cloverleaf 5.6 Rev2. I’ve port over the same TCL scripts which are running fine on Windows 2003 sp1 with Cloverleaf 5.3. This TCL basically calls a store procedure in Microsoft SQL 2005 to fetch a field back. The process would run for a day and then hang.

    pstack shows after executing  7aeba950 SQLExecDirect (12529348, 1251d698, fffffffd, 7b14e79d, 400, 630) + 104 then it stuck there waiting for completion.

    After viewing this forum, some suggested SQLExecute would be less of a performance issue, and I tried this but the process still hangs. The CPU usage for this process would goes 12% when this happens.

    I sincerely hope that someone would have a solution for this as I’m going nowhere with this problem. Thank you for your time.

    Regards,

    Chak

    Here is my TCL;

    ###Import ODBC3.DLL Package at quovadxqdx5.2integratorbin

    package require odbc        

    odbc SQLAllocHandle SQL_HANDLE_ENV SQL_NULL_HANDLE henv

    odbc SQLSetEnvAttr $henv SQL_ATTR_ODBC_VERSION SQL_OV_ODBC3 0

    odbc SQLAllocHandle SQL_HANDLE_DBC $henv hdbc

    ###System DSN config: DSN Name,UID,Pwd

    set gUID “xxxx”

    set password “xxxx”

    set server “SQL Server Wire Protocol”

    set Response [odbc SQLConnect $hdbc $server SQL_NTS $gUID SQL_NTS $password SQL_NTS]

    echo “RESPONSE: $Response”

    #Check final connection status

    if {[cequal $Response “SQL_ERROR”] } {

                   set succInd “FAIL”

    } else {

                   set succInd “SUCCESS”

    }

    if { [cequal $succInd “FAIL”] } {

                   return “{OVER $msgId}”

    } else {

          set sqlStmt “”

          ## allocate a handle for the SQL statement

           set errno [catch {odbc SQLAllocHandle SQL_HANDLE_STMT $hdbc hstmt} result]

           echo $result

        # prepare an fetch statement with 1 parameter markers

           set sqlStmt “exec dbo.sp_getcheckdigit $CaseNo”

           odbc SQLPrepare $hstmt $sqlStmt SQL_NTS

       ###set for single statement for execution

        set errno [catch {odbc SQLSetStmtAttr $hstmt SQL_ATTR_PARAMSET_SIZE 1 0} result]

        echo “stntAttr: $result”

        ## execute the query

       #set errno [catch { odbc SQLExecDirect $hstmt $sqlStmt SQL_NTS } result]

        set errno [catch { odbc SQLExecute $hstmt } result]

        set errno [odbc SQLExecute $hstmt]

        #echo “SQLExecute: $result $errno”  

         ## bind the data

         set errno [catch { odbc SQLBindCol $hstmt 1 SQL_C_CHAR CheckDigit 2 CheckDigitLength } result]

        echo “Binding Column ” $result

     

          ## fetch the data

          set errno [catch { odbc SQLFetch $hstmt } result]

          if {![cequal $result “SQL_NO_DATA_FOUND”] } {

    echo $CaseNo

    set DBcheckdigit $CheckDigit        

          }

                                                 

          ##Free resources

          odbc SQLFreeHandle SQL_HANDLE_STMT $hstmt

          odbc SQLDisconnect $hdbc

          odbc SQLFreeHandle SQL_HANDLE_DBC $hdbc

          odbc SQLFreeHandle SQL_HANDLE_ENV $henv

Viewing 2 reply threads
  • Author
    Replies
    • #72915
      garry r fisher
      Participant

      Hi Chak,

      I spent weeks trying to get stored procedures to work on Solaris when they worked without issue on Windows.

      I actually do it a different way to you. This example code has 4 inputs and 7 outputs – So 11 parameters in all. This is how I set it up and run it.

      I’m sure there are many other ways of doing this and this method may not suit you but this does work.

      Regards

      Garry

      # Inputs

        set bReturn [odbc SQLBindParameter $hstmt 1 SQL_PARAM_INPUT SQL_CHAR SQL_CHAR 32 0 dobi 100 NULL]

        set bReturn [odbc SQLBindParameter $hstmt 2 SQL_PARAM_INPUT SQL_C_VARCHAR SQL_VARCHAR 32 0 surn 100 NULL]

        set bReturn [odbc SQLBindParameter $hstmt 3 SQL_PARAM_INPUT SQL_C_VARCHAR SQL_VARCHAR 32 0 fore 100 NULL]

        set bReturn [odbc SQLBindParameter $hstmt 4 SQL_PARAM_INPUT SQL_C_VARCHAR SQL_VARCHAR 32 0 achi 100 NULL]

      # Outputs

        set bReturn [odbc SQLBindParameter $hstmt 5 SQL_PARAM_OUTPUT SQL_CHAR SQL_CHAR 32 0 numb 300 NULL]

        set bReturn [odbc SQLBindParameter $hstmt 6 SQL_PARAM_OUTPUT SQL_C_CHAR SQL_VARCHAR 300 0 res1 300 NULL]

        set bReturn [odbc SQLBindParameter $hstmt 7 SQL_PARAM_OUTPUT SQL_C_CHAR SQL_VARCHAR 300 0 res2 300 NULL]

        set bReturn [odbc SQLBindParameter $hstmt 8 SQL_PARAM_OUTPUT SQL_C_CHAR SQL_VARCHAR 300 0 res3 300 NULL]

        set bReturn [odbc SQLBindParameter $hstmt 9 SQL_PARAM_OUTPUT SQL_C_CHAR SQL_VARCHAR 300 0 res4 300 NULL]

        set bReturn [odbc SQLBindParameter $hstmt 10 SQL_PARAM_OUTPUT SQL_C_CHAR SQL_VARCHAR 300 0 res5 300 NULL]

        set bReturn [odbc SQLBindParameter $hstmt 11 SQL_PARAM_OUTPUT SQL_C_CHAR SQL_VARCHAR 300 0 res6 300 NULL]

      # Values

        set dobi 21071981

        set surn GOLF

        set fore CHRISTOPHER

        set achi none

      # Setup SP Call

        set SQLCmd “begin clinicom.ict_chi_search.get_by_dsf(?,?,?,?,?,?,?,?,?,?,?); end;”

       

        set err [odbc SQLPrepare $hstmt $SQLCmd SQL_NTS]

        echo $err Prepare

        set err [odbc SQLExecute $hstmt]

        echo $err Execute

    • #72916
      Chak Kwok Yin
      Participant

      Hi Garry

      Is allocating input and output parameters important as this is what is missing from my tcl. Also, I’m not familiar with this type of store procedure, can you break this syntax for me?

      clinicom =

      ict_chi_search =

      get_by_dsf =

      # Setup SP Call

      set SQLCmd “begin clinicom.ict_chi_search.get_by_dsf(?,?,?,?,?,?,?,?,?,?,?); end;”

    • #72917
      garry r fisher
      Participant

      Hi,

      A third party wrote and provided the stored procedures I just plugged in to what  they gave me.

      I was just trying to give another example of how to call stored procedures – If you try your SP name and set up the parameters does it work.

      get_by_dsf is the actual SP name, I think the rest refers to a library path of some kind.

      Regards

      Garry

Viewing 2 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,293
Replies
34,435
Topic Tags
286
Empty Topic Tags
10