pg select中使用变量

DO $$
DECLARE myvar int8;
BEGIN
    --SELECT 168038292783239160 INTO myvar;
    myvar=168038292783239168;
    DROP TABLE IF EXISTS tmp_table;
    CREATE TABLE tmp_table AS
    select * from ess_storehouseini es where s_storages_id= myvar;
END $$;

SELECT * FROM tmp_table;

 

posted @ 2023-03-06 21:58  Thenext  阅读(57)  评论(0编辑  收藏  举报