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 -> Cannot INSERT rst.* ?

Cannot INSERT rst.* ?

From: Adrian Hands <AHands_at_sprynet.com>
Date: 1997/10/17
Message-ID: <3448276A.44D9CF09@sprynet.com>#1/1

I've been coding in Informix-4GL and was excited to get an opportunity to try Oracle PL/SQL.
My first assignment required setting up a stored proc that duplicated an existing row on the database, changing the value of one column in the primary key. I tried this, but found that Oracle refuses to allow the asterisk within the INSERT statement:

begin

myRst myTable%rowtype;
v_new01 myTable.myCol01%type;

select * into myRst.* from myTable where... ; myRst.myCol01 := v_new01;
insert into myTable values(myRst.*);

end;

I ended up having to explicitly name each and every column in the insert statement which is a real drag because (1) what should've been just a few lines of code is now a few pages and (2) whenever this table is altered this code has to be fixed.

(I can't: INSERT INTO mytable (SELECT * FROM mytable) and then UPDATE mytable because of the unique primary key constraint.)

Anybody have a clean solution or am I destined to remain  Disappointed in Oracle,

-Adrian Hands
AHands_at_sprynet.com Received on Fri Oct 17 1997 - 00:00:00 CDT

Original text of this message

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