`
searchje
  • 浏览: 3458 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

sql and exception

    博客分类:
  • sql
阅读更多
DECLARE
  vinput  VARCHAR2(200);
  voutput VARCHAR2(4000);
BEGIN
  vinput := '1111073124253975';
  FOR x IN (WITH tab1 AS
               (SELECT vinput str FROM dual)
              SELECT regexp_substr(str || ',', '[^,]+', 1, LEVEL) AS c2
                FROM tab1 t
              CONNECT BY LEVEL <=
                         length(regexp_replace(str, '[^,]', NULL)) + 1) LOOP
    dbms_output.put_line('userid:' || x.c2);
    BEGIN
      --tf_f_user
      vtable := 'tf_f_user';
    
      SELECT 'insert into tf_f_user values ' || '(' || user_id || ',' ||
             dummy_tag || ',' || net_type_code || ',' || serial_number || ',' ||
             chr(10) || eparchy_code || ',' || city_code || ',' || cust_id || ',' ||
             usecust_id || ',' || brand_code || ',' || product_id || ',' ||
             chr(10) || user_type_code || ',' || prepay_tag || ',' ||
             service_state_code || ',' || open_mode || ',' || acct_tag || ',' ||
             remove_tag || ',' || to_char(in_date, 'yyyymmddhh24miss') || ',' ||
             chr(10) || to_char(open_date, 'yyyymmddhh24miss') || ',' ||
             to_char(pre_destroy_date, 'yyyymmddhh24miss') || ',' ||
             to_char(destroy_date, 'yyyymmddhh24miss') || ',' || chr(10) ||
             first_call_date || ',' ||
             to_char(last_stop_date, 'yyyymmddhh24miss') || ',' ||
             credit_class || ',' || base_credit_value || ',' ||
             credit_value || ',' || chr(10) || credit_control_id || ',' ||
             changeuser_date || ',' || score_value || ',' ||
             to_char(update_time, 'yyyymmddhh24miss') || ');'
        INTO voutput
        FROM ucr_act1.tf_f_user t
       WHERE t.user_id = x.c2
         AND t.remove_tag = ('0');
      dbms_output.put_line(voutput);
    EXCEPTION
      WHEN no_data_found THEN
        dbms_output.put_line('no ' || vtable || '!');
    END;
    BEGIN
      --tf_f_feepolicy
      vtable := 'tf_f_feepolicy';
    
      SELECT 'insert into tf_f_feepolicy values ' || '(' ||
             feepolicy_ins_id || ',' || id_type || ',' || id || ',' ||
             feepolicy_id || ',' || spec_tag || ',' || rela_user_id || ',' ||
             product_id || ',' || serv_bund_id || ',' || nvl(serv_id, 0) || ',' ||
             nvl(feepolicy_bund_id, 0) || ',' ||
             to_char(start_date, 'yyyymmddhh24miss') || ',' ||
             to_char(end_date, 'yyyymmddhh24miss') || ');'
        INTO voutput
        FROM ucr_act1.tf_f_feepolicy t
       WHERE t.id = x.c2
         AND t.start_date <= SYSDATE
         AND t.end_date >= SYSDATE;
      dbms_output.put_line(voutput);
    EXCEPTION
      WHEN no_data_found THEN
        dbms_output.put_line('no ' || vtable || '!');
    END;
    BEGIN
      --tf_f_user_importinfo
      vtable := 'tf_f_user_importinfo';
      SELECT 'insert into tf_f_user_importinfo values ' || '(' || user_id || ',' ||
             net_type_code || ',' || product_id || ',' || brand_code || ',' ||
             logic_phone || ',' || phyical_phone || ',' ||
             to_char(start_date, 'yyyymmddhh24miss') || ',' ||
             to_char(end_date, 'yyyymmddhh24miss') || ');'
        INTO voutput
        FROM ucr_act1.tf_f_user_importinfo t
       WHERE t.user_id = x.c2
         AND t.start_date <= SYSDATE
         AND t.end_date >= SYSDATE;
      dbms_output.put_line(voutput);
    EXCEPTION
      WHEN no_data_found THEN
        dbms_output.put_line('no ' || vtable || '!');
    END;
    BEGIN
      --tf_f_user_member
      vtable := 'tf_f_user_member';
      SELECT 'insert into tf_f_user_member values ' || '(' || user_id || ',' ||
             member_role_code || ',' || member_role_type || ',' ||
             member_role_id || ',' || member_role_number || ',' ||
             discnt_priority || ',' ||
             to_char(start_date, 'yyyymmddhh24miss') || ',' ||
             to_char(end_date, 'yyyymmddhh24miss') || ');'
        INTO voutput
        FROM ucr_act1.tf_f_user_member t
       WHERE t.user_id = x.c2
         AND t.start_date <= SYSDATE
         AND t.end_date >= SYSDATE;
      dbms_output.put_line(voutput);
    
    EXCEPTION
      WHEN no_data_found THEN
        dbms_output.put_line('no ' || vtable || '!');
    END;  
  END LOOP;
END;
--
--SELECT * FROM ucr_act1.tf_f_user_importinfo t WHERE t.user_id = ('1111073124253975');

分享到:
评论

相关推荐

    PL/SQL%FOUND and EXCEPTION

    通过实例说明在PL/SQL中,%Found, %notfound 和 EXCEPTION的用法

    PL/SQL User's Guide and Reference (官方CHM)

    It offers modern features such as data encapsulation, overloading, collection types, exception handling, and information hiding. PL/SQL also offers seamless SQL access, tight integration with the ...

    Introduction to Oracle SQL and PL/SQL

    《Introduction to Oracle SQL and PL/SQL》是一本专为初学者设计的教程,全面涵盖了Oracle数据库管理系统中的核心语言——SQL(结构化查询语言)和PL/SQL(过程化语言/SQL)。这本书分为两卷,旨在帮助读者从基础到...

    SQL and VB.NET.rar

    标题中的"SQL and VB.NET.rar"表明这是一个关于SQL与VB.NET结合使用的压缩文件包,而描述中的"不错的书"暗示这可能是一本电子书或教程资料,提供了关于这两个主题的结合学习。标签"and SQL VB.NET.rar"进一步确认了...

    Checked and Unchecked Exception

    而iBatis在执行SQL语句时,如果遇到数据库相关问题,如SQL执行错误,也会抛出异常。开发者需要根据具体的框架文档和最佳实践来适当地处理这些异常,确保应用的稳定性和用户体验。 总的来说,理解和正确使用已检查...

    Oracle 10G SQL And PLSQL Reference.rar

    这个压缩包“Oracle 10G SQL And PLSQL Reference.rar”包含了多个指南和资源,帮助用户深入理解这两个核心语言。 SQL(Structured Query Language)是用于管理和操作关系型数据库的标准语言。在Oracle 10G中,SQL...

    Oracle Database 12c PL-SQL programming

    Locate and repair errors and employ exception handlers Execute black box, white box, and integration tests Configure and manage stored packages and libraries Handle security with authentication and ...

    My sql 驱动程序

    而MySQL驱动程序则是实现JDBC接口的具体软件,它允许Java代码通过JDBC调用来执行SQL查询、更新数据库等操作。 MySQL的官方驱动程序被称为"mysql-connector-java",这是一个JAR文件,包含了连接MySQL服务器所需的...

    英文版Oracle PL/SQL Packages and Types Reference

    《Oracle PL/SQL Packages and Types Reference》是一本针对Oracle数据库编程的重要参考资料,主要涵盖了PL/SQL包和类型的详细信息。这本书对于那些具有英文阅读能力的开发者来说,是开发过程中的重要工具,能够帮助...

    oracle-pl-sql-programming-5th-edition

    Explore datatypes, conditional and sequential control statements, loops, exception handling, security features, globalization and localization issues, and the PL/SQL architecture Understand and use ...

    SQL-and-VB.zip_VB_vb sql

    这篇教程——"SQL-and-VB.zip_VB_vb sql"深入探讨了如何在VB应用中有效地集成和使用SQL来创建、查询、更新和管理数据库。 首先,我们需要了解VB中的ADO(ActiveX Data Objects)组件,它是连接数据库的核心工具。...

    cSharp-and-SQL.rar_C#连接sql_c# sql_c# SQL连接_c# sql

    本资源“cSharp-and-SQL.rar”包含了一个关于C#连接SQL的原创程序示例,这对于初学者理解如何在C#中操作SQL数据库非常有帮助。 首先,我们来看C#连接SQL的基本步骤。在C#中,我们可以使用ADO.NET库来实现数据库连接...

    SQL_Assistant_9.5.469_Enterprise_Edition 破解

    SA0033398 - Schema compare raises silent Out of Memory exception and stop when processing large databases with many MBytes of procedural code. SA0033396 - Code-generator generates full multi-part ...

    sql server驱动包

    - 数据源支持:可以通过Java Naming and Directory Interface (JNDI)查找和使用数据源。 5. 性能优化: -批处理:通过一次发送多个SQL命令,提高性能。 - 缓存预编译的SQL语句(PreparedStatement)以减少解析...

    NC后台sql语句执行的方式

    whereSql = "isnull(dr, 0) = 0 and isourcebilltype = " + IComparisonCONST.SOURCE_TYPE_PS_REC + " and isourcebusi = " + IComparisonCONST.SOURCE_BIZ_TYPE_PS_GET; } else { // 对应付款结算单 whereSql =...

    Microsoft SQL 2007年认证试题(英文PDF版)

    This is typically done by adding an exception rule for SQL Server or by configuring the firewall to allow incoming traffic on port 1433. --- #### Question 4: Writing Distributed Queries Between Two...

    Sql语句_SQL语句_plsql_

    -- SQL and PL/SQL statements EXCEPTION WHEN error_type THEN -- Exception handling END; ``` 2. **过程和函数**:PL/SQL支持创建自定义过程和函数,可以接受参数并返回结果。它们可以被其他PL/SQL代码或...

    javax.xml.bind.jar and sqljdbc42.jar

    主要解决Java连接Sql Server报错:Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter 另外赠送一个Sql 的jdbc驱动

    连接sql server的驱动包

    这个版本的驱动包含了对Java的Enhanced Date and Time Types的支持,比如java.time.LocalDate和java.time.LocalDateTime。这使得Java 8及以上版本的应用程序能更好地与SQL Server中的日期和时间类型进行交互。 使用...

    pl/sql学习笔记

    PL/SQL支持多种运算符,包括算术运算符(+、-、*、/、MOD)、比较运算符(=、、&lt;、&gt;、、&gt;=)和逻辑运算符(AND、OR、NOT)。这些运算符用于计算或比较表达式。 6. **CONDITIONAL CONTROL** 条件控制语句如IF-THEN...

Global site tag (gtag.js) - Google Analytics