Re: esql/c
Posted in 1992
Topics: Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL
In article 3081@fripp.ri.cadre.com, jh@cadre.com (Joe Hartley) writes:
>In article 6418@advtech.uswest.com, yslas@earpuswest.com ( Rob Yslas) writes:
>>I've just begun using esql/c and am having a problem writing to an output values
>>retrived from a cursor. I am running 4.10 on a sun fileserver.
>>
>>Here is what I'm doing. (I can get output but they are not characters
>>that exist in the db and not what I expected.)
>>
>
>What is probably happening is that one of the SQL statements is failing, but
>you are not testing for an error condition. One of the components of the
>sqlca data structure (defined by $include sqlca;) is sqlca.sqlcode. This
>variable will contain the error code of the last SQL statement executed.
>Note that the code for a successful execution is zero!
>You should modify your code to look something like this:
>
>
>$include sqlca;
>
>$char x[10];
>$char y[15];
>$char z[11];
>
>$declare foo_curs cursor for
> select x,y,z
> into $x,$y,$z
> from foo_table
> where "conditions exist"
> order by x,z;>
>$open foo_curs;
> if (sqlca.sqlcode != 0)
> {
> printf("Error %d opening cursor\\n", sqlca.sqlcode);
> exit;
> }
>$fetch foo_curs;
> if (sqlca.sqlcode != 0)
> {
> printf("Error %d on initial fetch\\n", sqlca.sqlcode);
> exit;
> }
>
>/* while (sqlca.sqlcode) This is wrong! it should be (!sqlca.sqlcode) */
> /* In fact, I tend to use (sqlca.sqlcode != 0) for clarity */
>
>while (sqlca.sqlcode != 0)
^^
*** I think you mean "==" here, meaning the fetch got a row. Right? ***
>{
> printf("%-10s %-15s %-11s \\n", x,y,z);
> fetch foo_curs;
> if (sqlca.sqlcode != 0)
> {
> printf("Error %d on fetch\\n", sqlca.sqlcode);
> exit;
> }
>}
>$close foo_curs;
>
>
>>
>>Can anyone shed any light on this for me. Sorry if it is a novice question but
>>I have been unable to find an answer.
>
>This won't fix anything, but it will tell you what's going wrong.
>
>===============================================================================
>Joe Hartley | jh@cadre.com - Whenever you find that you are on the
>Cadre Technologies | side of the majority, it is time to reform. - M. Twain
>222 Richmond St. | --------------------------------------------------------
>Providence, RI 02903 | Overman 1st Class - the Kilgore Trout Memorial Clench
>(401) 351-5950 x266 | of the Church of the SubGenius
>===============================================================================
---
--
Jerry Pope
Ext 6196
Bldg 4100, Floor 2