先创建包,再创建包体
---------------创建包体---------------------
create or replace package body pkg_yygl_service
Is
PROCEDURE p_service(as_date In Varchar2)
As Begin
p_zgda(as_date);
p_rydd(as_date);
p_rylz(as_date);
End p_service; Procedure p_job
As
ls_date Varchar2();
ls_newxh Varchar2();
Begin
Select to_char(Sysdate(),'yyyymmdd') Into ls_date From dual;
p_getxhb('RSGL_ZDFWZXJL',ls_newxh);
insert into RSGL_ZDFWZXJL(XH,lb,RQ,ZXsj) values(ls_newxh,'自动服务',ls_date,sysdate);
p_service(ls_date); End p_job;
procedure p_getxhb(as_tablename In Varchar2, xh Out Varchar2)
As
li_dqz Int;
li_zz Int;
Begin
Select dqz,decode(zz,Null,,) Into li_dqz,li_zz From xt_xhb Where bm=as_tablename;
li_dqz := li_dqz +li_zz;
Update xt_xhb Set dqz = li_dqz Where bm=as_tablename;
xh := to_char(li_dqz);
exception
when no_data_found then
Insert Into xt_xhb Values(as_tablename,,);
xh := '';
End p_getxhb; --初始化科室代码
Procedure p_init_ksdm(as_rootid In Varchar2,as_ksdm In Varchar2,as_last In Varchar2)
As
ls_ksdm Varchar2();
ls_jb Numeric();
ls_sjid Varchar2();
ls_tempdm Varchar2();
ls_mjpb Numeric();
ls_ksid Varchar2();
CURSOR c1 (p1 Varchar2) Is
Select ksid From rsgl_ksdm Where sjid=p1;
Begin
Select nvl(mjpb,),ksdm Into ls_mjpb, ls_ksdm From rsgl_ksdm Where ksid=as_rootid;
If(as_ksdm Is Null) Then
Select length(''||to_char(to_number(as_last)+))- Into ls_jb From dual;
Select ''||to_char(to_number(as_last)+) Into ls_sjid From dual;
Update rsgl_ksdm Set ksdm=substr(ls_sjid,ls_jb,) Where ksid=as_rootid;
Else
Update rsgl_ksdm Set ksdm=nvl(as_ksdm,'')||substr(''||to_char(to_number(as_last)+),length(''||to_char(to_number(as_last)+))-,) Where ksid=as_rootid;
End If;
If ls_mjpb= Then
ls_tempdm:='';
Open c1(as_rootid);
Loop
FETCH c1 Into ls_ksid;
IF c1 %NOTFOUND THEN EXIT; END IF;
p_init_ksdm(ls_ksid,ls_ksdm,ls_tempdm);
ls_tempdm:=substr(''||to_char(to_number(ls_tempdm)+),length(''||to_char(to_number(ls_tempdm)+))-,);
END LOOP;
CLOSE c1;
End If ;
End p_init_ksdm; --处理职工档案
Procedure p_zgda(as_dt In Varchar2)
As
Cursor c1 (p1 Varchar2) Is
Select xh,zgid From rsgl_ygjcjl where to_char(rq,'YYYYMMDD')=p1 And lb= and zt=;
ls_zgid Varchar2();
ls_xh Varchar2();
Begin
Open c1(as_dt);
LOOP
FETCH c1 Into ls_xh,ls_zgid;
IF c1 %NOTFOUND THEN EXIT; END IF;
Update rsgl_zgda Set sypb = ,zxpb= Where zgid = ls_zgid;
Update rsgl_ygjcjl Set zt = Where xh = ls_xh;
END LOOP;
CLOSE c1;
End p_zgda; --处理人员调动
Procedure p_rydd(as_dt In Varchar2)
As
CURSOR c1 (p1 Varchar2) IS
Select xh,zgid,zrks,zcks,zrylz,zcylz from rsgl_zgdd where to_char(bdrq,'YYYYMMDD')=p1 And dqzt=;
ls_zgid Varchar2();
ls_zrks Varchar2();
ls_zcks Varchar2();
ls_zrylz Varchar2();
ls_zcylz Varchar2();
ls_xh Varchar2();
ls_newxh Varchar2();
Begin
Open c1(as_dt);
LOOP
FETCH c1 Into ls_xh,ls_zgid,ls_zrks,ls_zcks,ls_zrylz,ls_zcylz;
IF c1 %NOTFOUND THEN EXIT; END IF; if ls_zrks is not null then
Update rsgl_zgda Set szks = ls_zrks Where zgid = ls_zgid; --所在科室
end if; if ls_zrylz is not null then
Update rsgl_zgda Set ylzid = ls_zrylz Where zgid = ls_zgid;--考勤组
end if; Update rsgl_zgdd Set dqzt = Where xh = ls_xh;
p_zgdals(ls_zgid); p_getxhb('RSGL_ZDFWZXJL',ls_newxh);
insert into RSGL_ZDFWZXJL(xh,lb,Zgid,RQ,ZXsj) values(ls_newxh,'自动服务人员调动',ls_zgid,as_dt,sysdate);
END LOOP; CLOSE c1;
End p_rydd; --处理人员轮转
Procedure p_rylz(as_dt In Varchar2)
As
CURSOR c1 (p1 Varchar2) IS
Select b.xh,b.zgid,a.ksid,a.zt From rsgl_lzjhmx a,rsgl_lzjh b Where a.xh=b.xh And (b.zt= Or b.zt=) and (a.zt= or a.zt=) And (to_char(a.kssj,'yyyymmdd') =p1 or to_char(a.jssj+,'yyyymmdd') =p1);
ls_xh Varchar2();
ls_zgid Varchar2();
ls_oldszks Varchar2();
ls_szks Varchar2();
ls_oldylzid Varchar2();
ls_ylzid Varchar2();
li_zt Int;
ls_newxh Varchar2();
/*ls_sjid Varchar2(10);*/
xtcs_RSGL_LZKSDD Varchar2();
li_count Int;
Begin
xtcs_RSGL_LZKSDD:=F_GET_XTCS('RSGL_LZKSDD');--1人事科室跟着考勤组调, 只调考勤组
Open C1(as_dt);
LOOP
FETCH c1 Into ls_xh,ls_zgid,ls_ylzid,li_zt;
IF c1 %NOTFOUND THEN EXIT; END IF;
if xtcs_RSGL_LZKSDD='' or xtcs_RSGL_LZKSDD='' then if li_zt= then
Select ylzid,szks Into ls_oldylzid,ls_oldszks From rsgl_zgda Where zgid=ls_zgid;
if(xtcs_RSGL_LZKSDD ='') then
select count() into li_count from rsgl_ksdm where ksid =ls_ylzid and rskspb= and mjpb='';
if(li_count=) then
ls_szks :=ls_ylzid;
else
ls_szks := pkg_yygl_service.f_getrskssjid(ls_ylzid);
/*原来只支持两层 注释掉 select sjid into ls_sjid from rsgl_ksdm where ksid =ls_ylzid;
select count(1) into li_count from rsgl_ksdm where ksid =ls_sjid and rskspb=1 and mjpb='1';
if(li_count=1) then
ls_szks :=ls_sjid;
else
ls_szks := ls_oldszks;
end if;*/
end if;
else
ls_szks := ls_oldszks;
end if; Update rsgl_zgda Set ylzid=ls_ylzid,szks=ls_szks Where zgid = ls_zgid; update rsgl_lzjh set zt= where xh=ls_xh and zt=; Update rsgl_lzjhmx Set zt = Where xh = ls_xh And to_char(kssj,'yyyymmdd') =as_dt;
Update rsgl_lzjhmx Set zt = Where xh = ls_xh And to_char(jssj+,'yyyymmdd') =as_dt And zt=; p_getxhb('RSGL_ZGDD',ls_newxh);
Insert Into rsgl_zgdd (xh,zgid,bdrq,zrks,zcks,zrylz,zcylz,ddlx,dqzt,czid,bz,czrq)
Values(ls_newxh,ls_zgid,to_date(to_char(Sysdate,'yyyy-mm-dd'),'yyyy-mm-dd'),ls_szks,ls_oldszks,ls_ylzid,ls_oldylzid,,,'p_service','后台服务处理轮转调动',Sysdate);
p_zgdals(ls_zgid);
delete rsgl_kqls where zgid=ls_zgid and to_char(kqrq,'yyyy-mm-dd')>=to_char(Sysdate,'yyyy-mm-dd') and ksid=ls_oldylzid;
delete rsgl_ksygkqpb where zgid=ls_zgid and to_char(rq,'yyyy-mm-dd')>=to_char(Sysdate,'yyyy-mm-dd') and ksid=ls_oldylzid; else
Update rsgl_lzjhmx Set zt = Where xh = ls_xh And to_char(jssj+,'yyyymmdd') =as_dt And zt=;
select count(*) into li_count from rsgl_lzjh where xh=ls_xh and jsrq<sysdate and zt=;
if(li_count=) then
update rsgl_lzjh set zt= where xh=ls_xh and zt=;
Update rsgl_zgda Set lbsx='' Where zgid = ls_zgid;
end if;
end if;
else --轮转科室不做实际调转
if li_zt= then
update rsgl_lzjh set zt= where xh=ls_xh and zt=; Update rsgl_lzjhmx Set zt = Where xh = ls_xh And to_char(jssj+,'yyyymmdd') =as_dt And zt=;
Update rsgl_lzjhmx Set zt = Where xh = ls_xh And to_char(kssj,'yyyymmdd') =as_dt;
else
select count(*) into li_count from rsgl_lzjh where xh=ls_xh and jsrq<sysdate ;
if(li_count=) then
Update rsgl_lzjhmx Set zt = Where xh = ls_xh And to_char(jssj+,'yyyymmdd') =as_dt And zt=;
update rsgl_lzjh set zt= where xh=ls_xh ;
Update rsgl_zgda Set lbsx='' Where zgid = ls_zgid;
end if;
end if;
end if;
p_getxhb('RSGL_ZDFWZXJL',ls_newxh);
insert into RSGL_ZDFWZXJL(xh,lb,Zgid,RQ,ZXsj) values(ls_newxh,'自动服务人员轮转',ls_zgid,as_dt,sysdate);
END LOOP;
CLOSE c1;
End p_rylz; --处理历史档案表
Procedure p_zgdals(as_zgid In Varchar2)
As
strtoday Varchar2();
stryestoday Varchar2();
rowcount1 Int;
Begin
Select to_char(Sysdate,'YYYY-MM-DD') Into strtoday From dual;
Select to_char(Sysdate-,'YYYY-MM-DD') Into stryestoday From dual;
Select count(*) Into rowcount1 from rsgl_zgdals where zgid=as_zgid and to_char(ksrq,'YYYY-MM-DD')=strtoday And to_char(jsrq,'YYYY-MM-DD')='2900-01-01';
If rowcount1=
Then
update rsgl_zgdals set jsrq=to_date(stryestoday,'yyyy-mm-dd') where zgid=as_zgid and to_char(jsrq,'YYYY-MM-DD')='2900-01-01';
Else
delete from rsgl_zgdals where zgid=as_zgid and to_char(ksrq,'YYYY-MM-DD')=strtoday and to_char(jsrq,'YYYY-MM-DD')='2900-01-01';
End If; insert into rsgl_zgdals (zgid,zggh, xm,xb,xl,mz,csrq,sfz,jtdz,jtyb,dzyj,jtdh, grdh, cjgzsj,szks,dyrq,zgxz,zjfs,zxpb, zxrq,zxyy,zw,zc,zglb,xzjb,jg,srm1,srm2,srm3,sypb, dlkl, gj,ryxz,zzmh,rdsj,bysj1, dexl,bysj2, zchdsj,byxx,sxzy,bz, wkxz,wkszd,kqpb, xgrq,czid,lbsx,xz,xw,hyzk,gzdh,yhmc,yhzh,yanlaobx,yiliaobx,sybxzh,zfgjjzh,htlb,htksrq,htjsrq,syqpb,syksrq,syjsrq,zyzg,zghdrq,ksrq,jsrq,dslb,dslbsj,rcpy, rcpysj, xhrz,rzsj,szxk,szxk2,szxk3,ynqz,kjbz,xj,xjd,gl,dsid,hspb,gzffpb,hl,gwdj,xxzrmsj,xxzrznx,qzw,qxzrmsj,qxzrznx,xjsjssj,xjsprsj,xjsrznx,qzc,qjsjssj,qjsrznx,qjsprsj,jpzc,jpsj,xgrdj,xgrprsj,xgrrznx,ygrdj,ygrprsj,ygrrznx,tglb,zsgl,fggl,zjnx,tgnx,xwsj,jylb,pg,brsbdj,ksjyfhjb,qdjb,gzbz,zzpb,gbpb,htgpb,bianzhi,gzsb,yppb,txpb,kqpxxh,jylb1,jylb2,ylzid) select zgid,zggh, xm,xb,xl,mz,csrq,sfz,jtdz,jtyb,dzyj, jtdh, grdh, cjgzsj,szks,dyrq,zgxz,zjfs,zxpb, zxrq,zxyy,zw,zc,zglb,xzjb,jg,srm1,srm2,srm3,sypb, dlkl, gj,ryxz,zzmh,rdsj,bysj1, dexl,bysj2, zchdsj,byxx,sxzy,bz, wkxz,wkszd,kqpb, xgrq,czid,lbsx ,xz,xw,hyzk,gzdh,yhmc,yhzh,yanlaobx,yiliaobx,sybxzh,zfgjjzh,htlb,htksrq,htjsrq,syqpb,syksrq,syjsrq,zyzg,zghdrq,
to_date(strtoday,'yyyy-mm-dd'),to_date('2900-01-01','YYYY-MM-DD'),dslb,dslbsj,rcpy, rcpysj, xhrz,rzsj,szxk,szxk2,szxk3,ynqz,kjbz,xj,xjd,gl,dsid,hspb,gzffpb,hl,ygrdj,xxzrmsj,xxzrznx,qzw,qxzrmsj,qxzrznx,xjsjssj,xjsprsj,xjsrznx,qzc,qjsjssj,qjsrznx,qjsprsj,jpzc,jpsj,xgrdj,xgrprsj,xgrrznx,ygrdj,ygrprsj,ygrrznx,tglb,zsgl,fggl,zjnx,tgnx,xwsj,jylb,pg,brsbdj,ksjyfhjb,qdjb,gzbz,zzpb,gbpb,htgpb,bianzhi,gzsb,yppb,txpb,kqpxxh,jylb1,jylb2,ylzid from rsgl_zgda where zgid=as_zgid ; End p_zgdals; function f_getrskssjid(ls_ksid varchar) return varchar2--返回该科室的上级人事科室
is
ls_sjid Varchar2();
li_count Int;
ls_szks Varchar2();
begin
select sjid into ls_sjid from rsgl_ksdm where ksid =ls_ksid;
select count() into li_count from rsgl_ksdm where ksid =ls_sjid and rskspb=;
if(li_count=) then
ls_szks :=ls_sjid;
else
ls_szks := f_getrskssjid(ls_sjid);
end if;
return(ls_szks);
end f_getrskssjid; end pkg_yygl_service; --------------------创建包------------

