Procedure [message #262656] |
Tue, 28 August 2007 00:48  |
kmanioracle
Messages: 19 Registered: March 2007
|
Junior Member |
|
|
Hi
Please help to write a procedure for below condition.
Take values from table A and insert in B & C
Insert table B if stud_id in table A has duplicate value(s)
Insert table C if stud_id in table A don’t have duplicate value(s)
Table A structure
stud_id number,
Other_fileds ….
Table B, C structure is same as A.
Thanks in advance.
Regards
Mani
|
|
|
Re: Procedure [message #262665 is a reply to message #262656] |
Tue, 28 August 2007 00:59   |
muzahid
Messages: 281 Registered: September 2004 Location: Dhaka, Bangladesh
|
Senior Member |
|
|
create a cursor using
select stud_id, count(*) cnt from table_A group by stud_id;
then fetch the cursor and if count = 1 then table c
else insert table table b
|
|
|
Re: Procedure [message #262679 is a reply to message #262656] |
Tue, 28 August 2007 01:14   |
kmanioracle
Messages: 19 Registered: March 2007
|
Junior Member |
|
|
Hi Muzahidul Islam
Thanks for your instant reply.
We have more columns in table A (like mark1, mark2, total and etc). Assume we have 100 columns in table A, so it will not be good if we use all columns in group by clause..
Note : Please use single cursor.
Regards,
Mani
|
|
|
Re: Procedure [message #262687 is a reply to message #262679] |
Tue, 28 August 2007 01:23   |
muzahid
Messages: 281 Registered: September 2004 Location: Dhaka, Bangladesh
|
Senior Member |
|
|
You will use single cursor using group by stud_id column.
Then you fetch the cursor and if the count is more than 1 then select all row from table a to table c like
insert into table_c values (select * from stud_id = v_stud_id)
Do You got my point?
|
|
|
|
|