Subject RE: [firebird-support] Generator as default value?
Author Helen Borrie
At 04:56 PM 24/01/2005 +0700, you wrote:


> >I would like to use a generator to assign unique row numbers for
> >various tables. I am familiar with the approach of defining an insert
> >trigger for each table.
> >Is there a simpler way to achieve this? I was hoping for one of the
> >two options:
> >(1) have the generator as the default value for the column, i.e.
> >something like
> >create table xyz ( xyzID DECIMAL(18) DEFAULT MyGenerator, ...)
>
>
>
>AFAIK, we can't use generator value as default statement,

Correct, you can't.

>but we can use
>them in COMPUTED BY definition, so if I'm not wrong about your meant, you
>can do this :
>
>
>CREATE TABLE XYZ (XYZID BIGINT COMPUTED BY
>(GEN_ID(MYGENERATOR,[somevalue]))

NO! NO! NO!

What this will do is generate a new value for the column every time you
select it!! and it won't populate a real column (which a primary key must be).

(Please excuse the shouting...)

./heLen