How do I declare variables in pgAdmin

前端 未结 3 1263
梦谈多话
梦谈多话 2021-02-20 05:38

If I am in the psql terminal then I can declare and use a variable like this:

\\set message_id soifsdaofisd.gmail.com;
select * from emails where message_id = \'         


        
3条回答
  •  没有蜡笔的小新
    2021-02-20 06:03

    When trying to run scripts in pgAdmin I wanted the something similar where i wanted to store a value to use across multiple queries. This is what I found which is similar to SQL

    set session vars.batch_id = '82';
    
    select * from batches where batch_id = current_setting('vars.batch_id')::int;
    
    

提交回复
热议问题