VastbaseG100

基于openGauss内核开发的企业级关系型数据库。

Menu

PL/pgSQL中调用存储过程和函数

  • PL/pgSQL中调用存储过程和函数不需要加call和perform

    vastbase=# CREATE OR REPLACE PROCEDURE pro_test() 
    vastbase-# is  
    vastbase$# BEGIN  
    vastbase$#    dbms_output.put_line ('this is a procedure');
    vastbase$# END;  
    vastbase$# /
    CREATE PROCEDURE
    
    vastbase=# CREATE OR REPLACE FUNCTION fun_test (
    vastbase(#  p_sal NUMBER,
    vastbase(#  p_comm NUMBER
    vastbase(# ) RETURNS NUMBER as $$
    vastbase$# BEGIN
    vastbase$#  RETURN (p_sal + NVL(p_comm, 0)) * 24;
    vastbase$# END ;
    vastbase$# $$ language plpgsql;
    CREATE FUNCTION
    
    vastbase=# DO $$ DECLARE
    vastbase$# BEGIN
    vastbase$#  fun_test(1,2);
    vastbase$#  pro_test();
    vastbase$# END $$;
    ANONYMOUS BLOCK EXECUTE