开发者

Running query from scratch with something like exec function?

is it possible to make something similar to the following with Postgresql without using a function?

pseudo sql code:

select * from sometable where somecol = somevalue AND someothercol IN exec( 'select something from exclusionlist' )

My primary intention is to build up a table with predefined queries to call inside a where clause

pseudo sql code: select * from sometable where somecol = somevalue AND someothercol IN exec( select query f开发者_运维技巧rom predefinedqueries where id=someid )


As far as I can see the only option is:

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