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);

posted @ 2015-10-27 17:26  springday  阅读(521)  评论(0编辑  收藏  举报