Subject Re: error when add computed
Author ronaldorezende
I agreee with you. It's better put this column in another table. But
an error is generated when I try to put this column. I think that
it's not have effect in the insert because, I will not mention this
column in inserts.
Look my other case:

alter table COURSE ADD QTD_STUDENTS COMPUTED BY
(
SELECT COUNT(*) FROM COURSE_STUDENTS CS
WHERE CS.ID_COURSE = COURSE.ID_COURSE
)

I receive the error mencioned below when I try this.


--- In ib-support@yahoogroups.com, Lucas Franzen <luc@r...> wrote:
>
>
> 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.