pro c variable declation question
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!