Subject Re: [ib-support] error when add computed
Author Lucas Franzen
ronaldorezende schrieb:
>
> I have this error when I try to create this computed column.
> Token unknow: LIne 3 char 1.
>
> ALTER TABLE MATRICULA ADD QTD_MATRICULA_CURSO COMPUTED BY
> (
> SELECT COUNT(*) FROM MATRICULA
> )
>
> What's wrong?
>
> If I put "extract(year from DATA_MATRICULA) from MATRICULA" instead of
> "SELECT COUNT(*) FROM MATRICULA" is ok

extract is a built in function doing artihmetic expression on a given
value in the current inserted/updated record, select is dml working on
the whole table.

The syntax for computed by is:

computed by <expr>
where <expr> "can be any artihmetic expression valid for the datatypes
in expression"

Anyway I don't think it makes any sense at all to put in a select
count(*) in a computed field, since this will slow down inserts
dramatically and will be most meaningless.

What do you want this for at all?

You could this in a before insert/update trigger but still: it's slow
and - in my opinion - absolutely meaningless.


Luc.