Thread: [SQL] how to store a query, that results in a table

[SQL] how to store a query, that results in a table

From
Nelson
Date:
thank you jie Liang for your response, but my problems are:
1. How to store a query in the database.
2. How to give a parameter from outside of database, for example:
select * from table1 where row1 = my_parameter_outside.
Give me an example please.



Re: [SQL] how to store a query, that results in a table

From
Tom Lane
Date:
Paul Wehr <paul@industrialsoftworks.com> writes:
> create view complex_view as select blah, ..... , effective_date.date
> from tablea, tableb, tablec, effective_date
> where tablea.foo=tableb.foo
>    ....
>   and effective_date.date between tablec.start_date=tablec.end_date
> ;

> insert into effective_date values ('09/23/2000');  -- may "fail" if date is
> already in the table, but if it is, who cares?

> select *
> from complex_view
> where date='09/23/2000';

Er, why don't you just do

select * from complex_view
where '09/23/2000' between start_date and end_date;

I don't see what the effective_date table is buying ...

            regards, tom lane