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

Re: Oracle's 'mysql_insert_id'?

From: Ron Reidy <rereidy_at_indra.com>
Date: Sun, 13 Jan 2002 09:08:18 -0700
Message-ID: <3C41B0F2.E1D7945F@indra.com>


Opi wrote:
>
> 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

insert into x value (y, z) returning id into :varaible;

-- 
Ron Reidy
Oracle DBA
Received on Sun Jan 13 2002 - 10:08:18 CST

Original text of this message

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