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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How do you declare function parameters as host variables in Pro*C/C++?

Re: How do you declare function parameters as host variables in Pro*C/C++?

From: Kenneth C Stahl <BluesSax_at_Unforgettable.com>
Date: Wed, 01 Sep 1999 07:44:29 -0400
Message-ID: <37CD119C.7CFCD008@Unforgettable.com>


Erik Moe wrote:

> Hello,
>
> I haven't done embedded SQL in several years and then it was with
> Informix. I want to use some function parameters as host variables,
> something like this:
>
> func(int foo, char* bar)
> {
> EXEC SQL INSERT INTO FOOBAR (FOO, BAR) VALUES (:foo, :bar);
> }
>
> How do I declare foo and bar as host variables? I don't want to want
> to you K&R syntax:
>
> func(foo, bar)
> EXEC SQL BEGIN DECLARE SECTION
> int foo;
> char* bar;
> EXEC SQL END DECLARE SECTION
> {
> EXEC SQL INSERT INTO FOOBAR (FOO, BAR) VALUES (:foo, :bar);
> }
>
> Is this legal?
>
> func(
> EXEC SQL BEGIN DECLARE SECTION
> int foo, char* bar
> EXEC SQL END DECLARE SECTION
> )
> {
> EXEC SQL INSERT INTO FOOBAR (FOO, BAR) VALUES (:foo, :bar);
> }
>
> Erik Moe

What version of Pro-C do you use? If it is 2.2 or higher then you don't need explicitly declared host variables and something like your first example should be reasonable except that most likely you probably meant:

void func(int foo,const char *bar)

However, if you are using C++ then you need the semantics of having a declare section.










Received on Wed Sep 01 1999 - 06:44:29 CDT

Original text of this message

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