I'm trying to insert new records in a table, but something is wrong and the record isn't inserted in the table.
I'm actually using the new/endnew
to setting the properties of my object.
I know that if i use Business Component i can take the error messages using .GetMessages()
but how i can take the error messages using new/endnew
? There's a way to get this?
First note that using a Business Component to do those tasks enforces the execution of the business rules defined in it, checks the foreign keys and updates related redundant formulas, whereas using new
/endnew
is akin to raw database insert.
You can use the error_handler
command/rule to capture DB errors (and act upon them)
Here is an example using error_handler
commands:
Error_handler('OnDBError')
// the code that generates a violation
Sub 'OnDBError'
msg(format(!'DBError: Code:%1 - %2', &gxDBErr, &gxDBTxt), status)
msg(format(!'Op: %1 - Table: %2', &gxOper, &gxErrTbl), status)
&gxErrOpt = 3
EndSub
If you want to crate a log file you can activate the logging features of GeneXus (see the Logging
section in the properties tab of your generator of choice)