Thank You
Arshad, December 08, 2016 - 12:58 pm UTC
Exactly what i was looking for, Can you please let me know how can we update the old values in B with new values in A if Match found.
Thanks in advance for the help.
December 08, 2016 - 1:24 pm UTC
I don't understand what you're trying to do. The example I gave is when there is a match in A. So why do you need to update? You'll end up with two rows in B with the same values!
Replace
Arshad, December 08, 2016 - 1:42 pm UTC
I have another requirement where we may need to replace the old values with new ones,so i wish to replace the old value in B with the new values in A,i believe we will need to update in that case.
December 08, 2016 - 2:10 pm UTC
But how do you know whether you're replacing the existing values or inserting alongside them?
Either insert or update
Arshad, December 08, 2016 - 2:20 pm UTC
We are not trying both at a time either we will be inserting or else replacing the older.
December 08, 2016 - 4:35 pm UTC
I still don't understand how you decide whether you update or insert.
Anonymous, February 25, 2019 - 6:03 pm UTC
Nice Tom... But I have a requirement. It is as follows
I need to create a procedure which takes an ID say it is a varchar
I have a select query which has union and returns me a single record based on the ID
One column from the result of select query decides in which table the data to be inserted assume in one of the two tables
How to write a procedure. Can u help me?
February 26, 2019 - 2:56 am UTC
Pseudo-code below
create or replace
procedure my_proc(id varchar2) is
result int;
begin
select ...
into result
from
( select ...
union
select ...
);
if result = 1 then
insert into TABLE_A ...
elsif result = 2 then
isnert into TABLE_B ...
end if;
end;