PL/SQL編程—控制語句

來源:互聯網
上載者:User

標籤:分享   user   set   int   png   rom   class   let   9.png   

 
SQL> create or replace procedure sp_pro5(id_in varchar2) is  2  v_sal mytest.salary%type;  3  begin  4  select salary into v_sal from mytest where id=id_in;  5  if v_sal<130 then  6  update mytest set salary=1.1*v_sal where id=id_in;  7  end if;  8  end;  9  / Procedure created SQL> exec sp_pro5(4); PL/SQL procedure successfully completed SQL> select * from mytest; ID    NAME                 PASSWD                                                                                         SALARY----- -------------------- -------------------- --------------------------------------------------------------------------------1     123                  123                                                                                               1502     gaodingle!!!!        123                                                                                               1503     gagaga               123                                                                                               1504     125555               passwd                                                                                             55

SQL> create or replace procedure sp_pro6(id_in varchar2) is  2  v_bonus number(6,2);  3  begin  4  select bonus into v_bonus from mytest where id=id_in;  5  if v_bonus=0 then  6  update mytest set bonus=100 where id=id_in;  7  else  8  update mytest set bonus=v_bonus+300 where id=id_in;  9  end if; 10  end; 11  / Procedure created SQL> select * from mytest; ID    NAME                 PASSWD                 SALARY    BONUS----- -------------------- -------------------- -------- --------1     123                  123                    120.00     0.002     gaodingle!!!!        123                    120.00     0.003     gagaga               123                    120.00   100.004     125555               passwd                 120.00   100.00 SQL> exec sp_pro6(1); PL/SQL procedure successfully completed SQL> select * from mytest; ID    NAME                 PASSWD                 SALARY    BONUS----- -------------------- -------------------- -------- --------1     123                  123                    120.00   100.002     gaodingle!!!!        123                    120.00     0.003     gagaga               123                    120.00   100.004     125555               passwd                 120.00   100.00

SQL> create or replace procedure sp_pro7 is  2  i number:=0;  3  begin  4  loop  5  insert into users values(i,‘test‘||i);  6  exit when i=3;  7  i:=i+1;  8  end loop;  9  end; 10  / Procedure created

 

 

PL/SQL編程—控制語句

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.