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

Home -> Community -> Usenet -> c.d.o.misc -> Re: PL/SQL - is inserting of %ROWTYPE variable possible?

Re: PL/SQL - is inserting of %ROWTYPE variable possible?

From: Hans van Dam <LandRoverManREMOVETHIS_at_tiscalimail.nl>
Date: Wed, 08 Jan 2003 15:52:14 GMT
Message-ID: <3e1c407a.199686406@pollux.casema.net>


On 7 Jan 2003 19:44:11 -0800, rs_arwar_at_hotmail.com (Rauf Sarwar) wrote:

>Bogien <bogien_at_xcom.pl> wrote in message news:<3E1B57D3.DDBC8532_at_xcom.pl>...

>> Hello,
>>
>> Suppose I have a table named "tab" with columns "a", "b", "c", "d", "e".
>> Now, I declare a variable named "rec" of type "tab%ROWTYPE", which
>> reflects single record of the table.
>>
>> Question:
>> Can I insert such variable into the table in PL/SQL at once?
>>
>> So fat, I've been performing this task this way (doesn't look nice...):
>> INSERT INTO tab (a, b, c, d, e) VALUES (rec.a, rec.b, rec.c, rec.d, rec.e);
>>
>> Is something like "INSERT INTO tab VALUES rec" possible?

Dont think so, but depending on what exactly you want to do, consider the following;

As you might know you can skip the first column-list (only when inserting all columns), like this:
  INSERT INTO tab VALUES (rec.a, rec.b, rec.c, rec.d, rec.e);

Also you could consider to directly insert from a select, thus eliminating the need for a record-variable and some code to fill the record, like this:
  INSERT INTO tab SELECT a, b, c, d, e FROM ???

Hope this helps,

Hans van Dam. Received on Wed Jan 08 2003 - 09:52:14 CST

Original text of this message

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