Strictly speaking, not so much hidden actually as maybe hiding in plain sight. Everything described below has been part of IIB for some time. Maybe though, like me, you were just not aware completely. Well, let’s see…

The first little ESQL nugget is about the THROW statement. While virtually every IIB developer has used it to THROW an EXCEPTION in one flow or another, if you searched your workspace right now, how many occurrences of THROW EXCEPTION would you find without the SEVERITY keyword?
Using the THROW EXCEPTION statement like that will publish the exception as INFO in the Unix syslog and will keep it from appearing correctly in the Windows error log. So, if you have decided to throw an exception from your code, remember to throw it severely! For example…
THROW USER EXCEPTION SEVERITY 3 MESSAGE 2951 VALUES('Error detected.','Missing baubles.');

This is another example of a very common ESQL function with an added twist. After all, everybody uses CAST. However not many people realise that there is a DEFAULT clause in the function which is intended to simplify exception handling for the CAST function itself.
So in case anything goes wrong in the execution, the default gets used. For example: SET chrResponseTimeSLA = CAST(intResponseTime AS CHAR DEFAULT 'N/A');
In the example above using CAST with DEFAULT saves a otherwise necessary COALESCE statement.

Executable comments
Did you know that it’s possible to include comments in your ESQL that are actually executed at runtime?
This is useful when the tooling raises an error that is not actually an error and therefore prevents a deploy. While is certainly not the norm, it can happen, for example in case of version differences between the tooling and the runtime. The syntax for executable comments is similar to normal comments and documented in the KnowledgeCenter.
/*!{ DECLARE chrMerry CHAR 'Xmas!'; }!*/

Can you think of other hidden ESQL treasures? Let us know!

PS: Do you like the festive IIB posts? You can easily find them all by having a look at our festive calendar or click on the festive2015 tag.

1 comment on"Top 3 hidden treasures (in ESQL)"

  1. Hi,
    May I know which is the best way to create modules in esql? Some saying creating all the modules realted one application in esql file is better and some saying splitting is the bestway. In terms of memory management and performance, which one would be the best?


Join The Discussion

Your email address will not be published. Required fields are marked *