IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 大数据 -> mysql 存储过程 带游标 -> 正文阅读

[大数据]mysql 存储过程 带游标

CREATE DEFINER=`mysqladmin`@`%` PROCEDURE `pr_wf_excel_init`(
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? in pa_cnc varchar(100), ??
?? ??? ??? ? ? ? ? ? ? ? ? ? ? ? ? ? OUT OSA_RETURN_CODE VARCHAR(5), ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
?? ??? ??? ? ? ? ? ? ? ? ? ? ? ? ? ? OUT OSA_SQLERRM VARCHAR(500)
)
__END: BEGIN?
?? ??? ??? ?declare ls_process_ins_id varchar(64);
?? ??? ??? ?declare ls_process_defind_id varchar(64);
?? ??? ??? ?declare ls_process_initfile_id varchar(64);
?? ??? ??? ?declare ls_process_initfile_path varchar(64);
?? ??? ??? ?declare ls_process_initfile_type varchar(128);
?? ??? ??? ?declare ls_process_initfile_type_copy varchar(128);
?? ??? ??? ?declare ls_process_initnode varchar(128);
?? ??? ??? ?declare ls_count_pqct int;
?? ??? ??? ?declare ls_uuid varchar(64);
?? ??? ??? ?
?? ??? ??? ?DECLARE done INT DEFAULT FALSE; ? ?-- 游标循环不能缺少的语句
?? ??? ??? ?
?? ??? ??? ?DECLARE Cursor_File CURSOR FOR?
?? ??? ??? ?(
?? ??? ??? ??? ??? ??? ?-- t_ebom_cncroot-- t_ebom_cncfiles-- t_ebom_outfile
?? ??? ??? ??? ??? ??? ?-- t_mbom_cnctec-- t_mbom_resfile-- 查询 填充文件id 文件路径?? ?
?? ??? ??? ??? ??? ?SELECT DISTINCT fileid,ftype,typeid FROM
?? ??? ??? ??? ??? ??? ??? ?(
?? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ?select a.fileid,'规格更改书' as ftype,'GGGG' as typeid ? ? ? ? ? ??
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?from t_ebom_cncroot a ?where a.eecnc=pa_cnc ?and ?cncbiltype='GGGG' ? ? ? ? ? ? ? ? ? ? ? ? ??
?? ??? ??? ??? ??? ??? ??? ??? ??? ?union all?
?? ??? ??? ??? ??? ??? ??? ??? ??? ?select a.fileid,typedesc,tab.typeid from t_ebom_outfile a ? ? ? ? ? ??
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?join t_sys_classdital tab ?on a.fitype=tab.typeid ? ? ? ? ? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?where a.eecnc=pa_cnc?
?? ??? ??? ??? ??? ??? ??? ??? ??? ?union all?
?? ??? ??? ??? ??? ??? ??? ??? ??? ?select a.fileid,typedesc,tab.typeid from t_mbom_resfile a ? ? ? ? ? ??
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?join t_sys_classdital tab ?on a.filetype=tab.typeid ? ? ? ? ? ? ? ? ? ? ??
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?where a.bgncnc=pa_cnc ?
?? ??? ??? ??? ??? ??? ??? ?)t
? ? ? ?);?
?? ??? ??? ??
?? ??? ??? ?DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; -- 绑定控制变量到游标,游标循环结束自动转true
?? ??? ??? ?
? ? ? ?/*---------- ? ? ?异常处理机制 ?模板 ? ? ----------*/?
? ? ? ?-- DECLARE EXIT HANDLER FOR SQLWARNING,NOT FOUND,SQLEXCEPTION ?如果有了游标,就不能有 NOT FOUND
?? ? ?DECLARE EXIT HANDLER FOR SQLWARNING,SQLEXCEPTION
?? ? ?BEGIN
?? ??? ? ?GET DIAGNOSTICS CONDITION 1
?? ??? ? ?OSA_RETURN_CODE = RETURNED_SQLSTATE, OSA_SQLERRM = MESSAGE_TEXT;?
?? ? ?END; ?
? ? ? set OSA_RETURN_CODE ="OK";
? ? ? set OSA_SQLERRM="noErr";?
?? ??? ??? ?
-- ?? ??? ??? ?设置同一批次的uuid
?? ??? ??? ?set ls_uuid=REPLACE(UUID(),'-','');
?? ??? ??? ?
?? ??? ??? ?-- 获取最新+有效的 工序
? ? ? ? set done = false;
? ? ? ? open Cursor_File;
?? ??? ??? ??? ??? ??? ?FileLoop: loop fetch Cursor_File into ls_process_initfile_id,ls_process_initfile_path,ls_process_initfile_type;
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?if done then
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?leave FileLoop;
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?end if;?? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? ?if instr(ls_process_initfile_type,'GGGG')>0 then ?set ls_process_initfile_type_copy = 'GGGG'; -- if 条件 =
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?elseif instr(ls_process_initfile_type,'PQCT')>0 then ?set ls_process_initfile_type_copy = ls_process_initfile_type; -- elseif关键字
-- ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?elseif instr(ls_process_initfile_type,'PQCT')>0 then ?set ls_process_initfile_type = ls_process_initfile_type; -- elseif关键字
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?else set ls_process_initfile_type_copy = 'EBOM_OUTFILE'; ? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?end if;
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?-- 审批人信息
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?insert into t_approve_init_temp
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? with tab_act_info as(?? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? SELECT?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? a.activity_id_,a.START_TIME_ as start_date,a.END_TIME_ ?as end_date,u.user_name,u.user_id,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? ls_process_initfile_id as file_id,f_getfilepath(ls_process_initfile_id) as file_path
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?FROM act_ext_hi_taskinst a,t_sys_user u?? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?WHERE a.ASSIGNEE_=u.user_id ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?and a.PROC_INST_ID_= (SELECT max(PROC_INST_ID_) ?FROM act_ext_ru_procinst WHERE BUSINESS_KEY_= pa_cnc)
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?and a.END_TIME_ in?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?(
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?SELECT max(a.END_TIME_)
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?FROM act_ext_hi_taskinst a ?,t_sys_user u
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?WHERE a.ASSIGNEE_=u.user_id ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?and a.PROC_INST_ID_= (SELECT max(PROC_INST_ID_) ?FROM act_ext_ru_procinst WHERE BUSINESS_KEY_= pa_cnc)
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?and a.EXEC_RESULT_='OK'
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?and a.ACTIVITY_ID_ <> 'startEvent'
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?GROUP BY a.activity_id_
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?ORDER BY a.seq_
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?)
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?and a.ACTIVITY_ID_ <> 'startEvent'
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?ORDER BY a.seq_
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?)?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?select null,ls_uuid,s.activity_id_,s.start_date as start_date,s.end_date as end_date,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?s.user_name,s.user_id,s.file_id,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?s.file_path,k.app_row,k.app_cell,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?f_getusersigpath(s.user_id) as sig_path,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?-- ?? ?case f_getusersigpath(s.user_id) when INSERT(f_getusersigpath(s.user_id),'/') then 'Y' end as ib_sign,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?'sign_value' as insert_flag
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?from ?tab_act_info s join t_approve_init k on s.activity_id_ = k.app_wfnode
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?WHERE INSTR (ls_process_initfile_type_copy,k.app_type)>0
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?union all
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?-- 审批时间信息
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?select null,ls_uuid,l.app_wfnode,?? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?(select k.start_date from tab_act_info k where left(l.app_wfnode,length(l.app_wfnode)-5)=k.activity_id_ ) as start_date,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?(select k.end_date from tab_act_info k where left(l.app_wfnode,length(l.app_wfnode)-5)=k.activity_id_ ) as end_date,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?(select k.user_name from tab_act_info k where left(l.app_wfnode,length(l.app_wfnode)-5)=k.activity_id_ ) as user_name,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?(select k.user_id from tab_act_info k where left(l.app_wfnode,length(l.app_wfnode)-5)=k.activity_id_ ) as user_id,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?(select k.file_id from tab_act_info k where left(l.app_wfnode,length(l.app_wfnode)-5)=k.activity_id_ ) as file_id,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?(select k.file_path from tab_act_info k where left(l.app_wfnode,length(l.app_wfnode)-5)=k.activity_id_ ) as file_path,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?l.app_row,l.app_cell,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?'time' as sig_path,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?'insert_time' as insert_flag
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?from ?t_approve_init l
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? where ?l.app_wfnode not in (
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?select ?s.activity_id_
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?from ?tab_act_info s?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?join t_approve_init k
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?on s.activity_id_ = k.app_wfnode
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? )
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? and instr(l.app_wfnode,
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? (SELECT left(a.activity_id_,10)?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?FROM act_ext_hi_taskinst a,t_sys_user u?? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?WHERE a.ASSIGNEE_=u.user_id ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?and a.PROC_INST_ID_= (SELECT max(PROC_INST_ID_) ?FROM act_ext_ru_procinst WHERE BUSINESS_KEY_= pa_cnc)
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?and a.END_TIME_ in?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?(
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?SELECT min(a.END_TIME_)
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?FROM act_ext_hi_taskinst a ?,t_sys_user u
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?WHERE a.ASSIGNEE_=u.user_id ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?and a.PROC_INST_ID_= (SELECT max(PROC_INST_ID_) ?FROM act_ext_ru_procinst WHERE BUSINESS_KEY_= pa_cnc)
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?and a.EXEC_RESULT_='OK'
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?and a.ACTIVITY_ID_ <> 'startEvent'
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?)
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?and a.ACTIVITY_ID_ <> 'startEvent'
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?ORDER BY a.seq_
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?)
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?)>0;
?? ??? ??? ??? ??? ??? ?end loop FileLoop;
? ? ? ? close Cursor_File;
?? ??? ??? ??? ?
?? ??? ??? ??? ?select * from t_approve_init_temp l where l.uuid = ls_uuid;
?? ??? ??? ??? ?
?? ??? ??? ??? ?
END

  大数据 最新文章
实现Kafka至少消费一次
亚马逊云科技:还在苦于ETL?Zero ETL的时代
初探MapReduce
【SpringBoot框架篇】32.基于注解+redis实现
Elasticsearch:如何减少 Elasticsearch 集
Go redis操作
Redis面试题
专题五 Redis高并发场景
基于GBase8s和Calcite的多数据源查询
Redis——底层数据结构原理
上一篇文章      下一篇文章      查看所有文章
加:2022-10-31 12:04:09  更:2022-10-31 12:08:07 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/26 10:49:27-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码