Oracle練習:塊、過程、函數、遊標的練習

塊、過程、函數、遊標的練習
注意:set serveroutput on(開啓存儲函數的結果顯示)
      select object_name,status from user_objects where object_type='PROCEDURE';(查詢當前用戶下有哪些存儲函數)
1、塊的練習
Begin
     dbms_output.put_line('我是小明');--相當於調用它裏面的方法,講這句話直接打印
End;

2、塊的練習
Declare
n Number;--定義一個變量
Begin
    n := 90;--對這個變量進行初始化
    dbms_output.put_line('n='||n);
End;

3、過程一
Create Or Replace Procedure p_my_first_proc As --定義一個存儲函數(無參)  名稱爲 p_my_first_proc  使用關鍵字 execute將其調用
Begin
    dbms_output.put_line('this is my first procedure');
End;

4、過程二
Create Or Replace Procedure p_number(n Number) As --定義一個入參的存儲函數
Begin
     dbms_output.put_line('n='||n);
End;

5、過程三
Create Or Replace Procedure p_number(n Number ,res Out Number) As --定義一個入參和出參的存儲函數
Begin
     res := n*100;
End;
----
Declare
  n Number :=9;--定義一個變量,並且賦值
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章