Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: insert statement in a function or select statement

Re: insert statement in a function or select statement

From: VC <boston103_at_hotmail.com>
Date: Thu, 03 Jun 2004 23:57:40 GMT
Message-ID: <UVOvc.36916$pt3.28575@attbi_s03>


Hi,

"Sharkie" <sharkdba_at_yahoo.com> wrote in message news:423b5ab1.0406031214.5c9b6070_at_posting.google.com...
> Oracle 8.1.7 on Solaris.
>
> Is it possible to somehow execute an insert statement inside a function
> or another select statement? Here's what I need to happen:

Yes:

create table t1(x int);

create or replace function f1(p_x int) return int as pragma autonomous_transaction;
begin
  insert into t1 values(p_x);
  commit;
  return p_x;
end;
/

select f1(1) from dual;
select f1(2) from dual;
select f1(3) from dual;

select * from t1;

X
-
1
2
3

VC Received on Thu Jun 03 2004 - 18:57:40 CDT

Original text of this message

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