熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Oracle >> 正文

在pl/sql中創建oracle的procedure並調用

2022-06-13   來源: Oracle 

   Create table

  create table A

  (

  USERID NUMBER()

  PWD    VARCHAR()

  )

  tablespace USERS

  pctfree

  initrans

  maxtrans

  storage

  (

  initial K

  minextents

  maxextents unlimited

  );

  ======================================

  創建procedure

  create or replace procedure up_sel(cur_test out sys_refcursor)

  is

  begin

  open cur_test for

  select * from a;

  end;

  刪除存儲過程

  drop procedure up_sel

  提交

  commit

  在PL/sql中執行procedure

  //   file>>new >>test window

  begin

   Call the procedure

  up_sel(cur_test => :cur_test);

  end;

  //在variable中填入定義的游標名  cur_test

  //在Type中填入游標類型  Cursor

  //點擊Value 右邊的 圖標即可顯示出所要的結果

  **當然也可直接右擊存儲過程後點TEST

  ===============================

  刪除數據的存儲過程

  create or replace procedure up_del

  (userid in varchar)

  is

  begin

  delete from a where USERID=userid;

  end;

  //** 要在value中填入要傳入的值

  增加數據

  create or replace procedure up_add

  (

  userid in varchar

  pwd in varchar

  )

  is

  begin

  insert into a(USERIDPWD) values(useridpwd);

  commit;

  end;

  執行

  declare

  begin

  up_add();

  end;


From:http://tw.wingwit.com/Article/program/Oracle/201311/16908.html
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.