marianowic
Programmer
Hello.
I`ve got a big problem.
I want to create an advance SELECT function that returns set of records. This function should do several different SELECTs depending on the INPUT parameter.
EX:
CREATE OR REPLACE FUNCTION getmessage(bigint)
RETURNS SETOF record AS
$BODY$
CASE WHEN $1 = -1 THEN
SELECT * FROM message WHERE idFrom = 5
ELSE
SELECT * FROM message WHERE idFrom=5 AND idTo = 13
END
$BODY$
This doesn`twork but it describe the idea.
Anyone can help me how can I achieve this goal??
Thanks a lot.
I`ve got a big problem.
I want to create an advance SELECT function that returns set of records. This function should do several different SELECTs depending on the INPUT parameter.
EX:
CREATE OR REPLACE FUNCTION getmessage(bigint)
RETURNS SETOF record AS
$BODY$
CASE WHEN $1 = -1 THEN
SELECT * FROM message WHERE idFrom = 5
ELSE
SELECT * FROM message WHERE idFrom=5 AND idTo = 13
END
$BODY$
This doesn`twork but it describe the idea.
Anyone can help me how can I achieve this goal??
Thanks a lot.