Computed Columns

Computed Columns

am 22.09.2006 01:36:34 von peterloh

In MSSQL you can create a table with a computed column, like this...

CREATE FUNCTION CubicVolume
-- Input dimensions in centimeters.
(@CubeLength decimal(4,1), @CubeWidth decimal(4,1),
@CubeHeight decimal(4,1) )
RETURNS decimal(12,3) -- Cubic Centimeters.
AS
BEGIN
RETURN ( @CubeLength * @CubeWidth * @CubeHeight )
END

CREATE TABLE Bricks
(
BrickPartNmbr int PRIMARY KEY,
BrickColor nchar(20),
BrickHeight decimal(4,1),
BrickLength decimal(4,1),
BrickWidth decimal(4,1),
BrickVolume AS
(
dbo.CubicVolume(BrickHeight,
BrickLength, BrickWidth)
)
)

Is there an equivalent in MySQL beside views, stored procedures or
calculating it in a query?

I'm not trying to implement it; I'm just curious.

Re: Computed Columns

am 22.09.2006 07:21:26 von Bill Karwin

peterloh@gmail.com wrote:
> Is there an equivalent in MySQL beside views, stored procedures or
> calculating it in a query?

No, there is no declarative support for computed fields in MySQL.

Regards,
Bill K.