postgresql 9.2之前的版本 需要CREATE LANGUAGE plpgsql
CREATE LANGUAGE plpgsql
CREATE or REPLACE function getDatirenshu(w_wjID int)
RETURNS INTEGER
as
'
DECLARE
datiRenshu INTEGER;
BEGIN
select count(id) into datiRenshu
from rfwenjuan_yuanshijieguo
where wenjuanItem_id=w_wjID;
return datiRenshu;
end;' LANGUAGE 'plpgsql';
调用
select getdatirenshu(1);