Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Getting primary key value after insert
I'm trying to create a function in an Oracle 8.1.6 database. The following code is how I create the function:
create or replace function test_add ( InNotes IN test.notes%TYPE )
return number
as
id test.pkid%TYPE;
begin
----select test_pkid_seq.nextval into id from dual;
insert into test ( pkid, notes ) i
values ( test_pkid_seq.nextval, InNotes ) returning pkid into id;
The function is created and I executed it from within PLSQL like this and get the following error messages:
select test_add( 'asdf' ) from dual;
select test_add( 'asdf' ) from dual
*
ERROR at line 1:
ORA-14551: cannot perform a DML operation inside a query ORA-06512: at "DESIGN.TEST_ADD", line 6 ORA-06512: at line 1
This topic was in another new group message and that describe that
this was possible.
I can seem to figure out why I can't get it to work.
Thanks,
Troy_Simpson_at_ncsu.edu
Received on Fri Sep 22 2000 - 17:14:41 CDT
![]() |
![]() |