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: store result of query in variable

Re: store result of query in variable

From: Vince <vinnyop_at_yahoo.com>
Date: Tue, 4 Dec 2007 09:34:53 -0800 (PST)
Message-ID: <804e689e-bee5-42b3-9079-1ae2d6537716@e23g2000prf.googlegroups.com>


On Dec 3, 11:47 pm, monesseldeur <raymondesseld..._at_gmail.com> wrote:
> Hi all,
>
> I'm trying to write a script in which I need the result of a query to
> perform an insert in a table.
>
> Something like this:
>
> var = select max(Xid) from tbl_X;
> var = var + 1;
> insert into tbl_X (Xid) values (var);
>
> Is this possible without uising Pl/SQL?

How about:
insert into tbl_X(Xid)
select max(Xid) + 1 from tbl_X;

As others have pointed out, you probably want to look into sequences. Received on Tue Dec 04 2007 - 11:34:53 CST

Original text of this message

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