What is error -424 in ESQL/C 
Author Message
 What is error -424 in ESQL/C

Greetings,

        The error message:

sqlca.sqlcode == -424
Cursor already declared from this "prepared" statement.

(It's not listed the error message appendix)

---------------------------------------------------------------------------

        The program:

An ESQL/C program which dynamically executes SQL statements.  The error
occurs after issuing the following pseudo-statements:

< User enters non-scrolling select statement >

        [ $PREPARE query_object from $query_statement ]
        [ $DESCRIBE query_object INTO description ]
        [ get and assign storage to sqlda structure "description" ]
        [ $DECLARE my_cursor CURSOR FOR query_object ]
        [ $OPEN my_cursor ]
        [ $FETCH, parse sqlda, and display rows (in a loop) ]
        [ $CLOSE my_cursor ]
        [ $FREE query_object ]

< User enters scrolling select statement >

        [ $PREPARE query_object from $query_statement ]
        [ $DESCRIBE query_object INTO description ]
        [ get and assign storage to sqlda structure "description" ]
        [ $DECLARE my_cursor SCROLL CURSOR FOR select_statement ]
        [ error -424 ]

---------------------------------------------------------------------------

        The environment:

$ what ${INFORMIXDIR}/bin/esql
        esql    6.11     11/27/89  14:26:58

INFORMIX-SE     Version 4.00.UH1
AT&T 6386/25 WGS running Sys V Rel 3.2

---------------------------------------------------------------------------

        First of all, could someone explain the error message.  Next, is
the problem occurring because of "cursor scope?"  In my ESQL/C course,
the instructor mentioned that cursors are known to all functions in a
single source file.  Looking at the generated code verifys that only one
_SQCURSOR structure (_SQ1) is used throughout the program.  Would breaking
my one source file into several do any good?  As always, thanks for any help.
---



Sat, 15 Oct 1994 06:53:11 GMT
 What is error -424 in ESQL/C

Quote:

>From: uunet!green.att.com!chris (Chris Hardin)
>Date: Mon, 27 Apr 92 18:11 EDT
>Subject: What is error -424 in ESQL/C
>X-Informix-List-Id: <list.1106>

>Error message -424: Cursor already declared from this prepared statement.
>(It's not listed the error message appendix)

        It is listed in the Version 5.00 Error Message manual.

Quote:
>< User enters non-scrolling select statement >
>    [ $PREPARE query_object from $query_statement ]
>    [ $DESCRIBE query_object INTO description ]
>    [ $DECLARE my_cursor CURSOR FOR query_object ]
>    [ $OPEN my_cursor ]
>    [ $FETCH, parse sqlda, and display rows (in a loop) ]
>    [ $CLOSE my_cursor ]
>    [ $FREE query_object ]
>< User enters scrolling select statement >
>    [ $PREPARE query_object from $query_statement ]
>    [ $DESCRIBE query_object INTO description ]
>    [ $DECLARE my_cursor SCROLL CURSOR FOR select_statement ]
>    [ error -424 ]
>The environment: INFORMIX-SE        Version 4.00.UH1
>First of all, could someone explain the error message.

The 5.00 manual says, by way of explanation:

This DECLARE statement associates a cursor with the name of a prepared
statement.  However, another DECLARE statement has already been executed,
associating a different cursor with the same statement ID.  This is not
supported; a given statement may be associated with only one cursor.  Check
all the DECLARE statements in the program and make sure they all refer to
unique statements.

The reason behind this (not in the book of words) is that when you FREE
something, if it is a cursor declared on a prepared statement, you free the
statement id, not the cursor id.  If, instead, you said "DECLARE c CURSOR
FOR SELECT ...", then (and only then) would you free the cursor name.  And
if two cursors were allowed on one statement id, then freeing the first
cursor would wreck the second.  Note that I am merely stating why; I am not
actually justifying it (because it would not be all that hard to keep a
reference count for the statement id and only release the statement when
the reference count drops to zero).

Yours sincerely,



Sun, 16 Oct 1994 00:18:07 GMT
 What is error -424 in ESQL/C

Quote:
>Date: Tue, 28 Apr 92 13:42:16 -0400

>Subject: Re:  What is error -424 in ESQL/C

> ...

>Is there any way to free the cursor name when dynamically executing
>SQL statements (using prepare, describe, and declare)?  What exactly
>happens when a cursor is closed and a sqlda structure freed?  What
>would happen if I freed a cursor that has been prepared? (The Version
>4.00 book expressly forbids this)

The FREE I am referring to is "EXEC SQL FREE cursor_id;" or "$FREE
cursor_id;", not your casual free() as in malloc and friends.  There
are several possible scenarios to consider:

Scenario A:
        EXEC SQL DECLARE c_scenario_a CURSOR FOR SELECT A FROM B;
After using OPEN, FETCH and CLOSE on this, you can use:
        EXEC SQL FREE c_scenario_a;
This will release any temporary resource associated with this cursor
in both the Engine and the front end interface code.

Scenario B:
        EXEC SQL PREPARE s_scenario_b FROM "SELECT * FROM Sysindexes";
        EXEC SQL DESCRIBE s_scenario_b INTO sqlda;
        EXEC SQL DECLARE c_scenario_b CURSOR FOR s_scenario_b;
After fixing up sqlda and using OPEN, FETCH, CLOSE, you can use:
        EXEC SQL FREE s_scenario_b;
After you have freed any memory allocated when fixing up sqlda, you
can also use:
        free(sqlda);

Scenario C:  !!!BUGGY CODE!!!
        EXEC SQL PREPARE s_scenario_c FROM "SELECT * FROM Sysindexes";
        EXEC SQL DESCRIBE s_scenario_c INTO sqlda;
        EXEC SQL DECLARE c_scenario_c CURSOR FOR s_scenario_c;
After fixing up sqlda and using OPEN, FETCH, CLOSE, you then
mistakenly use:
        EXEC SQL FREE c_scenario_c;
At this point, the system is apt to get its memory allocation in a
mess.  Probably, but by no means certainly, most of the temporary info
to do with statement s_scenario_c is probably not released.  However,
it is a fair bet that subsequently executing:
        EXEC SQL FREE s_scenario_c;
would lead to worse trouble -- probably re-releasing space that is
already released, and leading to havoc in the memory allocation
system.  That is why you are strongly discouraged from making the
mistake.

In Scenario A, there is no explicit statement ID to release, so you
must release the cursor ID; in Scenarios B and C, you should release
the statement ID, not the cursor ID.

All the above applies to Version 4.10 and earlier.  With Version 5.0,
things are slightly more complicated again.  The basics remain the
same (so all the above remains accurate), but there are additional
features for playing with descriptors in the language.  These are GET
DESCRIPTOR, SET DESCRIPTOR, ALLOCATE DESCRIPTOR, and DEALLOCATE
DESCRIPTOR.  I can't give a useful explanation of these -- I haven't
worked it out yet (mainly lack of time).  Additionally, you can use
character string variables in place of the statement and cursor IDs
used above.

Yours,



Sun, 16 Oct 1994 20:23:11 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Very newbie problem with Object Error (Error 424)

2. Error Starting application executable (error 424 - Object required)

3. 424 error error_hservice

4. Error 424 - Object Required

5. Error RC 424 Object Required message when trying to Connect via ASP

6. Run time error 424 - object required!

7. Run time error 424 - object required!

8. Run time error 424 Object Required

9. Run-time error '424'

10. Run-time error '424' Object Require

11. PRB: error 424 Object Required

12. 424 Object Required Error


 
Powered by phpBB® Forum Software