Home » SQL & PL/SQL » SQL & PL/SQL » Processing Records in Cursor
Processing Records in Cursor [message #637016] Thu, 07 May 2015 13:04 Go to next message
rohit_shinez
Messages: 139
Registered: January 2015
Senior Member
Hi Guys,

I need to insert records in Master table by doing one to one mapping records and comparing with respective tables. For Eg

Table_1

Header 1 Header 2 Header 3 Header 4
12 123 200 NZ
12 123 500 AUS
12 123 100 NZ



Table_2

Header 1 Header 2 Header 3 Header 4
0 500 1.5 NZ
500 1000 12.3 AUS

Master Table

Header 1 Header 2 0-500 500-1000 Header 5
12 123 200 1.5
12 123 500 12.3
12 123 100 1.5

I need to have one to one record mapping from Table_1 and Master_table by looking up Table_2 This needs to be done in cursor only
Re: Processing Records in Cursor [message #637017 is a reply to message #637016] Thu, 07 May 2015 13:13 Go to previous messageGo to next message
John Watson
Messages: 9003
Registered: January 2010
Location: Global Village
Senior Member
This is a college homework, question, right? You need to show what query you have tried to write so far, and the CRATE TABLE and INSERT statements needed to set up the problem. Please use [code] tags when you do this. You know how to use them, you have done it before.
Re: Processing Records in Cursor [message #637018 is a reply to message #637017] Thu, 07 May 2015 13:24 Go to previous messageGo to next message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

... Also don't forget to get back to your previous topics to feedback and thank people who helped and spent time for you.

Re: Processing Records in Cursor [message #637019 is a reply to message #637018] Thu, 07 May 2015 13:33 Go to previous messageGo to next message
rohit_shinez
Messages: 139
Registered: January 2015
Senior Member
create table Table_1(header_1 number,header_2 number,header_4 number,header_5 varchar2(4));
create table Table_2(header_1 number,header_2 number,header_4 varchar2(4));
create table Master_table(header_1 number,header_2 number,header_4 number,header_5 varchar2(4));

insert into table_1
select 12,123,200,'NZ' from dual;
insert into table_1
select 12,123,500,'AUS' from dual;
insert into table_1
select 12,123,100,'NZ' from dual;

insert into table_2
select 0,500,1.5,'NZ' from dual;
insert into table_2
select 500,1000,12.3,'AUS' from dual;
Re: Processing Records in Cursor [message #637020 is a reply to message #637019] Thu, 07 May 2015 13:41 Go to previous message
John Watson
Messages: 9003
Registered: January 2010
Location: Global Village
Senior Member
orclz> insert into table_2
  2  select 0,500,1.5,'NZ' from dual;
insert into table_2
            *
ERROR at line 1:
ORA-00913: too many values


orclz> insert into table_2
  2  select 500,1000,12.3,'AUS' from dual;
insert into table_2
            *
ERROR at line 1:
ORA-00913: too many values


orclz>

What query have you tried so far? Have you, for example, tried to join table_1 and table_2 using that varchar2 column?
Previous Topic: View is not able to execute successfully because of using
Next Topic: Frequency Distribution with future date place holders
Goto Forum:
  


Current Time: Wed Jul 29 07:59:15 CDT 2026