I have yet another question. I can get the cursor (below) to work. However, if the field is null it will not update the record(s). Does anyone have any ideas on how to get the cursor to update the records whether it's null or not?
DECLARE
v_ssn_update discover_cc.ssn%type;
v_cardnumber_update discover_cc.cardnumber%type;
v_expire_update discover_cc.expire%type;
v_name_on_card_update discover_cc.NAME%type;
CURSOR zegato_update IS
Select c.ssn, c.cardnumber, c.expire,c.NAME
from discover_CC c , ZEG_USER_DEF_STRING z
where c.SSN = z.SSN;
BEGIN
OPEN zegato_update;
FETCH zegato_update INTO
v_ssn_update, v_cardnumber_update, v_expire_update, v_name_on_card_update;
WHILE zegato_update %FOUND LOOP
UPDATE ZEG_USER_DEF_STRING
SET credit_card = v_cardnumber_update,
expire = v_expire_update,
name_on_card = v_name_on_card_update
where SSN = v_ssn_update
AND (
(v_cardnumber_update <> credit_card) or
(v_expire_update <> expire) or
(v_name_on_card_update <>name_on_card)
);
COMMIT;
FETCH zegato_update INTO
v_ssn_update,v_cardnumber_update, v_expire_update, v_name_on_card_update;
END LOOP;
close zegato_update;
END;
/
DECLARE
v_ssn_update discover_cc.ssn%type;
v_cardnumber_update discover_cc.cardnumber%type;
v_expire_update discover_cc.expire%type;
v_name_on_card_update discover_cc.NAME%type;
CURSOR zegato_update IS
Select c.ssn, c.cardnumber, c.expire,c.NAME
from discover_CC c , ZEG_USER_DEF_STRING z
where c.SSN = z.SSN;
BEGIN
OPEN zegato_update;
FETCH zegato_update INTO
v_ssn_update, v_cardnumber_update, v_expire_update, v_name_on_card_update;
WHILE zegato_update %FOUND LOOP
UPDATE ZEG_USER_DEF_STRING
SET credit_card = v_cardnumber_update,
expire = v_expire_update,
name_on_card = v_name_on_card_update
where SSN = v_ssn_update
AND (
(v_cardnumber_update <> credit_card) or
(v_expire_update <> expire) or
(v_name_on_card_update <>name_on_card)
);
COMMIT;
FETCH zegato_update INTO
v_ssn_update,v_cardnumber_update, v_expire_update, v_name_on_card_update;
END LOOP;
close zegato_update;
END;
/