Skip to content
Advertisement

Create and Run Query in Postgresql Procedure

I want to create a postgresql procedure which creates a query and run it. I tried and research on forums. But i can not solve my problem. Procedure should get user input as a parameter and use it in query. My code like that :

And this is the error :

edit: form_field is a table. create statement :

Advertisement

Answer

First I have created a table form_field(with only two fields I needed to avoid all errors…):

Then I have analized your query inside of the function you created and realized you are selecting one field of character and the table form_field has two fields. So, I have created one more table:

Edited your function, not procedure:

And then called your function:

So now, you have something that works… you can edit your question and maybe this will help someone to resolve your original problem…

Also, please do write, at the end of your question, what your wish is the function should execute when you send value 2 to that function ?

Here is a demo:

DEMO

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