Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling an SQL/PL function from C using embeded SQL

Status
Not open for further replies.

dsovey

Programmer
Aug 8, 2001
1
US
I am trying to call an SQL/PL function from within my C program. I am in a Linux enviroment running Oracle 8i. I can open up SQL*PLUS and run the function, but when I compile my C program it bombs with the error, PLS-S-00201, identifier 'CREATEACCOUNT' must be declared. I have tried both of the following without success. Please help. Thanks in advance.

Code:
int exec_stored_procedure() {
    int n;

    EXEC SQL CALL createAccount() INTO :n ;
    return(sqlca.sqlcode);
}

AND

int exec_stored_procedure() {
    int n;

    EXEC SQL EXECUTE
        BEGIN
        :n:=createAccount();
        END;
    END-EXEC;

    return(sqlca.sqlcode);
}
 
dsovey

It's been a while since I did stuff along these lines.. and unfortunately I can't look at the code any more... changed jobs. But I seem to remember the SQL pre-compiler we used PROc (on Solaris) was a bit fiddley.. Presumably you've written you createAccount function in a PL/SQL library somewhere.

Missing
Code:
EXEC SQL begin
and
Code:
EXEC SQL end
maybe?

Do you not need to declare 'n' inside an embedded call as well:
Code:
  EXEC SQL begin declaration

  int n

  EXEC SQL end declaration

Other than that - I'd suggest changing the call to CREATEACCOUNT (as sql puts it) to uppercase within your C code.. just in case.

Hope at least one of those helps!
Loon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top