Hi,
I need to check for the existence of record in a table for certain conditions if the record exits just update some muneric columns if it does not exists insert it
can u send me the query on this
Thanks all in advance
Anupama
Printable View
Hi,
I need to check for the existence of record in a table for certain conditions if the record exits just update some muneric columns if it does not exists insert it
can u send me the query on this
Thanks all in advance
Anupama
Hi
One way would be to do
declare
begin
--do the update
update table
set col1=some_value
where col2=some_condition; --based on some criteria
--check wheather u updated any rows
if sql%rowcount=0 then
--do nothing
NULL;
else
insert into tables
values(some_value);
end if
end;
regards
Hrishy
Hi,
Here is the Pseudocode, which u can try
----------------
Procedure Populate_Target_table
Cursor c1 is selet * from Target_Table
MINUS
select * from Source Table
for x in c1 loop
Insert into Target_Table
By taking data from cursor;
Exception
Dup_val_on index
Update Target_table
You need to have a primary key for this to work
have you tried "merge"
http://www.quest-pipelines.com/newsletter-v4/0903_D.htm
Thanks all for your help the problem is solved