Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Scope of EXEC SQL DECLARE <cursor>

Scope of EXEC SQL DECLARE <cursor>

From: Alex Vinokur <alexander.vinokur_at_telrad.co.il>
Date: Tue, 26 Oct 1999 11:24:38 GMT
Message-ID: <7v431l$qnj$1@nnrp1.deja.com>


Hi,

Here is a program containing the same line

        EXEC SQL DECLARE the_cursor CURSOR FOR the_exec; in two different functions (foo1 and foo2). I have got warning message (see below).

Does it mean that EXEC SQL DECLARE <cursor>

        always has global scope?
If it is right, what is a reason for that? (Does it depend on SQL scope?)
Ordinary internal variables have a local scope.

Do we have to use different names in

        EXEC SQL DECLARE <cursor>
        even if these declarations
        are in different functions?
If EXEC SQL DECLARE <cursor> has a global scope,
        why is the message warning one,
        but not error one?

        Thanks,
        Alex


//#########################################################
//------------------- Pro*C++ code : BEGIN ----------------

//==========================

#include <stdio.h>

#include <sqlca.h>
#include <sqlda.h>
#include <sqlcpr.h>
#include <oraca.h>

//==========================


//###############################
//###############################

class FOO
{
        private :
        public :
                void foo1 ();
                void foo2 ();

};
//###############################
//===============================

void FOO::foo1()
{
EXEC SQL BEGIN DECLARE SECTION;
const char *host_command_line = "DUMMY"; EXEC SQL END DECLARE SECTION;
        EXEC SQL PREPARE the_exec FROM :host_command_line;
        EXEC SQL DECLARE the_cursor CURSOR FOR the_exec;

} // void FOO::foo1()

//===============================

void FOO::foo2()
{
EXEC SQL BEGIN DECLARE SECTION;
const char *host_command_line = "DUMMY"; EXEC SQL END DECLARE SECTION;
        EXEC SQL PREPARE the_exec FROM :host_command_line;
        EXEC SQL DECLARE the_cursor CURSOR FOR the_exec; // Line#43

} // void FOO::foo2()

//###############################
//===============================

int main ()
{

        return 0;
}

//------------------- Pro*C++ code : END ------------------



//#########################################################
//------------------- Compilation Results : BEGIN --------- code=cpp
sys_include=(/opt/SUNWspro/SC4.2/include,/opt/SUNWspro/SC4.2/include/CC,/usr/
include,/opt/SUNWspro/RW/workspaces/SOLARIS26/SUNPRO42/7s) code=cpp
sys_include=(/opt/SUNWspro/SC4.2/include,/opt/SUNWspro/SC4.2/include/CC,/usr/ include,/opt/SUNWspro/RW/workspaces/SOLARIS26/SUNPRO42/7s) proc code=cpp sys_include='(/opt/SUNWspro/SC4.2/include,/opt/SUNWspro/SC4.2/include/CC,/usr /include,/opt/SUNWspro/RW/workspaces/SOLARIS26/SUNPRO42/7s)' iname=ntt MODE=ORACLE LINES=YES CPP_SUFFIX=cpp CHAR_MAP=STRING

Pro*C/C++: Release 8.0.5.0.0 - Production on Tue Oct 26 12:48:2 1999

(c) Copyright 1998 Oracle Corporation. All rights reserved.

System default option values taken from: /home/u01/app/oracle/product/8.0.5/precomp/admin/pcscfg.cfg

Warning at line 43, column 19, file ntt.pc:

        EXEC SQL DECLARE the_cursor CURSOR FOR the_exec;

..................1

PCC-W-02332, attempted to redefine SQL identifier

[snip]

//------------------- Compilation Results : END -----------


//#########################################################
//------------------- Environment -------------------------

=== Oracle 8.0.5
=== Pro*C/C++ : Release 8.0.5.0.0

=== CC: WorkShop Compilers 4.2 30 Oct 1996 C++ 4.2 === SunOS 5.6
//---------------------------------------------------------

//#########################################################



Sent via Deja.com http://www.deja.com/
Before you buy. Received on Tue Oct 26 1999 - 06:24:38 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US