Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

pro c variable declation question

bubblefishMay 14 2013 — edited May 15 2013
Hello all,

Lucky me, I get to work with some Pro*C code written in 1998 on Unix. I consider myself C-knowledgeable but am faced with pre-Ansi C with embedded SQL syntax, written by folks who were not comfortable with parameter passing.

Here is my dilema: I am uncertain about the scope of variable declared within EXEC SQL BEGIN DECLARE SECTION.
The code has the following ,as example:

// global section, occurring before main:
EXEC SQL BEGIN DECLARE SECTION;
varchar foo(10);
EXEC SQL END DECLARE SECTION;

main ()
{
gag( foo );
}


Then later there is a procedure, declared with pre-Ansi syntax:

void gag( foo )
EXEC SQL BEGIN DECLARE SECTION;
varchar foo(10);
EXEC SQL END DECLARE SECTION;
{ // open curly beginning procedure gag()

foo :=some Value;
}

Questions:
** Is the 2nd foo (declared as parameter to gag() ) still a local variable to gag()? I thought I'd read somewhere that the scope of variables declared within EXEC SQL BEGIN DECLARE/END DECLARE was global...

They are not passing any pointers, but it 'appears' that foo may change in the calling program (though the code is so ugly it's hard to discern for sure).

** Can you pass varchar as a pointer, or do I have to pass the (char*) after null-terminating it ? ie:
void gag (varchar* foo)

How the heck were they able to change vaues (unless it was global, of which there are LOTS of in this code).

Thank you!
This post has been answered by davidp 2 on May 14 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2013
Added on May 14 2013
4 comments
627 views