In PostgreSQL, there is a RETURNS TABLE function that can receive multiple rows of table data by FUNCTION. Can't this FUNCTION be bundled into a package and used?
Related
In psql i can get the pivot of a table using the client side function \crosstabview, but i can't figure out how to store the result in a table, i tried CREATE Table foo AS ... \crosstabview, but it stores just the input to the function and not the output.
\crosstabview is a psql slash command which takes the results of the actual query (everything up until \crosstabview) and reformats it. As such the output you see is generated within the psql client for display only, and cannot be used in other SQL operations.
To create a table based off the results of a crosstab query you'll need the tablefunc extension.
How can I get a total number of rows that were updated and inserted and deleted in a transaction called by a function?
I can get this information with pg_recvlogical. But can the postgres server be configured in any way to return this information with each postgres function that's called (both sql and plpgsql), or would it require a change to every function if it's even possible?
Is there some kind of metadata that the driver is able to pass back along with the actual function results where this can be somehow included? Or would it be possible to write a generic postgres stored procedure that calls functions and adds this information?
I tried to create a table (set returning) function in redshift but failed.
Because redshift only supports scalar function (documentation). Is it true? Can I create table functions?
The simple answer: no you can not create table functions ("set returning functions) as you can do in Postgres.
The section Unsupported PostgreSQL Features in the Redshift manual explicitly lists "Table functions".
I have written some set of statements which returns a table with some static columns. But I'll required to download csv format using the same function with different column. (Reason is that I created static columns to display high charts and we are using custom code to export chart data so require some different format to download)
In table valued function, I dont know how to return the Dynamic columns of the table based on pram passed to function.
How to write the table value function for this scenario? If this is not possible then what would be the alternative for this task(Stored procedure can't be used in my existing scnerio due to some limitation of code)?
Any suggestions please.
I have written some set of statements which returns a table with some columns. But we dont know exactly which column it returns.
In table valued function, I dont know how to return the Dynamic columns of the table.
How to write the table value function for this scenario? If this is not possible then what would be the alternative for this task?
Any suggestions please.
The table-valued function requires static columns (names and types). If you want dynamic columns in result-set, use procedure instead of function.