views:

35

answers:

1

Hi, 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 from predefinedqueries where id=someid )

+1  A: 

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);
Konrad Garus
Thank You, really a good suggestion, even more than what I figured out in my question
Steel Plume