I am trying to write a script that when returned it checks a certain field. If that field is null then I would put an id into a variable. If the field is not null then I would do a "select into" myvariable from mytable where somefield = q_rec.somefield.
I am a big newbie when it comes to oracle and pl/sql.
Any help would be appreciated.
Code:
declare nextclassID number;
nextgroupID number;
nextroomID number;
newAddedBy number;
newLastEditBy number;
CURSOR q IS
select class_id, course_id, class_date, room_id, unique_id, webevent_id, start_time, end_time, cancelled, class_recur_id, comments,
pre_instructions_fac, post_instructions_fac, pre_instructions_part, post_instructions_part, added_by, add_date, last_edited_by,
last_edit_date, conflict_ignore, class_group_id, new_room_id, new_course_id
from classes@linkwcl, map_courses mcr, map_id0_room mir
where wcl.course_id = mcr.old_course_id
and wcl.room_id = mir.old_room_id;
BEGIN
FOR q_rec IN q LOOP
SELECT class_id_seq.NEXTVAL INTO nextclassID FROM DUAL;
SELECT class_group_id_seq.NEXTVAL INTO nextgroupID FROM DUAL;
SELECT CLASS_ROOM_SEQ.NEXTVAL INTO nextroomID FROM DUAL;
if q_rec.added_by <> null then
SELECT new_user_id INTO newAddedBy FROM map_users where old_user_id = q_rec.added_by;
else
newAddedBy := 366;
end if;
if q_rec.last_edited_by <> null then
SELECT new_user_id INTO newLastEditBy FROM map_users where old_user_id = q_rec.last_edited_by;
else
newLastEditBy := 366;
end if;
I am a big newbie when it comes to oracle and pl/sql.
Any help would be appreciated.