Skip to content
Advertisement

Postgres declaration type for multiple rows

I have a postgres function that uses a %ROWTYPE declaration. When I execute this function I get a failure about returning more than one row "code":"P0003","message":"query returned more than one row"

I can successfully execute the query without the returning * into assignments; statement. Which leads me to believe the assignments data.assignment%ROWTYPE; is only for one row?

Advertisement

Answer

Yes. The %ROWTYPE is not strictly necessary, but in any case it holds only one row. You could make an array of data.assignment[], but then you need to loop to fill it.

You can simplify the function as follows:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement