Subject Re: [firebird-support] Getting underlying table
Author Ann W. Harrison
At 08:56 AM 2/6/2004, Elmar Haneke wrote:
>Hi,
>
>How can I get the name of the physical table accessed by an Query
>which is running against an view. I'm using the API.
>
>Example
>
>Create Table SampleTable ( ... )
>
>Create View SampleView as Select .. FROM Table ...
>
>I'm running "SELECT * from Sample View"

Look up the field name (the name the field is given in the view)
in rdb$relation_fields. Use that to lookup the underlying table
in the rdb$view_relations table.

select x.rdb$base_field, y.rdb$relation_name
from x in rdb$relation_fields
join y.rdb$view_relations on
(x.rdb$view_context = y.rdb$view_context and
x.rdb$relation_name = y.rdb$view_name)
where x.rdb$relation_name = <my view> and
x.rdb$field_name = <field in view>


Regards,


Ann