用exec函数从头开始运行查询?

时间:2010-03-15 23:24:03

标签: postgresql

是否可以在不使用函数的情况下使用Postgresql创建类似于以下的内容?

伪sql代码:

从sometable中选择* somecol = somevalue和someothercol IN exec('从exclusionlist'中选择一些内容)

我的主要目的是建立一个包含预定义查询的表,以便在where子句

中调用

伪sql代码: 从sometable中选择* somecol = somevalue和someothercol IN exec(从预定义查询中选择查询,其中id = someid)

1 个答案:

答案 0 :(得分:1)

据我所知,唯一的选择是:

prepare my_usr_id as select usr_id from usr where usr_id < $1;
create temp table my_temp on commit drop as execute my_usr_id(10);
select * from usr join my_temp using (usr_id);