pgsql存储过程(实例)

来源:互联网 发布:java 路径 编辑:程序博客网 时间:2024/06/08 09:06

pg存储过程 简单示例:


create or replace function select_resource_produrce(IN mprCode text , IN publicationType text , OUT resourceName text ,OUT resourceId int8)returns record as$BODY$ BEGINif publicationType = '1' then  select book_name_cn , book_id        into resourceName,resourceId          from t_book         where mpr_code = mprCode;  end if;if publicationType = '2' then  select periodical_name_cn , periodical_id        into resourceName,resourceId          from t_periodical         where mpr_code = mprCode;  end if;if publicationType = '3' then  select newspaper_name_cn , newspaper_id        into resourceName,resourceId          from t_newspaper         where mpr_code = mprCode;  end if;if publicationType = '4' then  select audio_name_cn , audio_id        into resourceName,resourceId          from t_audio         where mpr_code = mprCode;  end if;END;$BODY$language plpgsql;SELECT * from select_resource_produrce('0000000226' , '1')

调用  :SELECT * from select_resource_produrce('0000000226' , '1')

                                             
0 0
原创粉丝点击