Help me for this pls......
I'm trying to search what kind of return type in sql that would return the query results in joined table.
Quote:
CREATE OR REPLACE FUNCTION "public"."view_table" (table_1 text) RETURNS SETOF "public"."table_2" AS
$body$
DECLARE
r table_2%rowtype;
BEGIN
FOR r IN SELECT * FROM table_2 LOOP
RETURN NEXT r;
END LOOP;
END
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100 ROWS 1000;
Quote:
Select * from view_table('table1'')
This is a sample code but this would only return a rows for table_2. I am not finished to implement it. I want to join the table_1 and table_2 and would return their query results. But i don't know yet what is the return type to use for these two query.
Additionaly, I also don't know how to cancatenate the value from parameter which the table_1 to the Select statement in order to make a sql statement such as
Quote:
Select * from table_1 inner join table_2 using(thier_id)
Kindly, help me for this....
I appreaciate a lot for any help, suggestion, idea and comment.
Thanks :)