Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Advance SELECT

Status
Not open for further replies.

marianowic

Programmer
Jul 5, 2006
1
PL
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top