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 -> Oracle's 'mysql_insert_id'?

Oracle's 'mysql_insert_id'?

From: Opi <opi_at_volny.cz>
Date: Sun, 13 Jan 2002 02:52:18 +0100
Message-ID: <a1qp6i$1d99$1@ns.felk.cvut.cz>


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

Original text of this message

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