Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Oracle's 'mysql_insert_id'?
Hi,
I don't want to annoy you with mysql stuff, but that describes my problem best.
I need to get the last value added to the table's id column, what is get
from a sequence.
1) Is using SEQUENCE the best way to get the incrementing id's value?
2) How to get the inserted value? Do I need to write a PL script?
Now, I am trying this: (the code is written in PHP)
$sql = "
BEGIN
:dohajzlu := godir_seq.nextval;
INSERT INTO godir VALUES(:dohajzlu, :pod, :xpath);
END;";
$stmt = OCIParse($spoj,$sql);
OCIBindByName($stmt,":dohajzlu",&$b_curid,32); OCIBindByName($stmt,":pod",&$b_pod,32); OCIBindByName($stmt,":xpath",&$b_xpath,32);OCIExecute($stmt);
But this throws an error:
OCIStmtExecute: ORA-06550: line 1, col 1: PLS-00103: found "" while
expecting one of: begin declare ... blah blah ... and so on.
I should say that " BEGIN :dohajzlu := 55; END; " works fine.
" BEGIN :dohajzlu := (SELECT godir_seq.nextval FROM dual); END; " doesn't.
I'm still turning at the same place, because noone was kind enough to tell me where to get WHOLE oracle manual for FREE. I still have several f***g bad written tutorials, lot of them about sql*plus, what I don't need at all. So please, if you have something big about Oracle8i SQL && PL/SQL, send it to me!!! Or just a link. And resolving this problem would help me much, too. Thanks, Opi
Thanks, Opi Received on Sat Jan 12 2002 - 19:52:18 CST