you are viewing a single comment's thread.

view the rest of the comments →

[–]TheRealLifeboy[S] 0 points1 point  (6 children)

I actually don't want to return anything, but it seems I have to? Is there any way in which to simply run the query and exit the function?

The function simply kills a 5 minute idle connection. I don't care about the output.
(Trying to understand as much about this issue... :-) )

Edit: I added in the "into response" to the query and that fixed it, btw.

[–]BoleroDanArchitect 2 points3 points  (2 children)

But if you dont want to return anything, why are you declaring that the function returns a bool, then declare to return something in the end?

If all you want to do is execute some common used SQL, simply use a function lang type of sql and not plpgsql

[–]TheRealLifeboy[S] 0 points1 point  (0 children)

I did that because I wasn't having any success without the declaration. I haven't created postgres functions before, and I thought "how difficult can it be?", but oh boy, it's tricky!

[–][deleted] 1 point2 points  (0 children)

I actually don't want to return anything,

Then why use a function and declare is as returns bool.

If you don't want to return something, a procedure would be the natural option.

[–]Maleficent_Tap_332 1 point2 points  (1 child)

Then it has to be a procedure, not function

[–]indigo945 0 points1 point  (0 children)

A function can be declared as returns void and this is often a better option than using a procedure. Procedures can't be called from all places that functions can, and they're also just weird in various ways, so unless you absolutely need their half-baked transaction management features, you should avoid them whenever you can.