Re: failed to execute the psql case statement which has the function call. - Mailing list pgsql-admin

From David G. Johnston
Subject Re: failed to execute the psql case statement which has the function call.
Date
Msg-id CAKFQuwYBRbm_jqO4APypSLiYbqY=Qcx9d4XQc97H+KJK83SPvQ@mail.gmail.com
Whole thread Raw
In response to failed to execute the psql case statement which has the function call.  (Nikhil Ingale <niks.bgm@gmail.com>)
Responses Re: failed to execute the psql case statement which has the function call.  (sagar jadhav <sagarjdhv5@gmail.com>)
List pgsql-admin


On Tuesday, April 5, 2022, Nikhil Ingale <niks.bgm@gmail.com> wrote:
Hi All,

I've a case statement where I'm calling the user defined postgres function and failed to execute the same. Because it's assuming the variable passed inside the function as a column for the table.

You cannot use variables for identifiers in raw sql.  If you need to do that you must use dynamic sql - build a string using format and execute it.

David J.
 

pgsql-admin by date:

Previous
From: hubert depesz lubaczewski
Date:
Subject: Re: failed to execute the psql case statement which has the function call.
Next
From: sagar jadhav
Date:
Subject: Re: failed to execute the psql case statement which has the function call.