Debug SQL in pgAdmin when SQL contains variables

前端 未结 3 509
臣服心动
臣服心动 2021-02-06 13:11

In SQL Server I could copy sql code out of an application and paste it into SSMS, declare & assign vars that exist in the sql and run. yay great debugging scenario.

3条回答
  •  囚心锁ツ
    2021-02-06 13:44

    You can achieve this using the PREPARE, EXECUTE, DEALLOCATE commands for handling statements, which is really what we are talking about here.

    For example:

    PREPARE test AS SELECT * FROM users WHERE first_name = $1;
    EXECUTE test ('paul');
    DEALLOCATE test;
    

    Perhaps not as graphical as some may like, but certainly workable.

提交回复
热议问题