• Re: [Info-ingres] Calculated column defaults

    From Roy Hann@specially@processed.almost.meat to comp.databases.ingres on Tue Feb 9 15:09:36 2021
    From Newsgroup: comp.databases.ingres

    Martin Bowes wrote:

    OK. Feeling a little lazy and not wanting to write another
    before triggered procedure to do the deed for me...

    Has anyone thought of gunning up the column defaults so we
    can specify a calculation to perform using the standard default values
    only. Ie not using some other column as a basis for the calculation...

    Eg. Loading up standard defaults of date('today') and user:

    Create table test(

    tom integer not null not default,

    dick ingresdate not null with default date_part('month', 'today'),

    harry varchar(32) not null with default uppercase(user)

    )

    I know you are at ease with your own self-loathing but much more of this
    and I'm going to go off you too.

    Eg. Of something that would be insane:
    tom integer not null not default,
    dick integer not null with default (tom / 2),
    harry float4 not null with default float(dick)

    It's insane because the order of calculation would be unclear,
    and even if you could make it clear the thought of the dependency tree
    scares the tripe out of me.

    It is insane but that is not the reason. In SQL things happen as if simultaneously, which is why

    UPDATE foo SET a=b, b=a

    works to swap the values of columns a and b.

    Roy
    --- Synchronet 3.21b-Linux NewsLink 1.2