PG数据库技巧

1.查询表结构

 

/d pg_catalog.pg_proc;

 

2.查询存储过程

select proname,prosrc from pg_catalog.pg_proc where proname like 'sp_%';

 

3.动态存储过程调用

CREATE OR REPLACE PROCEDURE sp_test1

(

  param1 in INTEGER,

  param2 out INTEGER,

  param3 in INTEGER

)

AS

BEGIN

  param2:=param1+param3;

END;

/

DECLARE

  input1 INTEGER:=1;

  input2 INTEGER:=2;

  lstatement VCHAR2(200);

  lparam2 INTEGER;

BEGIN

  lstatement:='call sp_test1(:col_1,:col_2,:col_3);

  EXECUTE IMMEDIATE lstatement USING IN input1, out param2,in input2;

  dbms_output.put_line('result is ' || tochar(lparam2);

END;

你可能感兴趣的:(BASH脚本)