oracle 在pl/sql中创建procedure并调用


-- Create table

  create table A

  (

  USERID NUMBER(38),

  PWD    VARCHAR2(30)

  )

  tablespace USERS

  pctfree 10

  initrans 1

  maxtrans 255

  storage

  (

  initial 64K

  minextents 1

  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 varchar2)

  is

  begin

  delete from a where USERID=userid;

  end;

  --//** 要在value中填入要传入的值

  --------增加数据

  create or replace procedure up_add

  (

  userid in varchar2,

  pwd in varchar2

  )

  is

  begin

  insert into a(USERID,PWD) values(userid,pwd);

  commit;

  end;

  -----执行------------------

  declare

  begin

  up_add(11,'222');

  end;


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3