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. 06_检测本机当前用户是否为超级管理员,如果是管理员,则使用 yum 安装 vsftpd,如果不是,则提示您非管理员(使用子串对比版本)

    #!/bin/bashif [ $USER == "root" ];then #或者 if [ $UID -eq 0 ];then    yum -y install vsftpd ...

  2. SIGCHLD函数

    SIGCHLD的产生条件 子进程终止时 子进程接收到SIGSTOP信号停止时 子进程处在停止态,接受到SIGCONT后唤醒时 借助SIGCHLD信号回收子进程 子进程结束运行,其父进程会收到SIGCH ...

  3. Git入门(待更)

    github是什么? 以下截取自百度百科 github: GitHub 是一个面向开源及私有软件项目的托管平台,因为只支持 Git 作为唯一的版本库格式进行托管,故名 GitHub. GitHub 于 ...

  4. JavaWeb_(Spring框架)Spring中的aop事务

    1.事务相关知识 a)什么是事务:把多条数据库操作捆绑到一起执行,要么都成功,要么都失败: b)事务的原则ACID: i.原子性:事务包含的所有操作,要么全部成功,要么全部失败回滚,成功全部应用到数据 ...

  5. JavaWeb_(Spring框架)注解配置

    系列博文 JavaWeb_(Spring框架)xml配置文件  传送门 JavaWeb_(Spring框架)注解配置 传送门 Spring注解配置 a)导包和约束:基本包.aop包+context约束 ...

  6. easyui-combobox和C标签判断回显

    <td width="40%"> <select class="easyui-combobox" id="work_property ...

  7. 冲刺阶段——Day2

    [今日进展] 完成黄金点游戏的算法与代码架构. 使用文字界面完成任务 码云链接:https://gitee.com/jxxydwt1999/20175215-java/blob/master/Gold ...

  8. SCRIPT438: 对象不支持“trim”属性或方法

    关于ie9以下不支持trim()方法 可以在自己封装的框架中加入如下.或直接调用也行. if(!String.prototype.trim) { String.prototype.trim = fun ...

  9. [go]grpc远程接口调用实现

    // grpc序列化/反序列化成对应语言的对象 // 1.写idl(数据类型+方法) // 2.生成对应语言的序列化/反序列化代码 // 3.方法需要自己实现 // 环境(将gopath/bin加入p ...

  10. Java同步数据结构之SynchronousQueue

    前言 严格来说SynchronousQueue并不是像它的名字那样是一种Queue,它更像是一个数据接力的交汇点,还记得在介绍Exchanger的时候提到过Exchanger可以看作是Synchron ...