Is it possible to use the CASE statement in a CREATE TABLE statement. I just thought that I could make the database more accurate this way. Say if i refer to products sold in a supermarket, some are measured by quantity and some are measured by weight. So if possible to have this statement:
If the prodtype is FRESH (goods measured by weight) then I the DCStockLvl type will be FLOAT. However if the ProdType is 'PACKAGED' (goods measured by unit) then the type will be just a SMALLINT.Code:CREATE TABLE tblProduct ( ProdCode CHAR(8) PRIMARY KEY, ProdType VARCHAR(8), Prod_Desc VARCHAR(40), Unit VARCHAR(12), CentreName CHAR(12) REFERENCES tblDistCentre(CentreName), /*DCStockLvl (type to be decided by case statement) */ );
The thought of using a CASE statement just occured to me, atm Ive just set-it up so that the type will just be a FLOAT.
Thanks in advance,




Reply With Quote