Re: OCI calls

From: Scott Urman <surman_at_oracle.com>
Date: 1996/02/01
Message-ID: <4er8f4$bgk_at_inet-nntp-gw-1.us.oracle.com>#1/1


In article <4eovhd$t08_at_news.missouri.edu>, kodali_at_cclabs.missouri.edu (Ravi Kodali) writes:
|> I was trying to update some records with C and OCI and could someone
|> tell me if I need to bind the variable before calling 'oexec' or
|> can I directly call 'oexec' after 'oparse'.
|>
|> say variable 'Load' is pointer to some data.
|>
|> now I tried this way.
|>
|> strcpy(array,"UPDATE USER_INFO SET DESCRIPTION = '");
|> strcat(array,Load);
|> strcat(array,"' WHERE USER_ID = 'dale'");
|>
|> oparse(&cda, array, -1, 0, 2);
|>
|> obndra(&cda,(text *) "dale",-1,(text *) Load,sizeof(sword),\
|> VARCHAR2_TYPE,-1,(sb2 *) 1,alen,arcode,len,&max ,(text
|> 0,-1,-1));
|>
|> oexec(&cda);
|>
|>
|> and when I try to bind it before executing it, gives me this error
|>
|> ORA-01036: illegal variable name/number
|> Processing OCI function OBNDRA
|> Error logging off!
|>
|> and I tried executing it directly without binding and it takes forever
|> though it does not give an error.
|>
|> can someone tell me if I should bind before executing it at all for
|> an UPDATE and also when is that I have to bind at all.

In this case, you don't bind, since there are no placeholders in the string. You are comparing the USER_ID column to the hardcoded string 'dale'. If you want to use a bind variable, it would be

 strcpy(array,"UPDATE USER_INFO SET DESCRIPTION = '"); 
 strcat(array,Load); 
 strcat(array,"' WHERE USER_ID = :dale"); 

 oparse(&cda, array, -1, 0, 2);

 obndra(&cda,(text *) ":dale",-1,(text *) Load,sizeof(sword),\

         VARCHAR2_TYPE,-1,(sb2 *) 1,alen,arcode,len,&max ,(text
                  0,-1,-1));

 oexec(&cda);

Note the colon.

|>
|> thanks in advance.
|>
|> Ravi
|>
|> --
|> **********************************************************
|> * Programmer/Analyst I (Oracle DBA) *
|> * Centre for Technology Innovations in Education(CTIE) *
|> * University of Missouri - Columbia *
|> * Columbia MO - 65211 *
|> * Tel # Home - (314)815-9176 *
|> * Off - (314)882-2162 *
|> * email - kodali_at_tie.missouri.edu *
|> **********************************************************
  Received on Thu Feb 01 1996 - 00:00:00 CET

Original text of this message