This question is asked several times, but I cann't figure out some things.
First, I have situation that I need to create view (must be view), but according to the result of one query.
create view as
if (select count(oid)...)>1
select1
else
select2
I know that this form is not allowed. But how can I accomplish something like this? I have tens of views like this I need to create. Because these SELECT statements contain spatial conditions, and the database is big and has many many tables, I need the 'most optimal' solution, or it will query forever.
I read something about using stored procedures and UD functions, but how to create view from them and get max performances? I don't need parameters in it, just way to create views defined by this condition.