Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: simple embedded C/SQL question
Someone suggested that you use a host variable. Well, you definitely have to
use host variables with SQL statements but I don't think you can use one as
the where clause. What you have to do is use dynamic SQL. You have to use
declare cursor and prepare cursor. You didn't specify which version of the
database and which version of Pro*C you're running under and so if you're
using Oracle 8, it is possible that they have something new in that, but I
haven't heard of it.
If you need more info or some sample code, just email me back.
Geoffrey Bray
Tandy Corporation
In article <7fq3ecv65kz.fsf_at_saul7.u.washington.edu>,
David Doll <djd_at_saul7.u.washington.edu> wrote:
>
>
> Hello, I have a simple C code program with some embedded SQL in it. I
> have something like this:
>
> ...
> char *query_string;
> ....
> query_string = getenv("QUERY_STRING");
> ....
>
> EXEC SQL DECLARE est_cursor CURSOR FOR
> SELECT library, ESTs
> FROM cluster_annotation
> WHERE query_string;
>
> Note:query_string would look something like db_id=1234
>
> A little later on, I will be printing out something like:
>
> library ESTs
> ------- -------
> yodnorm 21345 87649 3008
> tumor1 49484 84484
> etc.
>
> Now I can't get the syntax correct for the where clause to accept my
> variable. Could someone explain the correct syntax/method(s) to do
> this? Thanks for your time and help.
>
> David
> djd_at_u.washington.edu
>
> p.s. system info: SunOS 5.5.1, oracle server: 7.2.3.0.0
>
>
-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading Received on Wed Jun 24 1998 - 13:34:47 CDT