加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-12 13:12:44 所属栏目:百科 来源:网络整理
导读: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 =
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;     

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读