Re: OCI: How can I insert a string including an amphersand (&) from OCI??

From: Ole Hansen <oha_at_unispeed.com>
Date: Mon, 14 Oct 2002 11:01:45 +0200
Message-ID: <3DAA87F9.2000508_at_unispeed.com>


Hi,

I think I really messed up things here. This is an example of the code I use.

char query[200];

sprintf(query, "insert into some_table (a,b) values (25, 'abc&def')");

OCIStmtPrepare(stmthp,errhp,(text*)query,
   (ub4)strlen(query),(ub4)OCI_NTV_SYNTAX,(ub4) OCI_DEFAULT);
OCIStmtExecute(svchp, stmthp, errhp,(ub4)1,

   (ub4)0,(CONST OCISnapshot *)NULL,
   (OCISnapshot *) NULL,OCI_COMMIT_ON_SUCCESS);

Whenever I had a faulty insert I tried to execute the very same statement from sqlplus - and it failed too because the string also included an ampersand and I was prompted for a value.

However the problem seems to be something different which I will look into.

Thanks!

Ole

Thomas Kyte wrote:
> In article <3DA7F0F8.2060801_at_city.dk>, Ole says...
>

>>Hi,
>>
>>I have troble escaping an amphersand (&) from within OCI.
>>Neither single quote (') or backslash (\) seems to work.
>>
>>The statement fails if I try to execute it from OCI if the string 
>>includes an amphersand but I dont know how to escape an amphersand (&).
>>
>>I really need to store the amphersand with the string.
>>

>
>
> you'll have to show us an example since & is meaningless to OCI
>
> It only means something in sqlplus (and you use "set define off" to make it mean
> nothing in there).
>
> & in OCI is just like "X" or "A" -- just another character.
>
>
>>Any ideas?
>>
>>Thanks in advance!
>>Ole Hansen
>>

>
>
> --
> 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 Mon Oct 14 2002 - 11:01:45 CEST

Original text of this message