Default Null
In HANA SQL script, while doing a SELECT of a single column value from a DB table or Internal table, if the selection is unsuccessful then it raised SQLEXCEPTION. In such a case either we have to handle the exception or we can assign a default value in case the selection is not successful.
This post shows how to assign a DEFAULT NULL value in the selection process. It is also possible to handle the exception and exit from there which will see in the upcoming post.
In below, as shown trying to read a single field value from the DB table as well as from the internal table.
Test report that calls the above AMDP procedure.
Here the selection is successful and no run time dump.
Let’s try with the internal table Select and here we are trying to read with a different field value that doesn’t exists in the internal table.
The run time debug details-
The run time exception(DUMP) details-
Above selection results in NO DATA FOUND( CODE- 1299 ) SQL Exception.
In order to avoid that , just add DEFAULT NULL to the SELECT statement and in case the selection is unsuccessful, it contains NULL value according to the variable data type.
Now same thing happens if the selection fails on a DB table as well.
Now after adding the DEFAULT NULL addition to the select statement no dump and the procedure executes the next statement.
One comment