creating a procedure to loops through a table to see if the item exist
774561Jun 8 2010 — edited Jun 9 2010I have the following table_one created
type_id descriptiom used_value
cbx red 0
boo green 5
aaa yellow 0
Ok, I dont know how possible this is but I am trying to do the following
procedure recent_change (type_required in varchar2, description in varchar2, value_required in varchar2) IS
type_required varchar2(30);
description varchar2(30);
value_requiredid := to_number(value_required);
cursor c3 is
select used_value from table_one
where type_id = type_required;
Begin
open c3;
fetch c3 into value_requiredid;
close c3
if
<....................this is where i am stuck>
<however, what I am trying to do is loop through all the rows in the table to check to see if the description passed as a parameter exist in the table(table_one) and if it does I should be able to do the following command below
update table_one
set used_value = value_requiredid
where type_id = type_required;
elseif <....if the description passed as a parament doesn't exist>
then do
insert into table_one values (type_required, description, value_requiredid);
commit;
End recent_change;
I am still a newbie...so I need a bit of help. Thank you.