user1455270
user1455270

Reputation: 113

Token Unknown, Firebird Computed By

I'm getting token unknown QTY when executing the below DML, at a complete loss as to why as QTY is contained earlier in the table definition. The error is occurring on the COMPUTED column.

CREATE TABLE LINE_ITEMS(
  LINE_ITEM_ID INTEGER NOT NULL, 
  QTY          NUMERIC(10,4) DEFAULT 0, 
  PRICE        NUMERIC(10,4) DEFAULT 0, 
  AMOUNT       COMPUTED BY QTY * PRICE,     
  CONSTRAINT   PK_LINE_ITEMS PRIMARY KEY(LINE_ITEM_ID)));

Upvotes: 0

Views: 1183

Answers (1)

user330315
user330315

Reputation:

You need to put the expression between parentheses:

CREATE TABLE LINE_ITEMS
(
  LINE_ITEM_ID INTEGER NOT NULL, 
  QTY          NUMERIC(10,4) DEFAULT 0, 
  PRICE        NUMERIC(10,4) DEFAULT 0, 
  AMOUNT       COMPUTED BY (QTY * PRICE),     
  CONSTRAINT   PK_LINE_ITEMS PRIMARY KEY(LINE_ITEM_ID)
);

Upvotes: 4

Related Questions