Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: INSERT ... VALUES( :placeholder1, ...)
In article <a1ur8m$317g$1_at_ns.felk.cvut.cz>, "Opi" says...
>
>Hi, I have written a recursive script in PHP that scans directory tree and
>saves it to a single table. That was for mysql, and now when I'm tampering
>with Oracle, I want to see it in action, so I have parsed this statement:
>
>$sql =
>"DECLARE dohajzlu NUMBER(5);"
> ."BEGIN SELECT godir_i.NEXTVAL INTO :dohajzlu FROM DUAL;"
> ."INSERT INTO godir VALUES(:dohajzlu, :pod, :xpath);".
>"END;";
>
>// then...
>$b_curid = 0;
>OCIBindByName($stmt,":dohajzlu",&$b_curid,32);
>OCIBindByName($stmt,":pod",&$b_pod,32);
>OCIBindByName($stmt,":xpath",&$b_xpath,32);
>
>It works fine - until the $xpath contains something bad. It works with
>"C:/mp3/Republica", "C:/mp3/Mike Oldfield", ... , but doesn't with
>"C:/mp3/Mike Oldfield/1974 - Hergest Ridge", and it prints out this error:
> "ORA-01460: no-sence or non-implemented conversion demanded" (Translated
>from Czech, don't know the exact phrase.)
>
>Please tell me what's wrong, and also please, tell me how to escape various
>chars, like \, &, ' etc.
>
>Thanks, Opi
>
>
in the ocibindbyname call, you are passing a length of 32 but binding a string of 41 characters.
see
http://www.php.net/manual/en/function.ocibindbyname.php
perhaps you want to be using -1
ops$tkyte_at_ORA817DEV.US.ORACLE.COM> select length( 'C:/mp3/Mike Oldfield/1974 - Hergest Ridge' ) from dual;
LENGTH('C:/MP3/MIKEOLDFIELD/1974-HERGESTRIDGE')
41
that could cause
01460, 00000, "unimplemented or unreasonable conversion requested"
There is no need to "escape" any characters in bind variables. There are no characters to be escaped.
In sqlplus, you can issue "set define off" to have an & ignored. Otherwise, it is like the $ in shell -- sqlplus does substitution....
In sqlplus when inserting character string constants -- a '' = ' in a string
select 'how''s this' from dual;
in your program, with bind variables, you do not have this issue at all.
-- Thomas Kyte (tkyte@us.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 CorpReceived on Mon Jan 14 2002 - 10:41:53 CST
![]() |
![]() |