oracle-function-into时为null报错

 create or replace function P_ADD_CUSTOMER_FOR_CSS_heyt_test(i_cust_name          in varchar2,
i_en_name in varchar2,
i_cust_sex in varchar2,
i_cust_birthday in date,
i_cust_id_type in varchar2,
i_cust_id_no in varchar2,
i_data_quality_level in char,
i_death_date in date,
i_part_code in varchar2,
i_risk_level_time in date,
i_risk_level in varchar2,
i_risk_level_reason in varchar2,
i_risk_level_user in varchar2,
i_address in varchar2,
i_postcode in varchar2,
i_landline_phone in varchar2,
i_mobile in varchar2,
i_email in varchar2,
i_papers_effect_date in date,
i_papers_matu_date in date,
i_occupation_grade in varchar2,
i_occupation_code in varchar2,
i_nationality in varchar2,
i_sys_source in varchar2,
i_cif_cust_no in varchar2,
i_oper in varchar2,
i_remark in varchar2)
return varchar2 is
tInsuredNo varchar2(20);
tInsuredNo_temp varchar2(20);
i_cust_id_type_temp varchar2(20);
i_cust_sex_temp varchar2(5); --pragma autonomous_transaction;
--tInsuredNo ldperson.customerno%type;
begin
DBMS_OUTPUT.put_line('sql:'||'查询客户号开始');
begin
DBMS_OUTPUT.put_line('sql:'||i_cust_id_no);
DBMS_OUTPUT.put_line('sql:'||i_cust_name);
DBMS_OUTPUT.put_line('sql:'||i_cust_id_type);
DBMS_OUTPUT.put_line('sql:'||i_cust_id_no);
DBMS_OUTPUT.put_line('sql:'||i_cust_birthday);
DBMS_OUTPUT.put_line('sql:'||i_cust_sex);
Execute Immediate 'ALTER SESSION SET NLS_DATE_FORMAT = ''YYYY-MM-DD HH24:MI:SS'''; select count(1)
into tInsuredNo_temp
from ldperson_heyt_test t
where t.customername = i_cust_name
and t.idtype = decode(i_cust_id_type,'','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','',i_cust_id_type)
and UPPER(t.idno) = UPPER(i_cust_id_no)
and t.birthday = i_cust_birthday
and t.gender = decode(i_cust_sex,'','','','','','','')
and rownum = 1; if tInsuredNo_temp != 0 then
select t.customerno
into tInsuredNo
from ldperson_heyt_test t
where t.customername = i_cust_name
and t.idtype = decode(i_cust_id_type,'','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','',i_cust_id_type)
and UPPER(t.idno) = UPPER(i_cust_id_no)
and t.birthday = i_cust_birthday
and t.gender = decode(i_cust_sex,'','','','','','','')
and rownum = 1;
return tInsuredNo;
end if;
DBMS_OUTPUT.put_line('sql:'||'查询客户号结束'); --如果客户号存不存在即需要生成客户号,添加客户地址两张表
if tInsuredNo_temp = 0 Then
DBMS_OUTPUT.put_line('sql:'||'查询客户号未找到,需要生成');
Execute Immediate 'ALTER SESSION SET NLS_DATE_FORMAT = ''YYYY-MM-DD HH24:MI:SS'''; select decode(i_cust_id_type,'','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','',i_cust_id_type) into i_cust_id_type_temp from dual;
select decode(i_cust_sex,'','','','','','','') into i_cust_sex_temp from dual; --调用生成规则
tInsuredNo := 'CP' || lpad(createmaxno('CUSTOMERNO', 'SN'), 18, '');
DBMS_OUTPUT.put_line('sql:'||'客户号已生成'); Execute Immediate 'insert into ldperson (CustomerNo, CustomerName, Gender, Birthday, IDType, IDNo, IDInitiateDate, IDExpiryDate, Nationality, OccupationType, OccupationCode, DeathDate, NameEn, Remark, managecom, comcode, makeoperator, makedate, maketime, modifyoperator, modifydate, modifytime) Values
('''||tInsuredNo||''','''||i_cust_name||''','''||i_cust_sex_temp||''','''||i_cust_birthday||''','''||i_cust_id_type_temp||''','''||i_cust_id_no||''','''||i_papers_effect_date||''','''||i_papers_matu_date||''','''||i_nationality||''','''||i_occupation_grade||''','''||i_occupation_code||''','''||i_death_date||''','''||i_en_name||''','''||i_remark||''','''||''||''','''||''||''','''||i_oper||''','''||sysdate||''','''||'00:00:00'||''','''||i_oper||''','''||sysdate||''','''||'00:00:00'||''')';
DBMS_OUTPUT.put_line('sql:'||'添加客户完成'); Execute Immediate 'insert into ldpersoncontactinfo (CustomerNo,PostalAddress,ZipCode,Phone,Mobile1,EMail1, makeoperator, makedate, maketime, modifyoperator, modifydate, modifytime)values ('''||tInsuredNo||''','''||i_address||''','''||i_postcode||''','''||i_landline_phone||''','''||i_mobile||''','''||i_email||''','''||i_oper||''','''||sysdate||''','''||'00:00:00'||''','''||i_oper||''','''||sysdate||''','''||'00:00:00'||''')';
DBMS_OUTPUT.put_line('sql:'||'添加地址完成'); Execute Immediate 'commit';
elsif tInsuredNo IS not null then
return(tInsuredNo);
End If;
return(tInsuredNo);
end;
Exception When Others Then
dbms_output.put_line('sqlcode:'||sqlcode);
DBMS_OUTPUT.put_line('sqlerrm:'||substr(sqlerrm,1,100));
Execute Immediate 'rollback';
return(tInsuredNo);
end P_ADD_CUSTOMER_FOR_CSS_heyt_test;
/

oracle-function-into时为null报错的更多相关文章

  1. 数据库 插入时 碰到NULL报错判断的一种方法(技巧)

    //public static object ToDBNull(object value) 判断插入数据的时候个别参数不能为空的时候做的判断方法 //{ // if (value == null) / ...

  2. 连接远程MySQL数据库项目启动时,不报错但是卡住不继续启动的,

    连接远程MySQL数据库项目启动时,不报错但是卡住不继续启动的, 2018-03-12 17:08:52.532DEBUG[localhost-startStop-1]o.s.beans.factor ...

  3. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:4.安装Oracle RAC FAQ-4.1.系统界面报错Gnome

    1.错误信息:登录系统后,屏幕弹出几个错误对话框,无菜单.无按钮 GConf error: Failed to contact configuration server; some possible ...

  4. soamanager发布的Webservice服务,调用时出现http500报错

    最近再给薪酬那边发布ws服务时出现了报错,调用方反馈了errorCode:BEA-380002.在使用XMLspy工具去调用这个WSDL时候,则反馈http500的错误消息.如下图: 遇到这种问题我通 ...

  5. 当子查询内存在ORDER BY 字句时查询会报错

    问题:当子查询内存在ORDER BY 字句时查询会报错 SQL: SELECT * FROM ( SELECT * FROM USER ORDER BY USER_CORD ) S. 解决办法:在子查 ...

  6. 关于使用CodeFirst,修改类或上下文时操作数据库报错解决方法

    在操作已经创建好的数据库时,若是添加新的实体类或者修改原有数据库上下文,会报如下错误: The model backing the 'StudentDbContext' context has cha ...

  7. nuget包管理nuget服务器发布包时出现请求报错 406 (Not Acceptable)

    在window服务器上部署nuget服务器时,发布包时出现请求报错 406 (Not Acceptable) 验证用户名.密码正确的情况下,还是出现上面错误.后面跟踪服务器日志,发现window\te ...

  8. Jenkins安装时Web页面报错提示离线安装

    先跳过所有. 方法1 先看它的提示:”参考离线Jenkins安装文档“发现链接点不开,我还以为是被墙了呢,FQ以后还是打不开.看来这个参考文档是没有用滴.点击配置HTTP代理跳出如下界面:安装Jenk ...

  9. python3写入文件时编码问题报错

    在字符串写入文件时,有时会因编码问题导致无法写入,可在open方法中指定encoding参数 chfile = open(filename, 'w', encoding='utf-8') 这样可解决大 ...

随机推荐

  1. springboot o.a.tomcat.util.scan.StandardJarScanner : Failed to scan [file:/D:/apache-maven-3.0.5[系统找不到指定路径]

    报错信息: 2019-11-04 11:05:52.404 WARN 4512 --- [ main] o.a.tomcat.util.scan.StandardJarScanner : Failed ...

  2. Spring boot请求参数

    GET请求: 1.restful风格: @GetMapping("/order/detail") public BaseOutput omsQueryDetail(@Request ...

  3. 【AGC030F】Permutation and Minimum(DP)

    题目链接 题解 首先可以想到分组后,去掉两边都填了数的组. 然后就会剩下\((-1,-1)\)和\((-1,x)\)或\((x,-1)\)这两种情况 因为是最小值序列的情况数,我们可以考虑从大到小填数 ...

  4. Liunx之django项目部署

    一.python web 项目部署 python django默认启动python3 manage.py runserver 0.0.0.0:8000这种方式调用wsgiref单机模块,性能较低,生产 ...

  5. puppeteer爬虫服务

    爬虫文件 baidu.js const puppeteer = require("puppeteer"); const path = require('path'); const ...

  6. DQL:查询表中数据

    1. 基础查询 (1) 查询整表 SELECT * FROM 表名; -- 不推荐使用"*",不方便阅读 (2) 选择性查询 SELECT 列名,列名,列名 FROM 表名; (3 ...

  7. 重读APUE(10)-中断的系统调用

    如果进程在执行一个低速系统调用而阻塞期间捕获到一个信号,则该系统调用就会被中断而不再继续执行:该系统调用返回出错,其errno设置为EINTR: 系统将系统调用分成两类:低速系统调用和其他系统调用:低 ...

  8. go -- application/x-www-form-urlencoded发送post数据

  9. Flutter移动电商实战 --(34)列表页_小BUG的修复

    当高粱酒的子类没有数据返回的时候就会报错. 解决接口空数据报错的问题 没有数据的时候,给用户一个友好的提示, 我们没有数据的时候还要告诉用户,提示一下他没有数据,在我们的右侧列表的build方法内去判 ...

  10. python 简单了解一下 描述器

    1.描述器是什么? 在Python中描述器也被称为描述符, 1)描述器实际上是任何新式类(新式类是继承自 type 或者 object 的类),这种类至少实现了3个特殊的方法__get__, __se ...