Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Jean-Guy Charron's C UDR row_to_json using mi_trigger_get_old_row and mi_trigger_get_new_row received NULL, with mi_trigger_event returning MI_ERROR, when called from an SPL with trigger references. Paul Watson said the functions return NULL outside the trigger action. Jean-Guy sent working and non-working scripts. No solution was given.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
Paul Watson — source: IBM Community (ConnectedCommunity.org) Informix forum
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
↪ replying to Paul Watson
Jean-Guy Charron — source: IBM Community (ConnectedCommunity.org) Informix forum
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
------------------------------
↪ replying to Jean-Guy Charron
Paul Watson — source: IBM Community (ConnectedCommunity.org) Informix forum
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
↪ replying to Paul Watson
Jean-Guy Charron — source: IBM Community (ConnectedCommunity.org) Informix forum
Yes a NULL
And mi_trigger_event() return MI_ERROR (-1)
Jean-Guy
↪ replying to Paul Watson
Jean-Guy Charron — source: IBM Community (ConnectedCommunity.org) Informix forum
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
systhemes.ca
flexio-erp.ca
205-863 St-Pierre, Terrebonne, Qc, J6W 1E6
Your privacy choices
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.