Computed Columns

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • peterloh@gmail.com

    Computed Columns

    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.

  • Bill Karwin

    #2
    Re: Computed Columns

    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.

    Comment

    Working...