Working in a fog today and simply cannot think my way through this question. So rather than continue to pound my head on the desktop, I'll ask the fine folks in this forum.
How can I identify the newly created row(s) for a table within the proc for TRIGGER PROCEDURE FOR CREATE OF Customer?
Unlike the TRIGGER PROCEDURE FOR WRITE which optionally passes in the OLD and NEW buffers for the target table, I do not have these buffers for the CREATE trigger proc. Or do I?
Is the trigger fired while the new Customer record is still in an open transaction and not yet committed, thereby allowing me to create a dynamic query for all Customer records where ROW-STATE = ROW-CREATED?
Do I have access to the BEFORE-TABLE for Customer in the CREATE trigger? Do I need this object in the CREATE trigger? If so, how do I access it?
https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvref/trigger-procedure-statement.html
Thanks much.
You can access the new record just by using the default buffer Customer in that trigger procedure.
It may be simpler to ask what you are trying to achieve, Rom? The create trigger is fired after the empty record is created on the database, as far as I remember. The data you have available to you will be very limited, probably just the default values of the record. The write trigger then fires once the record is committed to the database. The values are in the default customer buffer.
If you're wanting to capture the values of new records only, for example, then in the write trigger you can check for IF NEW Customer.
You can access the new record just by using the default buffer Customer in that trigger procedure.
It may be simpler to ask what you are trying to achieve, Rom? The create trigger is fired after the empty record is created on the database, as far as I remember. The data you have available to you will be very limited, probably just the default values of the record. The write trigger then fires once the record is committed to the database. The values are in the default customer buffer.
If you're wanting to capture the values of new records only, for example, then in the write trigger you can check for IF NEW Customer.
Thank you gentlemen!
note that the write trigger can fire more than once for a new record. this can happen when not all field values are assigned in a single assign statement. for example, suppose you set all the key field values in one assign statement and then all the others in a second assign statement. now you have a create followed by an entirely separate update.
Thanks for the clarification, Gus. For the use case I'm working with, the behavior you described would not create any issues.