App Connect

App Connect

Join this online user group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

Top 3 hidden treasures (in ESQL) 

Tue July 14, 2020 01:10 PM

pressybox
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…

THROW SEVERELY!
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.');

CAST with DEFAULT
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!

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

  1. Anonymous November 20, 2016

    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?

    Thanks



Statistics
0 Favorited
24 Views
0 Files
0 Shares
0 Downloads
Global message icon