惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threat Research - Cisco Blogs
Latest news
Latest news
Project Zero
Project Zero
TaoSecurity Blog
TaoSecurity Blog
Cyberwarzone
Cyberwarzone
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google DeepMind News
Google DeepMind News
P
Privacy & Cybersecurity Law Blog
T
Troy Hunt's Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
AWS News Blog
AWS News Blog
Hacker News: Ask HN
Hacker News: Ask HN
S
Security @ Cisco Blogs
C
Cisco Blogs
Help Net Security
Help Net Security
I
Intezer
W
WeLiveSecurity
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
腾讯CDC
S
Secure Thoughts
MyScale Blog
MyScale Blog
Recorded Future
Recorded Future
G
GRAHAM CLULEY
L
LINUX DO - 热门话题
A
About on SuperTechFans
C
CXSECURITY Database RSS Feed - CXSecurity.com
IT之家
IT之家
J
Java Code Geeks
The Hacker News
The Hacker News
阮一峰的网络日志
阮一峰的网络日志
Scott Helme
Scott Helme
Recent Announcements
Recent Announcements
AI
AI
Cisco Talos Blog
Cisco Talos Blog
B
Blog RSS Feed
V
Vulnerabilities – Threatpost
C
Check Point Blog
Security Latest
Security Latest
S
SegmentFault 最新的问题
T
The Exploit Database - CXSecurity.com
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
M
MIT News - Artificial intelligence
T
The Blog of Author Tim Ferriss
Attack and Defense Labs
Attack and Defense Labs
PCI Perspectives
PCI Perspectives
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - Magicam

jquery easyui 扩展验证 vs2010 安装 Ajax Control Toolkit Backing up the tail mysql 1449 : The user specified as a definer ('root'@'%') does not exist 解决方法 WInform CMD command Mysql中的数据导入SQLServer2000 VS2010安装SP1后无法安装VS2010 SDK Vs2008调试Silverlight时,出现“未安装silverlight托管调试包” js 取时间代码 Sys.ArgumentOutOfRangeException: Value must be an integer 错误的原因 iframe - Magicam wia Kodak 扫描仪应用 winform - Magicam js实现: e.keycode详解 jquery 无法设置selected属性,未指明的错误 JQuery ListBox间移动和ListBox内上下移动 Tif文件转换成GIF列表 - Magicam - 博客园 Visual Studio 2010 安装“deffactory.dat can not open” 的解决办法 - Magicam js 实现2列 div 自适应高度 - Magicam NetTiers模板属性说明 NHibernate配置引发的异常 - Magicam - 博客园
Mysql存储过程游标循环操作
Magicam · 2010-09-10 · via 博客园 - Magicam

代码

LABEL_PROC:
BEGIN
    
    
-- 任务表关联时使用的key值
    DECLARE v_faxkey VARCHAR(
50default '';-- 任务表中的传真状态
    DECLARE v_taskstate 
int default 0;
    DECLARE v_ID 
int default 0;
    DECLARE v_userName VARCHAR(
50default '';

    DECLARE done INT DEFAULT 

0;
    DECLARE cur1 CURSOR FOR SELECT ID FROM childfax 
where ParentId=p_id;
    DECLARE CONTINUE HANDLER FOR SQLSTATE 
'02000' SET done = 1;-- 如果id不在合法范围,直接返回-1
    
if( p_id<=0 ) then
        select 
-1 into result;
        leave LABEL_PROC; 
    end 
if;-- id 指定记录不存在,直接返回 -2
    
if(not exists(select * from parentfax where id=p_id) ) then
        select 
-2 into result;
        leave LABEL_PROC;
    end 
if;if(select count(*) from faxtask where ParentId = p_id and status=1 > 0) then
        select 
-3 into result;
        select 
'正在发送中,不能删除';
                leave LABEL_PROC;
  end 
if;
  
-- 设置子传真会删除状态 
    UPDATE childfax 
set faxstate=-1 where ParentId=p_id;
        
    
-- 设置份传真为删除状态
    UPDATE parentfax 
set FaxState=-1 where id=p_id;
  
  
-- 删除任务表中数据
  delete from faxtask 
where parentid = p_id;

  OPEN cur1;
    
    REPEAT
            FETCH cur1 INTO v_ID;
        
            IF NOT done THEN
                    select username into v_userName from user_childfax_view 

where id=v_ID;
                    call pro_add_log(v_ID,
2,concat(v_userName,' 删除') );
            END IF;

        UNTIL done END REPEAT;
      CLOSE cur1;

-- 返回执行成功结果
    select 
1 into result;

END LABEL_PROC