Re: Dynamic SQL and Pro*C

From: Thomas Kyte <tkyte_at_oracle.com>
Date: 21 Aug 2002 18:11:57 -0700
Message-ID: <ak1dot0b7b_at_drn.newsguy.com>


In article <3D642F21.35721E32_at_akula.com>, Shirland says...
>
>Hello,
> I'm a novice pro*C programmer. I have come upon a problem that I
>cannot resolve. When running a query via a string host variable , Must
>I use place holders for string variables/numbers etc in teh actualy
>queury ? I really dont want to ! My data is built around really large
>structures and I dont know think Dynamic SQL supports
>Example...
>
>This is what I want to execute:
>
>char *stmt="SELECT EMPNO, EMPNAME where DEPTNO=34";
>
>It seems like im being forced to :
>
>int x=34;
>
>char *stmt="SELECT EMPNO, EMPNAME where DEPNO=:x";
>
>My program generates a statement like the first one above and its
>dynamic therefore I'll never know how many variables to declare. I've
>tried using a host array with the value in it but that doesnt seem to
>work for SELECT statements. Thanks in advance for any help !
>

*forced to* no. (oh HOW I WISH)

*should do* -- oh yes, big time -- absolutely, 100% screaming YES.

Look at dynamic sql method 4. It'll let you do this.

short of that, give serious consideration to:

exec sql alter session set cursor_sharing=force; exec sql execute immediate :stmt_without_bind_variables; exec sql alter session set cursor_sharing=exact;

and read about cursor_sharing in the docs.

--
Thomas Kyte (tkyte_at_oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Thu Aug 22 2002 - 03:11:57 CEST

Original text of this message