日期:2014-05-16 浏览次数:20394 次
Set Serveroutput on; begin update t_contract_master set liability_state = 1 where policy_code = '123456789'; if SQL%Found then dbms_output.put_line('the Policy is updated successfully.'); commit; else dbms_output.put_line('the policy is updated failed.'); end if; end;
SQL> the policy is updated failed. PL/SQL procedure successfully completed
Set serveroutput on; declare ---define Cursor Cursor cur_policy is select cm.policy_code, cm.applicant_id, cm.period_prem,cm.bank_code,cm.bank_account from t_contract_master cm where cm.liability_state = 2 and cm.policy_type = 1 and cm.policy_cate in ('2','3','4') and rownum < 5 order by cm.policy_code desc; curPolicyInfo cur_policy%rowtype;---定义游标变量 Begin open cur_policy; ---open cursor Loop --deal with extraction data from DB Fetch cur_policy into curPolicyInfo; Exit when cur_policy%notfound; Dbms_Output.put_line(curPolicyInfo.policy_code); end loop; Exception when others then close cur_policy; Dbms_Output.put_line(Sqlerrm); if cur_policy%isopen then --close cursor close cur_policy; end if; end; /
Set serveroutput on; declare Cursor cur_policy is select cm.policy_code, cm.applicant_id, cm.period_prem,cm.bank_code,cm.bank_account from t_contract_master cm where cm.liability_state = 2 and cm.policy_type = 1 and cm.policy_cate in ('2','3','4') and rownum < 5 order by cm.policy_code desc; v_policyCode t_contract_master.policy_code%type; v_applicantId t_contract_master.applicant_id%type; v_periodPrem t_contract_master.period_prem%type; v_bankCode t_contract_master.bank_code%type; v_bankAccount t_contract_master.bank_account%type; Begin open cur_policy; Loop Fetch cur_policy into v_policyCode, v_applicantId, v_periodPrem, v_bankCode, v_bankAccount; Exit when cur_policy%notfound; Dbms_Output.put_line(v_policyCode); end loop; Exception when others then close cur_policy; Dbms_Output.put_line(Sqlerrm); if cur_policy%isopen then close cur_policy; end if; end; /
Set serveroutput on; declare Cursor cur_policy is select cm.policy_code, c