Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: A newbie question regarding cursors
cursors are global to a source code file -- they are not lexically parsed or
scope with C.
The cursor is known everywhere in that source file from the point of its declaration till the end of the code. As long as you have the functions in the order you have them below, it will work (of course prepare_sql is a much larger subroutine then you have in the psuedo code below as it will allocate the sqlda and all other memory...)
A copy of this was sent to "peckle" <peckle_at_pacific.net.sg> (if that email address didn't require changing) On 20 Jul 1998 10:09:26 GMT, you wrote:
>Hi!
>
>I'm a newbie who need to write some codes in C++ with dynamic SQL.
>I have to do the following in my program :
>
>.....// fill the sql_statement.....
>.....
>EXEC SQL PREPARE S FROM :sql_statement;
>EXEC SQL DECLARE C CURSOR FOR S;
>EXEC SQL OPEN C;
>.....//prepare the descriptor select_dp
>.....
>EXEC SQL FOR :array_size FETCH C USING DESCRIPTOR select_dp;
>EXEC SQL CLOSE C;
>......
>
>I HAVE TO separate the codes into a few function for some reasons :
>eg.
>void prepare_sql()
>{
> EXEC SQL PREPARE S FROM :sql_statement;
> EXEC SQL DECLARE C CURSOR FOR S;
> EXEC SQL OPEN C;
>}
>
>void fetch_data()
>{
> EXEC SQL FOR :array_size FETCH C USING DESCRIPTOR select_dp;
>}
>
>Question: How do I declare the cursor such that it would not be
>out-of-scope after the prepare_sql() function.
>
>Any help will be much appreciated.
>Thank-you in advance.
>Peck Leng
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA
http://govt.us.oracle.com/ -- downloadable utilities
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Mon Jul 20 1998 - 10:11:21 CDT
![]() |
![]() |