zoukankan      html  css  js  c++  java
  • oracle 存储过程

    create or replace procedure p_insert_caz_lims as v_sqlcode TLIMSERRORINFO.ERROR_CODE%type; v_msg TLIMSERRORINFO.error_msg%type; begin insert into TLIMSERRORINFO (ERROR_ID, error_code, error_msg, error_date, error_program) values (SEQ_TLIMSERRORINFO.nextval, '0', '执行开始', sysdate, 'p_insert_caz_lims'); declare cursor lims_info is select zzdm, zzmc, cyd, ypmc, fxxm, r_units, qy, to_char(r_value) as r_value, to_char(r_text) as r_text, to_char(cysj) as rtime, to_char(rzsj) as dtime, batch_name, r_out_of_range, mv_range, grade from CAZ_LIMS_ALL_VIEW@DLINK_CAZ.REGRESS.RDBMS.DEV.US.ORACLE.COM where to_date(rzsj, 'yyyy-mm-dd HH24:mi:ss') > trunc(sysdate)-2 and rzsj is not null; limsstop lims_info%rowtype; DATA_COUNT number(10); begin open lims_info; loop fetch lims_info into limsstop; exit when lims_info%NOTFOUND; begin select count(id) into DATA_COUNT from tlimsoriginaldata where rtime = to_date(limsstop.rtime,'yyyy-mm-dd HH24:mi:ss') and dtime = to_date(limsstop.dtime,'yyyy-mm-dd HH24:mi:ss') and locationid = limsstop.zzdm and locationname = limsstop.zzmc and samplingpoint = limsstop.cyd and samplename = limsstop.ypmc and rname = limsstop.fxxm and qy = 'CAZ'; if DATA_COUNT = 0 then insert into TLIMSORIGINALDATA (id, locationid, locationname, samplingpoint, samplename, rname, units, qy, rvalue, rtime, dtime, batch_name, rtext, r_out_of_range, mv_range, grade) values (SEQ_TLIMSORIGINALDATA.nextval, limsstop.zzdm, limsstop.zzmc, limsstop.cyd, limsstop.ypmc, limsstop.fxxm, limsstop.r_units, limsstop.qy, limsstop.r_value, to_date(limsstop.rtime, 'yyyy-mm-dd hh24:mi:ss'), to_date(limsstop.dtime, 'yyyy-mm-dd hh24:mi:ss'), limsstop.batch_name, limsstop.r_text, limsstop.r_out_of_range, limsstop.mv_range, limsstop.grade); end if; end; end loop; close lims_info; insert into TLIMSERRORINFO (ERROR_ID, error_code, error_msg, error_date, error_program) values (SEQ_TLIMSERRORINFO.nextval, '1', '执行成功', sysdate, 'p_insert_caz_lims'); exception when others then v_sqlcode := sqlcode; v_msg := sqlerrm; insert into TLIMSERRORINFO (ERROR_ID, error_code, error_msg, error_date, error_program) values (SEQ_TLIMSERRORINFO.nextval, v_sqlcode, v_msg, sysdate, 'p_insert_caz_lims'); end; end p_insert_caz_lims;
  • 相关阅读:
    Postgresql中string转换成timestamp类型
    zTree节点重叠或者遮挡
    Powerdesigner+Execel
    Powerdesigner+PostgreSQL
    PostgreSQL 的 distinct on 的理解
    PostgreSql问题:ERROR: operator does not exist: timestamp without time zone > character varying
    git分支小问题
    SSH问题:系统启动时,spring配置文件解析失败,报”cvc-elt.1: 找不到元素 'beans' 的声明“异常
    PostgresSQL中的限制和级联删除
    sql语句添加删除外键及其约束
  • 原文地址:https://www.cnblogs.com/xu3593/p/3884906.html
Copyright © 2011-2022 走看看