The SQLError can trigger the database event.
(event-type : RAISERROR)
And Message statement can write to the Windows Event Log.
Please refer to the following documents.
"CREATE EVENT statement"
http://dcx.sap.com/index.html#sa160/en/dbreference/create-event-statement.html
"MESSAGE statement"
http://dcx.sap.com/index.html#sa160/en/dbreference/message-statement.html
Thanks