oracle存储过程将一个表的数据导入另一个表

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

oracle´æ´¢¹ý³Ì--ÿÈÕͳ¼ÆÒ»¸ö±íÖеÄÊý¾Ý£¬²¢²åÈëÁíÒ»¸ö±íÖиù¾ÝLOGINFOºÍMEDICALINFO±íÖеÄÊý¾Ý£¬¸ù¾ÝDocIDºÍPROCTIME×ֶΣ¬²éѯ¼Ç¼£¬È»ºó¸ù¾ÝACTION×ֶεÄÖµ£¬½«²éѯ³öµÄÊý¾Ý²åÈëµ½ÁíÍâÒ»¸ö±íÖС£createorreplacePROCEDUREPROCEDURE1ASCURSORLOG_CURSORISSELECTTO_CHAR(PROCTIME,'YYYY-MM-DDHH24'),MEDICALINFO.APPCODE,LOGINFO.ACTION,COUNT(*)FROMLOGINFO,MEDICALINFOWHERELOGINFO.DOCID=MEDICALINFO.DOCIDANDTO_CHAR(PROCTIME,'YYYY-MM-DD')='2010-12-14'GROUPBYTO_CHAR(PROCTIME,'YYYY-MM-DDHH24'),MEDICALINFO.APPCODE,LOGINFO.ACTIONORDERBYAPPCODEDESC;PROCTIMESTRVARCHAR2(20);PROCTIMEDATE;APPCODEVARCHAR2(20);ACTIONNUMBER;COUNTSUMNUMBER;CREATESUMNUMBER;STAMPSUMNUMBER;PRINTSUMNUMBER;BEGINOPENLOG_CURSOR;LOOPFETCHLOG_CURSORINTOPROCTIMESTR,APPCODE,ACTION,COUNTSUM;SELECTTO_DATE(PROCTIMESTR,'YYYY-MM-DDHH24')INTOPROCTIMEFROMDUAL;EXITWHENLOG_CURSOR%NOTFOUND;IFACTION=1THENCREATESUM:=COUNTSUM;ELSIFACTION=2THENSTAMPSUM:=COUNTSUM;ELSIFACTION=3THENPRINTSUM:=COUNTSUM;ELSENULL;ENDIF;INSERTINTOACTIONLOG(LOGDATE,STARTHOUR,CREATESUM,STAMPSUM,PRINTSUM,DEPARTMENT)VALUES(PROCTIME,0,CREATESUM,STAMPSUM,PRINTSUM,APPCODE);ENDLOOP;CLOSELOG_CURSOR;ENDPROCEDURE1;

1 / 1
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功