I am quite new to the postgresql.
what is the best way to achieve this?
SELECT get_columns()
FROM table_name;
get_columns(
I think your biggest problem is that you need to return rows in a way that PostgreSQL can understand. This means basically, you can return a refcursor or you can return a consistent set of data types. I prefer the latter because it makes the system a bit more consistent from a programming perspective and there are some advanced directions you can take that but I can see the other way too.