Subject | Computed column madness |
---|---|
Author | William L. Thomson Jr. |
Post date | 2006-02-08T19:19:50Z |
This is driving me insane. I can't add a computed column to this db the
way I do to others. I am computing the columns just as I do else where.
CREATE TABLE INVOICE_ITEMS (
INVOICE_NUM NUMERIC_18_0 NOT NULL,
ITEM_NUM INTEGER_SHORT NOT NULL,
RATE NUMERIC_9_2 NOT NULL,
QUANTITY NUMERIC_9_2 NOT NULL,
ITEM_TOTAL COMPUTED BY (CAST (RATE*QUANTITY) AS NUMERIC(9,2))),
CONSTRAINT PK_INVOICE_ITEMS PRIMARY KEY (INVOICE_NUM,ITEM_NUM)
);
Produces
Dynamic SQL Error
SQL error code = -104
Token unknown - line 6, char 47
)
Now it seems as if there is the incorrect # of opening and closing
brackets. Now I have extracted the meta data from existing dbs where I
do the same or similar computed casting stuff. If I remove a trailing
closing bracket to even off the pairs on the test dbs. Then it fails,
but when I do as above it works.
However for the life of me I can't add my ITEM_TOTAL computed column in
the table above.
Just for reference here is a table from anther db doing the same thing,
that I can create without errors.
CREATE TABLE INVOICE_ITEMS (
INVOICE_NUM NUM NOT NULL,
NUM NUM NOT NULL,
ITEM_NUM NUM NOT NULL,
ITEM VARCHAR_5 NOT NULL,
DESCRIPTION VARCHAR_50 NOT NULL,
COST NUMERIC_9_2 NOT NULL,
PRICE NUMERIC_9_2 NOT NULL,
QUANTITY NUMERIC_9_2 NOT NULL,
ITEM_TOTAL COMPUTED BY (CAST (PRICE*QUANTITY AS NUMERIC(9,2))),
CONSTRAINT PK_INVOICE_ITEMS PRIMARY KEY (INVOICE_NUM, NUM)
);
Please advise. It's a show stopper at the moment for me. Seems very
simple and straight forward. Hopefully something obvious?
Firebird 1.5 LI-V1.5.3.4870
Gentoo Linux ~x86 on i686
--
Sincerely,
William L. Thomson Jr.
Obsidian-Studios, Inc.
http://www.obsidian-studios.com
way I do to others. I am computing the columns just as I do else where.
CREATE TABLE INVOICE_ITEMS (
INVOICE_NUM NUMERIC_18_0 NOT NULL,
ITEM_NUM INTEGER_SHORT NOT NULL,
RATE NUMERIC_9_2 NOT NULL,
QUANTITY NUMERIC_9_2 NOT NULL,
ITEM_TOTAL COMPUTED BY (CAST (RATE*QUANTITY) AS NUMERIC(9,2))),
CONSTRAINT PK_INVOICE_ITEMS PRIMARY KEY (INVOICE_NUM,ITEM_NUM)
);
Produces
Dynamic SQL Error
SQL error code = -104
Token unknown - line 6, char 47
)
Now it seems as if there is the incorrect # of opening and closing
brackets. Now I have extracted the meta data from existing dbs where I
do the same or similar computed casting stuff. If I remove a trailing
closing bracket to even off the pairs on the test dbs. Then it fails,
but when I do as above it works.
However for the life of me I can't add my ITEM_TOTAL computed column in
the table above.
Just for reference here is a table from anther db doing the same thing,
that I can create without errors.
CREATE TABLE INVOICE_ITEMS (
INVOICE_NUM NUM NOT NULL,
NUM NUM NOT NULL,
ITEM_NUM NUM NOT NULL,
ITEM VARCHAR_5 NOT NULL,
DESCRIPTION VARCHAR_50 NOT NULL,
COST NUMERIC_9_2 NOT NULL,
PRICE NUMERIC_9_2 NOT NULL,
QUANTITY NUMERIC_9_2 NOT NULL,
ITEM_TOTAL COMPUTED BY (CAST (PRICE*QUANTITY AS NUMERIC(9,2))),
CONSTRAINT PK_INVOICE_ITEMS PRIMARY KEY (INVOICE_NUM, NUM)
);
Please advise. It's a show stopper at the moment for me. Seems very
simple and straight forward. Hopefully something obvious?
Firebird 1.5 LI-V1.5.3.4870
Gentoo Linux ~x86 on i686
--
Sincerely,
William L. Thomson Jr.
Obsidian-Studios, Inc.
http://www.obsidian-studios.com