zoukankan      html  css  js  c++  java
  • oracle 游标循环, 查询,异常捕获,继续执行

    declare
           --类型定义
           strsql string(500);
            v_ErrorCode NUMBER;           -- Variable to hold the error message code  
            v_ErrorText VARCHAR2(200);    -- Variable to hold the error message text  
           cursor c_eventstate
           is
           Select  CampaignId,phonenumber,PolicyNumber from mkt_eventstate a where synstate =0 and packagestate = 2 and errorcode = 6;
           --定义一个游标变量v_cinfo c_emp%ROWTYPE ,该类型为游标c_emp中的一行数据类型
           c_row c_eventstate%rowtype;
    begin
           for c_row in c_eventstate loop
              begin
              strsql:='select * from mkt_userprizeinfo t where t.campaignid='||c_row.CampaignId||' and t.userid='||c_row.phonenumber||' and t.PolicyNumber='''||c_row.PolicyNumber||'''';
              execute immediate strsql ;
             dbms_output.put_line(c_row.CampaignId||'-'||c_row.phonenumber||'-'||c_row.PolicyNumber);
            -- RAISE_APPLICATION_ERROR(-20001,'数值不能为0');
              EXCEPTION
             --捕捉异常
             WHEN others THEN
               begin
                  v_ErrorCode := SQLCODE;  
                  v_ErrorText := SUBSTR(SQLERRM, 1, 200); 
               DBMS_OUTPUT.put_line('捕获了错误begin');
               dbms_output.put_line(c_row.CampaignId||'-'||c_row.phonenumber||'-'||c_row.PolicyNumber||'-'||v_ErrorCode || '::'||v_ErrorText);
               DBMS_OUTPUT.put_line('捕获了错误end');
               end;
             end;
           
           end loop;    
    end;

  • 相关阅读:
    SQLite存储类(数据类型)
    SQLite常用命令
    C# 跨线程操作无效
    Android打开新的Activity并同时关闭当前Activity
    SQLite实现Top功能
    Android调用Sqlite数据库时自动生成db-journal文件的原因
    C#使用SqlDataReader读取数据库数据时CommandBehavior.CloseConnection参数的作用
    Android计算时间差
    PS通道抠图总结
    Android再次激活Activity时触发事件用于列表重新读取载入
  • 原文地址:https://www.cnblogs.com/linbl/p/4565746.html
Copyright © 2011-2022 走看看