Raw Table for which rule are stored in one table named md_formula , which are used to map in destination table
Drop/Create/Insert for raw_dbs_transacti
So this is what i've tried to attained result as per my requirement. Thanks to @pozs your link to some post was really helpful, Appreciated.
Solution:
Create or replace Function gen_Test(query_name refcursor)
returns refcursor
as $$
Declare sql text;
begin
sql:=(SELECT 'SELECT '|| string_Agg(col_src,',') ||' FROM ' || tbl_src FROM md_formula
WHERE format='Dbs'
GROUP BY tbl_src);
open query_name for execute
sql;
return query_name;
end;
$$ language plpgsql;
select gen_Test('english');
fetch all in english;
PS: Appreciated everyone feedback for giving time for this issue.
For a dynamic query you need to use the 'execute' command.
EXECUTE dynamic-query-string INTO target-variable...
The manual page for this is here: http://www.postgresql.org/docs/current/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN
HTH