Akdora’s Blog

Programming, Oracle, Life, Fun

A small sequence trick August 8, 2007

Filed under: Oracle — Akdora @ 8:20 am

I could not send a sequence next value directly as a parameter in a pl/sql block. Then, 🙂


begin
pr_insert_mytable
(
mytable_seq.NEXTVAL ,
xx,
yy,
0,
zz,
);
end;

Error: PLS-00357: Table,View Or Sequence reference mytable_seq.NEXTVAL not allowed in this context
Line: 301
Text: pr_insert_log(mytable_seq.NEXTVAL,

Error: PL/SQL: Statement ignored
Line: 301
Text: pr_insert_mytable(mytable_seq.NEXTVAL,

then we can set it the sequence to a variable then insert it 🙂

declare
ln_id number(10);
begin
select mytable_seq.NEXTVAL into ln_id
from dual;
pr_insert_mytable
(
ln_id,
xx,
yy,
0,
zz,
);
end;

Advertisement
 

One Response to “A small sequence trick”


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s