存储过程在包中的用法

最近更新时间: 2024-06-12 15:06:00

#定义
postgres=#
drop table t1;
create table t1(f1 int ,f2 varchar);
CREATE OR REPLACE package b_2 IS       
    #定义过程
    procedure insert_record(a_f1 int,a_f2 varchar);     
end;
/
CREATE OR REPLACE package body b_2 is   
    #实现过程
    procedure insert_record(a_f1 int,a_f2 varchar) is       
    begin
        insert into t1 values(a_f1,a_f2);
    end;    
end;
/
#调用
postgres=# call b_2.insert_record(1,'tdsql pg');
CALL
postgres=# select * from t1;
 f1 |  f2   
----+-------
  1 | tdsql pg
(1 row)