Embedded SQL Exception/Error Handling
April 2, 2014 Paul Tuohy
At times, I wish embedded SQL would act more like RPG. A case in point is with exception/error handling. Embedded SQL assumes you are using SQLCODE or SQLSTATE to check whether or not each statement worked. In RPG, the equivalent would be have an E extender on every file operation code and checking the %error() after the operation code. Wouldn’t it be nice if you could get embedded SQL to cause the program to fail if it gets an unexpected error–just like RPG? Well, you can, just by adding one line of code after each SQL statement. Figure 1 shows |