Can you declare a table as a parameter in Postgres?

Can you declare a table as a parameter in Postgres?

You cannot declare a table as function parameter per se, since there are no table variables in Postgres. But there are various ways to achieve what you might want to achieve – which isn’t exactly clear yet. You can “pass” a table as

Can you pass a table to a function?

As far as I can tell (after googeling extensivly, because I had the same problem) you can’t pass a table directly to a function. However, as shown, you can transform a table into an array [] of a custom type that consists of several basic types (similar to a table definition).

Is it possible to assign a table type to a function?

I have a TABLE TYPE that some table must respect (interface). For example: I have seen many options in the API, but I am a little lost. I would like to know if it is possible to assign this type to function INPUT/OUTPUT parameters.

Can a table name be interpreted as an identifier in SQL?

The identifier source in the function body has no leading underscore and is interpreted as constant table name independently. But it would not work like this anyway. SQL only allows to parameterize values in DML statements. See: Or search for related questions and answers on site.

Are there other ways to pass data to PostgreSQL?

As Evan mentioned, there are other ways of passing data to PostgreSQL but if you are looking for a cross platform solution then you will need to ensure that you only choose ANSI-compliant methods – unfortunately this does not include the SQL Server table-valued parameters.

How to pass DataTable as parameter to stored procedure?

Likely that would be the ideal solution for you if you’re looking to get the functionality described in Passing a Table-Valued Parameter to a Stored Procedure. All you’d have to do is map the DataTable to JSON, and then pass the JSON to the function. To convert a Datatable to JSON you can use JSON.net. See also these Stack Overflow answers.

How to pass DataTable as parameter in ADO.NET?

The following example receives a list of phone books and stores them in a database using ADO.Net. The example retrieves the phone book details from the list and stores them into the DataTable and passes this table to the Stored Procedure named NewPhoneBook as a parameter. I would never use these objects. They simply don’t seem that useful.