Skip to content
Advertisement

How to add column inside postgres function without saving it to the db?

I have a postgres DB and I want to create a function that returns a copy of my table with a new column that has a value of 1 if its id is inside the array(idds[]) that the function gets as an input. In the code below I’ve try to create a temporary table(chosen) that have id if it’s in the idds array and to manually add the isChosen column that obviously doesn’t work…

Advertisement

Answer

you can use this query instead :

so:

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