Informix

 View Only

 C UDR using mi_trigger_get_old_row() and mi_trigger_get_new_row()

Jean-Guy Charron's profile image
Jean-Guy Charron posted Wed September 03, 2025 04:27 PM

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 data.

When I call it directly from the for each row of a trigger it is working well.

But when from the for each row I call a SPL procedure with trigger references and this procedure call my C UDR, the mi_trigger_get_old_row() and mi_trigger_get_new_row() did't work.

The big question is why ?

I try with execute function and call but it's not working.

The definition of the C UDR is:

CREATE FUNCTION row_to_json(which LVARCHAR)
RETURNS LVARCHAR
EXTERNAL NAME '$INFORMIXDIR/extend/row_to_json.bld(row_to_json)'
LANGUAGE C;

Someone have and idea ?

Best Regards

Art Kagel's profile image
Art Kagel IBM Champion

Jean-Guy:

Partly a guess here, but the trigger has already fetched the pre and/or post verion(s) of the affected row, so it is no longer available to the URL that you wrote. I would suggest just having the SPL version convert the pre or post or both records, as appropriate, to ROW() types then use genbson()::JSON to perform the conversion directly there. Writing a generic function would be harder in SPL, but you don't have to each SPL trigger function can be specific to the trigger that calls it anyway.

Art