Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

creating a procedure to loops through a table to see if the item exist

774561Jun 8 2010 — edited Jun 9 2010
I 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.
This post has been answered by SomeoneElse on Jun 9 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 7 2010
Added on Jun 8 2010
30 comments
2,778 views