often referred as "materialized views" for the ones who can spare me a 
lecture about what are exactly those :P, let's say you have an 
iper-complicated query that "reconstructs" to a "table" that you want to 
show in a grid just for searching purposes (other purposes not listed, 
sorry, they make absolute no sense)

the dba that is in you says "I'll write a view for my iper-complicated 
query" ...
so, you code something like
create view iperquery as 
select something_that_resemble_a_sequence, bla1, bla2, bla3,
 .....
from bla1
 .....
left outer join (
   select blablabla
   group by blablabla
)
 .....
where max(whatever) > 0

Perfect. now you can do a "select * from iperquery" and your db engine does 
all the work.
To use "iperquery" as a table (read-only mode, for write only go to see 
docs about your engine support for keyed views, another story I'm NOT going 
to cover here) ....

db.define_table('iperquery',
     Field('something_that_resemble_a_sequence', 'id')
     Field('bla1'),
     Field('bla2'),
     .....,
     migrate=False
)

the migrate=False bit is the key: web2py won't try creating it and assumes 
there's a table ready to be used.
You just need to:
 - include a pkey, better if resembles a sequence, and have a Field of type 
'id' matching it
 - tune the Field types accordingly to the type of column of your view

On Friday, April 5, 2013 11:24:23 PM UTC+2, Jurgis Pralgauskis wrote:
>
> You'll better code a view and access it as a "fake table". 
>>
>
> are there examplses of this?
>
> Is it possible to show virtual fields in grid (in appadmin they don't show 
> up)?
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to