Skip to content
Advertisement

How to insert data into a String array in postgres stored procedure

I have a pseudo stored procedure as given below:

I want to create multiple insert queries with dynamic fileId’s being iterated over a loop and put them in a string array ('querstring') seperated by a comma delimiter. The code above is not giving me the exact result. What is the correct way to achieve this?

The expected output is like:

Then this querystring array needs to be executed also.

Advertisement

Answer

You are probably looking for the “array append” operator ||.

But that is an overly complicated way to solve the problem. You can do it simpler and more efficiently with something like

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