I am having a hard time wording this question--
i have this simple select statement that returns a record
SELECT q.qid,q.question,depth,active
FROM q
JOIN qp ON q.qid = qp.descendant where qid=723
order by depth
this correctly returns the 1 record it is after
however when i include a function in the select statement it no longer returns the records and I am not sure why that is.
SELECT q.qid,q.question,depth,active,(getprevquestiontemp(qid)).qid parent
FROM q
JOIN qp ON q.qid = qp.descendant where qid=723
order by depth
this is the function
CREATE OR REPLACE FUNCTION getprevquestiontemp(cur_qid integer)
RETURNS SETOF q AS
$BODY$
SELECT q.* FROM q
JOIN qp ON q.qid = qp.ancestor WHERE qp.descendant = cur_qid
AND depth = 1;
$BODY$
LANGUAGE sql VOLATILE
COST 100
ROWS 1000;
getprevquestiontempdo? Is that a set returning function? If yes use it in the FROM clause with an outer join