Examples of trigger
Hello people!
I am Brazilian and I am starting to work with the latest version of CACHE, and I would like to know where I can see an example of a TRIGGER, I would like to validate the fields before writing the actual data in the database.
in advance, thank you very much! and sorry for any mistake in concordance in english
Hi Luiz,
Here is the Caché documentation for building triggers.
-Marc
Hi @Luiz Henrique Carvalho Martarelli
You can take a look at this post: Trigger or Callback?
https://community.intersystems.com/post/trigger-or-callback
And for more detail information: Using Triggers
https://cedocs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GSQL_triggers
If you have interested, the Developer Community has a Discord with a dedicated Channel for Portuguese Speakers.
https://discord.gg/dzzPDvY
Best Regards,
Henrique
Thanks very much!
Tamo junto!

Use ValidateObject(), from %Persistent, see about this in:
https://docs.intersystems.com/irislatest/csp/documatic/%25CSP.Documatic....
ValidateObject sample: https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...
Unless things have changed with IRIS I generally prefer to use triggers over any of the object implementations. Properly defined triggers will be executed whether you are doing an object Save or a SQL INSERT/UPDATE/DELETE. You may only want to perform the code during object save but I find why not implement the code in a trigger where you know it will always be executed. Additionally triggers provider
{ColumnName*N}
{ColumnName*O}
syntax which is valuable.
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue