SQL%NOTFOUND的用法,SQL%NOTFOUND用法

來源:互聯網
上載者:User

SQL%NOTFOUND的用法,SQL%NOTFOUND用法

SQL%NOTFOUND 是一個布爾值。與最近的sql語句(update,insert,delete,select)發生互動,當最近的一條sql語句沒有涉及任何行的時候,則返回true。否則返回false。這樣的語句在實際應用中,是非常有用的。例如要update一行資料時,如果沒有找到,就可以作相應操作。如:

begin

  update salary set bonus = 1000 where emp_id = 10;

  if sql%notfound then

     insert salary(bonus)values(100);

  end if;

.................

當update emp_id為10的這行記錄,而這行記錄不存在,則作了相應的異常拋出。

相關文章

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.