SQL_編寫一個簡單的刪除員工資訊的預存程序,sql預存程序

來源:互聯網
上載者:User

SQL_編寫一個簡單的刪除員工資訊的預存程序,sql預存程序

原創作品,出自 “深藍的blog” 部落格,歡迎轉載,轉載時請務必註明以下出處,否則追究著作權法律責任。

深藍的blog:http://blog.csdn.net/huangyanlong/article/details/43938953

 

開始實驗:

(1)、查詢未經處理資料,使用scott使用者進行實驗

SQL> select  t.*,  t.rowid  from  EMP  t

(2)、編寫預存程序並執行,如下:

create  or  replace procedure P_delete_Empno(empid  innumber) is

begin

  delete from emp  where emp.empno=empid;

  commit;

end  P_delete_Empno;

--參數說明

--P_delete_Empno表示建立預存程序的名字

--empid in number表示預存程序中的參數,此處定義為number類型

--begin、end為預存程序開始和結束的關鍵字

(3)、測試預存程序

SQL> select *from emp;

--查詢資料,員工號為7902的員工資訊存在如下所示

在命令視窗執行如下操作:

SQL> execute  p_delete_empno(7902);

SQL> select  *  from emp;

--再次發起查詢,員工號為7902的員工資訊已經不存在了

至此,一個簡單的根據員工號刪除員工資訊的預存程序示範完畢。

 

原創作品,出自 “深藍的blog” 部落格,歡迎轉載,轉載時請務必註明以下出處,否則追究著作權法律責任。

深藍的blog:http://blog.csdn.net/huangyanlong/article/details/43938953

相關文章

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.