Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Embedded sql
N Prabhakar wrote:
>
> Bing Liu <bliu_at_shore.net> wrote:
> >Is that possible to put VARCHAR variable in condition WHERE ?
> >
> >I declared host variables as:
> >
> >VARCHAR key[20];
> >VARCHAR ItemName[20];
> >
> >and:
> >
> >strcpy(key.arr,"xyz");
> >key.len=strlen(key.arr);
> >
> >Then I want select columns from a table:
> >
> >EXEC SQL SELECT name INTO :ItemName
> >FROM CABLEBOX
> >WHERE KEY = :key;
> >
> >When I run the program, I couldn't get the item name I want.But if I put
> >the string 'xyz' behend = , it works. I wonder if I could put variable
> >in WHERE clause. What to do if I really want to fetch somthing like this
> >?
>
> Hi there,
>
> This should definitely work. May be after setting the .len of key, can you
> print the value of key and check??
>
> After executing the sql statement, check for SQL_ERROR.
>
> Null terminate ITEMNAME variable and print it.
>
> Hope the above info helps you
>
> Regards
>
> N.Prabhakar
Hi, there
Thanks for the help.
The problem has been fixed.
I changed the data type in database from char to varchar, so that both internal and extern variable have the same data type. I also tried to define them both as char, I looks working too.
Regards
B.Liu Received on Tue Feb 04 1997 - 00:00:00 CST