Stop PeopleCode Processing with Error

A blunt, but useful method for debugging PeopleCode is to use the inbuilt "Error" function to stop processing and provide a message.

Something as simple as this can be a valuable debugging tool at times:

Error "The value of variable x=" | &x;

Most people use message box (or the now very deprecated WinMessage), but at times this may not appear depending on the context of the PeopleCode you are executing. Error stops processing (a poor man's breakpoint) so you can find out what's going on at that exact point in the code.

Note: Error causes a rollback of any pending database transactions, so if you need to store the state of the DB, put in a commit (e.g. SQLExec("commit") on Oracle) before throwing the error. 注意:错误会导致回滚所有待处理的数据库事务,所以如果你要在数据库中保存当前状态,请在抛出错误之前提交一个commit 

posted @ 2013-10-24 13:53  Bryan chen  阅读(220)  评论(0编辑  收藏  举报