Informix

Informix

Connect with Db2, Informix, Netezza, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only
  • 1.  C UDR using mi_trigger_get_old_row() and mi_trigger_get_new_row()

    Posted 3 days ago
    I suspect you are getting a NULL rather that a valid row ptr, I believe it will be NULL cos you are in a SPL

    An MI_ROW pointer
    A pointer to the old row.

    NULL
    The function was one of the following:
    not successful.
    not in the trigger action.
    not in the FOR EACH row trigger.
    not in one of the DELETE or UPDATE triggers.


    On 9/3/2025 3:27 PM, Jean-Guy Charron via IBM TechXchange Community wrote:
    01000199114329d4-a23cc2f6-599d-415a-9251-a193c02f6858-000000@email.amazonses.com">
    Hi Everyone, I have create a C UDR row_to_json that use mi_trigger_get_old_row() and mi_trigger_get_new_row() to have access to the trigger row... -posted to the "Informix" group


  • 2.  RE: C UDR using mi_trigger_get_old_row() and mi_trigger_get_new_row()

    Posted 3 days ago

    Yes I effectivly received a NULL.

    But since I call the UDR from an SPL with trigger references I expected to received the old/new row. 

    I just hoped there was a solution.

    Thanks for your help



    ------------------------------
    Jean-Guy Charron
    ------------------------------



  • 3.  RE: C UDR using mi_trigger_get_old_row() and mi_trigger_get_new_row()

    Posted 3 days ago
    A real NULl or just crap ?

    Cheers
    Paul

    Paul Watson
    Oninit LLC
    +1-913-387-7529
    www.oninit.com
    Oninit®️ is a registered trademark of Oninit LLC





  • 4.  RE: C UDR using mi_trigger_get_old_row() and mi_trigger_get_new_row()

    Posted 3 days ago
    Yes a NULL
    And mi_trigger_event() return MI_ERROR (-1)

    Jean-Guy





  • 5.  RE: C UDR using mi_trigger_get_old_row() and mi_trigger_get_new_row()

    Posted 2 days ago

    Hi Paul,

     

    I send the C UDR and a working.sql and a notworking.sql scripts.

     

    You will see in the DEBUG* files the tracing.

     

    What I need to do, is a generic UDR that take the old/new row and return a lvarchar containing a json of the data excluding TEXT, BYTE, BLOB, CLOB, row, collection, list, ... and limiting lvarchar column to the first 255 characters.

     

    After that I can cast it in json and bson to keep a log of change in important tables in a generic log tables.

     

    So the working.sql call row_to_json directly from the trigger and pass the value to a SPL procedure with trigger references.

    The notworking.sql call the row_to_json from the SPL procedure with triggers references.

     

    Thanks for your help.

     

    Jean-Guy Charron

    Président

    Logiciels Sys-Thèmes inc.

     

    514-381-5460 x 202

    jeanguy.charron@systhemes.ca

    website

    systhemes.ca   flexio-erp.ca

    address

    205-863 St-Pierre, Terrebonne, Qc, J6W 1E6

    signature_1262202784

     




    Attachment(s)

    txt
    row_to_json.sql.txt   200 B 1 version
    txt
    README.txt   464 B 1 version
    c
    row_to_json.c   10 KB 1 version
    txt
    DEBUG.working.txt   2 KB 1 version
    txt
    DEBUG.notworking.txt   50 B 1 version
    txt
    DEBUG.row_to_json.trc.txt   66 KB 1 version
    txt
    DEBUG.notworking.txt   50 B 1 version
    txt
    working.sql.txt   7 KB 1 version
    txt
    notworking.sql.txt   7 KB 1 version
    sh
    row_to_json.sh   259 B 1 version