2016-11-16 106 views
0

我有一個像函數調用沒有結果集

create or replace function getalltypes(name character varying(100)) 
returns setof docs as $BODY$ 

begin 
perform c.contenttypename from conttype c; 

end; 
$BODY$ LANGUAGE PLPGSQL; 

文檔PostgreSQL的功能是

select getalltypes('') 

是越來越沒有結果顯示,我已經創建

create type docs as (contenttypename character varying(100)) 

類型。任何人都可以幫忙嗎?

+1

您可能想要更改從contType c執行c.contenttypename;從contType c返回查詢c.contenttypename; –

+0

@VaoTsun - 從contType c返回查詢c.contenttypename;在'c'處顯示錯誤。我改爲'返回查詢從conttype c選擇c.contenttypename;'然後它工作。謝謝 –

回答

1

您沒有任何return語句。這就是爲什麼你看不到任何結果。 PERFORMis used to evaluate the query and DISCARD the result 這就是爲什麼你應該將perform c.contenttypename from conttype c;更改爲return query select c.contenttypename from conttype c;