云数据库 GaussDB-调用语句:示例

时间:2023-11-01 16:22:24

示例

 1 2 3 4 5 6 7 8 910111213141516171819202122232425262728293031323334353637383940414243444546474849
--创建存储过程proc_staffspostgres=# CREATE OR REPLACE PROCEDURE proc_staffs(section     NUMBER(6),salary_sum out NUMBER(8,2),staffs_count out INTEGER)ISBEGINSELECT sum(salary), count(*) INTO salary_sum, staffs_count FROM hr.staffs where section_id = section;END;/--创建存储过程proc_return.postgres=# CREATE OR REPLACE PROCEDURE proc_returnASv_num NUMBER(8,2);v_sum INTEGER;BEGINproc_staffs(30, v_sum, v_num);  --调用语句dbe_output.print_line(v_sum||'#'||v_num);RETURN;  --返回语句END;/--调用存储过程proc_return.postgres=# CALL proc_return();--清除存储过程postgres=# DROP PROCEDURE proc_staffs;postgres=# DROP PROCEDURE proc_return;--创建函数func_return.postgres=# CREATE OR REPLACE FUNCTION func_return returns voidlanguage plpgsqlAS $$DECLAREv_num INTEGER := 1;BEGINdbe_output.print_line(v_num);RETURN;  --返回语句END $$;-- 调用函数func_returnpostgres=#  CALL func_return();-- 清除函数postgres=#  DROP FUNCTION func_return;
support.huaweicloud.com/devg-opengauss/opengauss_devg_0677.html