码迷,mamicode.com
首页 > 数据库 > 详细

oracle 定义临时变量,并使用分支判断

时间:2019-04-18 20:17:08      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:name   where   res   desc   div   count   varchar2   hone   declare   

declare tempCount int;
  tempID  VARCHAR2(8);
begin
    select count(*) into tempCount from CUSTOMER_PROFILE where id=:CUSTOMER_ID;
    
    if tempCount>0 then
        
        update CUSTOMER_PROFILE set name=:CUSTOMER_NAME,address=:CUSTOMER_ADDRESS,phone=:CUSTOMER_PHONE,description=:CUSTOMER_DESCRIPTION,update_user_id=:USER_ID,update_date=sysdate;
    else 
        
         begin
              select  ID into tempID from ID_POOL where status=0 and rownum=1;
              insert into CUSTOMER_PROFILE(id,name,address,phone,description,create_user_id) values(tempID,:CUSTOMER_NAME,:CUSTOMER_ADDRESS,:CUSTOMER_PHONE,:CUSTOMER_DESCRIPTION,:USER_ID);
              update ID_POOL set STATUS=1 where id=tempID;
              
          end;
    end if;
end;     

 

oracle 定义临时变量,并使用分支判断

标签:name   where   res   desc   div   count   varchar2   hone   declare   

原文地址:https://www.cnblogs.com/25miao/p/10731831.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!