declare
v_creditcard_id ec_creditcards.creditcard_id%TYPE;
begin
IF new.order_id is not null THEN
select into v_creditcard_id creditcard_id
from ec_orders where order_id=new.order_id;
IF new.creditcard_id is null THEN
new.creditcard_id := v_creditcard_id;
END IF;
END IF;
return new;
end;