Re: Calling stored procedure in PRO C

From: Dave <solomons_dad.w.marks_and_whom_at_oracle.com>
Date: Wed, 19 Jul 2006 09:41:39 +0100
Message-ID: <nxmvg.12$xP5.106_at_news.oracle.com>


abhi147_at_gmail.com wrote:
> Hi ,
> I am very new to Pro C . I have a stored procedure like
> abc ( IN a , IN b , IN/OUT c)
> I want to call this procedure but I don't know how to get the output
> parameter c after the execution .
> The sub program is as follows :
> EXEC SQL BEGIN DECLARE SECTION;
> char *a;
> char *b;
> varchar c[8];
> EXEC SQL END DECLARE SECTION;
>
> a = "A";
> b = "B";
> c = "normal";

This won't work at all. Generally string assignment is done in C with strcpy, not with =, although for complicated reasons char *a; a="a"; will work providing you never need to change the contents of a (except via another assignment). You should use strcpy for string assignment and define strings as char name[length] unless you know exactly what you are doing.

Not sure why you used varchar for c instead of char; if you do char c[8]; and strcpy(c,"normal"); that should work fine, and the result of the SP will then be in c after the end-exec.

>
> EXEC SQL EXECUTE
> BEGIN
> abc(:a, :b, :c );
> END;
> END-EXEC;
>
> Please tell me if i am executing the procedure correctly . And how can
> i get the output argument c .

Depends what you mean by "get." If you follow the end-exec with a puts(c); that should display it.

Dave. Received on Wed Jul 19 2006 - 10:41:39 CEST

Original text of this message