Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How can I update DB using PERL?

Re: How can I update DB using PERL?

From: QuestionExchange <USENET_at_questionexchange.com>
Date: 4 Nov 1999 15:49:43 GMT
Message-ID: <2486qx@questionexchange.com>


>
> --------------F6E00528E8927CCB0A9A2E2E
> Content-Type: text/plain; charset=EUC-KR
> Content-Transfer-Encoding: 7bit
>
> *** I'm not used to in English.. so will you do me a favor!



>
> I had implemented inserting into a DB and selecting from a DB
> and I'm tring to update a DB (Oracle) using Perl at this
time.
> but this isn't implemented .
>
> I had done following as :
> if table name is T1, field names are F1,F2,F3, and input
variables
> $V1,$V2,$V3
>
> $dbh->do("update T1 set F1=$V1, F2=$V2, F3=$V3 where
num=$v_num") || die
> DBI->errstr;
>
> that result is "ORA-00936: missing expression "
> but I don't know what I missed.
>
> I'll wait for your answer!!!
>
> --------------F6E00528E8927CCB0A9A2E2E
> Content-Type: text/html; charset=EUC-KR
> Content-Transfer-Encoding: 7bit
>
> <!doctype html public "-//w3c//dtd html 4.0
transitional//en">
> <html>
> *** I'm not used to in English.. so will you do me a favor!


> <p>I had implemented inserting into a DB and selecting from a
DB
> <br>and I'm tring to update a DB (Oracle) using Perl at this
time.
> <br>but this isn't implemented .
> <p>I had done  following as :
> <br>if table name is T1,  field names are F1,F2,F3,  and 
> input variables $V1,$V2,$V3
> <p><b>$dbh->do("update T1 set F1=$V1, F2=$V2, F3=$V3 where
num=$v_num")
> || die DBI->errstr;</b>
> <p>that result is "ORA-00936: missing expression "
> <br>but I don't know what I missed.
> <p>I'll wait for your answer!!!</html>
>
> --------------F6E00528E8927CCB0A9A2E2E--
>
>
>

One of your variables must be missing a value, effectively turning your SQL string into:
"update T1 set F1=, F2=, F3= where num=" or some variant. No expressions means invalid SQL statement! You are much better off using bind variables in the Perl DBI/DBD,
instead of the dreaded substitutive $varnames. This has to do with how statements like this are parsed by the database engine.
Your statement might look like this instead: "update T1 set F1=:v1, F2=:v2, F3=:v3 where num=:somenum" *Prepare* the SQL statement (instead of "do") first! Then set bind variables :v1, :v2, :v3 and :somenum to their respective values prior to the "do" call. See (specifically) the DBD-Oracle documentation for info on bind variables - it's a little different than other databases'
implementation (others use the "?" placeholder, oracle uses the ":var" nomenclature).
Hope this helps!

--
  This answer is courtesy of QuestionExchange.com   http://www.questionexchange.com/showUsenetGuest.jhtml?ans_id=7168&cus_id=USENET&qtn_id=6907 Received on Thu Nov 04 1999 - 09:49:43 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US