create or replace package pkg_yygl_service is


-- Author : MOJIAOYANG
-- Created : 2006-9-9 上午 11:27:54
-- Purpose : 医院管理后台服务程序
-- 最近更新 : 2014-09-28 tangwei


Type cursorType Is Ref Cursor;
Procedure p_service(as_date In Varchar2);


--得到序号表序号
procedure p_getxhb(as_tablename In Varchar2, xh Out Varchar2);
--自动任务
Procedure p_job;
--初始化科室代码;
Procedure p_init_ksdm(as_rootid In Varchar2,
as_ksdm In Varchar2,
as_last In Varchar2);


--处理职工档案
Procedure p_zgda(as_dt In Varchar2);
--处理职工档案历史
Procedure p_zgdals(as_zgid In Varchar2);
--处理人员调动
Procedure p_rydd(as_dt In Varchar2);
--处理人员轮转
Procedure p_rylz(as_dt In Varchar2);
--获取人事科室上级ID函数
function f_getrskssjid (ls_ksid varchar) return varchar2;


end pkg_yygl_service;


oracle 之 包,包体创建和使用案例的更多相关文章

  1. oracle函数、包、变量的定义和使用、重点”结构体和数组”

    函数 实例1:输入雇员的姓名,返回该雇员的年薪 create function fun1(spName varchar2) ,); begin +nvl(comm,) into yearSal fro ...

  2. ORACLE之UTL_FILE包详解

    1 Utl_File包简介Oracle的UTL_FILE包用来实现对磁盘文件的I/O操作.(1)Oracle10g之前的版本需要指定utl_file包可以操作的目录.      方法:        ...

  3. Oracle DBA管理包脚本系列(二)

    该系列脚本结合日常工作,方便DBA做数据管理.迁移.同步等功能,以下为该系列的脚本,按照功能划分不同的包.功能有如下: 1)数据库对象管理(添加.修改.删除.禁用/启用.编译.去重复.闪回.文件读写. ...

  4. oracle中utl_file包读写文件操作实例学习

    在oracle中utl_file包提供了一些操作文本文件的函数和过程,学习了一下他的基本操作 1.创建directory,并给用户授权 复制代码 代码如下: --创建directory create ...

  5. Oracle数据库程序包全局变量的应用

    1 前言  在程序实现过程中,经常用遇到一些全局变量或常数.在程序开发过程中,往往会将该变量或常数存储于临时表或前台程序的全局变量中,由此带来运行效率降低<频繁读取临时表>或安全隐患< ...

  6. 160322、Maven手动安装Oracle的jar包

    oracle的jar包 收费所以不能通过配置pom.xml获得,可以通过以下方法在pom.xml中引用 在命令行窗口执行(注意更改路径): mvn install:install-file -Dgro ...

  7. TCP/IP各种数据包结构体

    下面这些TCP/IP数据包是我在进行Socket及Wipcap网络编程过程中曾经用到过的数据包结构体, 这些东西平时看起来不起眼,真正用到的时候就会觉得非常有用...... 以太帧头格式结构体,共14 ...

  8. 使用Oracle的DBMS_SQL包执行动态SQL语句

    引用自:http://blog.csdn.net/ggjjzhzz/archive/2005/10/17/507880.aspx 在某些场合下,存储过程或触发器里的SQL语句需要动态生成.Oracle ...

  9. maven在windows下的安装配置及手动引入oracle数据库jar包

    一.maven的安装配置 注意:在进行如下配置之前,有个前提是你的java的jdk安装配置正确才行 1.首先,下载maven,网址http://maven.apache.org/download.cg ...

随机推荐

  1. Yii数据对象笔记

    要执行一个SQL查询,应该遵循以下步骤 - 创建一个 yii\db\Command 的 SQL查询命令 绑定参数(非必须) 执行命令 第1步 - 创建一个 actionTestDb()方法在 Site ...

  2. Python读取excel数据类型处理

    一.python xlrd读取datetime类型数据:https://blog.csdn.net/y1535766478/article/details/78128574 (1)使用xlrd读取出来 ...

  3. 大数据处理框架之Strom:kafka storm 整合

    storm 使用kafka做数据源,还可以使用文件.redis.jdbc.hive.HDFS.hbase.netty做数据源. 新建一个maven 工程: pom.xml <project xm ...

  4. MySql 存储过程 光标只循环一次

    [1]MqSql 存储过程 光标只循环一次 针对MySql存储过程,光标只循环一次就退出的场景,可能原因分析: (1)存储过程有问题(仔细检查语法.控制变量.条件等等) (2)保证存储过程正确.调用过 ...

  5. Spring 无缝整合 quartz

    关键步骤: 1. 配置 SchedulerFactoryBean <bean class="org.springframework.scheduling.quartz.Schedule ...

  6. 利用sqoop将hive数据导入导出数据到mysql

    一.导入导出数据库常用命令语句 1)列出mysql数据库中的所有数据库命令  #  sqoop list-databases --connect jdbc:mysql://localhost:3306 ...

  7. Linux基础命令---pgrep

    pgrep pgrep指令可以按名字或者其他属性搜索指定的进程,显示出进程的id到标准输出. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedo ...

  8. activemq消息队列的使用及应用docker部署常见问题及注意事项

    activemq消息队列的使用及应用docker部署常见问题及注意事项 docker用https://hub.docker.com/r/rmohr/activemq/配置在/data/docker/a ...

  9. golang学习笔记15 golang用strings.Split切割字符串

    golang用strings.Split切割字符串 kv := strings.Split(authString, " ") if len(kv) != 2 || kv[0] != ...

  10. 区块链3.0 ada Cardano卡尔达诺如何获得一致好评?

    区块链3.0 ada Cardano卡尔达诺如何获得一致好评? EOS 的直接竞争对手是以太坊.文章介绍的卡尔达诺(Cardano)的目标就更加远大了,他要同时锁定比特币和以太坊.但大家去网上搜索卡尔 ...