Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert %rowtype values in table

Status
Not open for further replies.

kondakindi

IS-IT--Management
Apr 18, 2005
31
US
Hi,
I have one row data in %rowtype .and when in insert the values in that rowtype it says column not allowed here: the following is the example
rec books%rowtype;
select * into rec from books where bno='8888';
insert into book_archive values
(rec.bno,rec.title,recauthor and so on...);
all theses fields are same
infact the rowtype is of the table in which i am making entry.....
Could u let me know where is the problem from the above rough syntax.

Thanks
 
Hi,
Ya it should be rec.author it was a typo mistake here but i still can't make an insert as it says column not allowed here can i skip coulns in the rec.I mean some i take from local variable adn some from rowtype ones is it possible.
Thanks,
 
Here's one that works and seems to do everything you want:

Code:
drop table testins;
drop table testins2;
create table testins (col1 integer, col2 varchar2(10));
create table testins2 (col1 integer, col2 varchar2(10));
insert into testins values (1,'XXX');

select * from testins;
select * from testins2;

declare
    r_type testins%rowtype;
    v_new_key integer;
begin
         select col1, col2
         into r_type.col1, r_type.col2
         from testins
         where rownum=1;
         v_new_key := r_type.col1 + 1;
         insert into testins2 values (v_new_key, r_type.col2);
end;
/
select * from testins;
select * from testins2;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top