Problem using ct_sql with websql

Problem using ct_sql with websql

Post by Phill Edward » Fri, 24 Apr 1998 04:00:00



I have writen a websql script (pinching lots from the Sybase docco) which
calls a stored procedure which returns 0, 1 or more rows.

I call the store procedure like this :

  if (($rc = ct_sql( $ws_db, "exec schema..getDailyMaxStatistics
\"$dateFrom\",\"$dateTo\"" ) ) != CS_SUCCEED)
      {
      ws_error ("Unable to process database request.");
      }

Then I process the results like this :
  while (($ret = ct_results($ws_db, $result_type)) == CS_SUCCEED)
      {
      # Equivalent of switch statement in Perl.
      RESULTS: {

          # Check CS_CMD_DONE
          # Check CS_CMD_FAIL
          # Check CS_ROW_RESULT
  etc etc

I get an error message which says "! Open Client Error: 163 (Layer 1, Origin
1, Severity 1) ct_results(): user api layer: external error: This routine
cannot be called until all fetchable results have been completely
processed".

Does anyone know what I am doing wrong here? UI'd really appreciate somem
help on this one because I've been through the manuals and am using the code
provided in them.

Any help much appreciated.
Thanks,
-- Phill Edwards --

 
 
 

Problem using ct_sql with websql

Post by Michael Pepple » Fri, 24 Apr 1998 04:00:00



> I have writen a websql script (pinching lots from the Sybase docco) which
> calls a stored procedure which returns 0, 1 or more rows.

> I call the store procedure like this :

>   if (($rc = ct_sql( $ws_db, "exec schema..getDailyMaxStatistics
> \"$dateFrom\",\"$dateTo\"" ) ) != CS_SUCCEED)
>       {
>       ws_error ("Unable to process database request.");
>       }

> Then I process the results like this :
>   while (($ret = ct_results($ws_db, $result_type)) == CS_SUCCEED)
>       {
>       # Equivalent of switch statement in Perl.
>       RESULTS: {

>           # Check CS_CMD_DONE
>           # Check CS_CMD_FAIL
>           # Check CS_ROW_RESULT
>   etc etc

> I get an error message which says "! Open Client Error: 163 (Layer 1, Origin
> 1, Severity 1) ct_results(): user api layer: external error: This routine
> cannot be called until all fetchable results have been completely
> processed".

You're clearly not fetching all the result rows. In particular, you're
probably not fetching the result status (CS_STATUS_RESULT) of the stored
proc. The following
$result_type values have fetchable results:

CS_ROW_RESULT,
CS_PARAM_RESULT,
CS_STATUS_RESULT,
CS_CURSOR_RESULT,
CS_COMPUTE_RESULT

So check for each of these and call ct_fetch() to process all returned
rows.

Michael
--
Michael Peppler         -||-  Data Migrations Inc.

Int. Sybase User Group  -||-  http://www.isug.com

 
 
 

1. Websql Problem with returning data

I am working with WebSql and I am having the following problem.
I am expecting the results to be returned within the browser but instead
it tries to print our the perl script. If I comment out the  block of
code marked with '#' then it return the data in the browser. Could
anyone tell me why this block is causing it to try to save the file to
the disk.

The code is

   $rc = ct_sql($ws_db, "$procedure");
   if ($rc != CS_SUCCEED) {ws_error("ct_sql() failed");}

   while ($ret=ct_results($ws_db, $result_type) == CS_SUCCEED)
        {
        if ($result_type == CS_ROW_RESULT)
           {
                print "<TABLE BORDER>\n";

                {

                   elseif (result_type == CS_STATUS_RESULT)
                   {
#                     $status = ct_fetch ($ws_db);
#                     ct_fetch ($ws_db);
#                  }
#                  else {
#                     ws_error ("Unexpected result type returned from SQL"); }
                   }
                print "</TABLE>\n";
           }
        }
print qq!

   </BODY>
   </HTML>
   !;
  }

2. Can ADO modify a saved query?

3. Websql security problems

4. Still problems with pg_dump ad \dt...

5. websql installation problems

6. Is there any simple way ?

7. A sybperl question reguarding ct_sql()

8. Is it nessesary to run instcat script on a 6.5 to have a Linked Server from 7.0?

9. return code of ct_results and ct_sql

10. How to handle dead DBPROCESS in Sybperl (ct_sql)

11. webSQL with NSAPI?

12. WebSQL support for Apache/Stronghold