創建一個函數。該功能有一個輸入參數。我可以返回一列,但我想返回所有表列。如果結果爲零,我也想這樣做,函數只返回0.我該怎麼做? 這裏的錯誤結果。Postgresql存儲過程返回表的所有列
ERROR: query has no destination for result data HINT: If you want to discard the results of a SELECT, use PERFORM instead. CONTEXT: PL/pgSQL function dwgcould.returnallcolumns(character varying) line 3 at SQL statement ********** Error ********** ERROR: query has no destination for result data SQL state: 42601 Hint: If you want to discard the results of a SELECT, use PERFORM instead. Context: PL/pgSQL function dwgcould.returnallcolumns(character varying) line 3 at SQL statement
CREATE OR REPLACE FUNCTION dwgcould.returnallcolumns(IN sessionId character varying)
RETURNS SETOF public.mytable AS
$BODY$
BEGIN
SELECT * FROM public.mytable WHERE session_id=returnallcolumns.sessionId ORDER BY pro_id DESC LIMIT 1;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
你得到的錯誤是什麼?但是「*我想返回所有表列*」違反:「*函數只返回0 *」在一種情況下不能返回「所有列」,在其他情況下只能返回一列。 –
沒有結果返回值將爲0.不可能? – Fatih
它似乎在做你想做的事。穩定不易變 –