Subject | Re: Select in 'Computed By' field |
---|---|
Author | Adam |
Post date | 2005-07-18T23:20:44Z |
--- In firebird-support@yahoogroups.com, Jason Dodson <jasond@b...> wrote:
From memory you dont need to include the "Table1."
Alter Table Table1
Add MyNewField Computed By ((Select Field1 from
MyStoredProcedure(Field1)));
One thing you will encounter is abismal performance if your stored
procedure runs any sort of query. If it is just a formatting routine
or something that adds a number or two together it is acceptable, but
do not even bother querying other tables or even this table.
If that is what you need to do, create the field as a real field and
populate it on the insert and update triggers. At least then the
expense of calculating the value for MyNewField only occurs when the
record is added or changed, not every time it is selected.
Adam
> Hi all,Jason,
>
> Aside from this being pretty unappealing in appearance, I am playing
> around with having a calculated field that, more or less, selects a
> fields from a stored procedure, that is sure to return only one record.
>
> Ive gotten the syntax down (For whatever reason, you need double parens
> around a select statement in the 'computed by' declaration), but I am
> still not 100% there. Here is more or less what I have:
>
> Alter Table Table1
> Add MyNewField Computed By ((Select Field1 from
> MyStoredProcedure(Table1.Field1)));
>
> For a reason unknown to me, I get the error 'Column Unknown
> Table1.Field1'. Now I would HOPE that I can access field values of the
> current record, like I can WITHOUT a select statement. Is there some
> other syntax magic I am missing, or is this a limitation of this
> functionality?
>
> Jason
From memory you dont need to include the "Table1."
Alter Table Table1
Add MyNewField Computed By ((Select Field1 from
MyStoredProcedure(Field1)));
One thing you will encounter is abismal performance if your stored
procedure runs any sort of query. If it is just a formatting routine
or something that adds a number or two together it is acceptable, but
do not even bother querying other tables or even this table.
If that is what you need to do, create the field as a real field and
populate it on the insert and update triggers. At least then the
expense of calculating the value for MyNewField only occurs when the
record is added or changed, not every time it is selected.
Adam