存储过程学习

一、 匿名块

--set serveroutput on;
declare
  -- Local variables here
  v_id   sec.SEC_ORGANIZE.organize_id%type;
  v_name varchar2(1000);
begin
  -- Test statements here
  select t.organize_id, t.organize_name
    into v_id, v_name
    from sec.SEC_ORGANIZE t
   where rownum in (1, 2);

  dbms_output.put_line('id= ' || v_id || ' name=' || v_name);
exception
  when others then
    dbms_output.put_line(sqlerrm);
end;

 

二、创建入、出参的过程

 

create or replace procedure myPro1(v_id   out sec.SEC_ORGANIZE.organize_id%type,
                                  v_name out varchar2) is
begin
  -- Test statements here   
  select t.organize_id, t.organize_name
    into v_id, v_name
    from sec.SEC_ORGANIZE t
   where rownum in (1);

  dbms_output.put_line('id= ' || v_id || ' name=' || v_name);
exception
  when others then
    dbms_output.put_line(sqlerrm);
end myPro1;

 

三、创建无参的过程

 

create or replace procedure myPro2 is

begin
  -- Test statements here   

  dbms_output.put_line('id= ');
exception
  when others then
    dbms_output.put_line(sqlerrm);
end myPro2;

 

你可能感兴趣的:(存储过程)