• Resolved samonpress

    (@samonpress)


    First of all, WP Data Access is an amazing tool and I’m really enjoying building projects on it. I was wondering if its possible to create computed columns within Data Designer module itself?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @samonpress,

    >>> I was wondering if its possible to create computed columns within Data Designer module itself?

    You could use the Data Designer to add a column to your table and use it to store computed values. Strickly spoken however, computed values can be computed and should as such not be stored I think, although you might have reason to do so.

    I guess a view would be more applicable, or a feature in Data Projects and/or the Data Publisher. Unfortunately, both are not (yet) avialable. Sorry! But they are on my to do list… 😉

    Best regards,
    Peter

    Thread Starter samonpress

    (@samonpress)

    Hi Peter!

    Looking forward to that feature! For now, can creating a trigger be an alternative solution to this situation?

    Actually, I want to save the computed value because the numbers used for calculation will change time to time. However, the computed number which shows up on the day will be our promise to the other party.

    I’ve been trying to use this trigger statement which is not going through.

    CREATE OR REPLACE TRIGGER grand_trigger
    BEFORE INSERT ON termsheet_db
    FOR EACH ROW
    WHEN INSERTING THEN
    INSERT INTO termsheet_db(grand_totalamt) VALUES (NEW.grandtotal_amt+100),
    END;
    

    Need help!

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @samonpress,

    You cannot insert a new row into a table in a before insert trigger. This would create an infinite loop. Try this:

    SET NEW.grandtotal_amt= NEW.grandtotal_amt + 100;

    Best regards,
    Peter

    Thread Starter samonpress

    (@samonpress)

    Thank you! That worked.

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Great! 🙂

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Computed Columns’ is closed to new replies.