HANA SQL- Default NULL

light111Default 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.

1

Test report that calls the above AMDP procedure.

2

Here the selection is successful and no run time dump.

3

4


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.

5

The run time debug details- 

6

The run time exception(DUMP) details- 

789

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.

10

Now same thing happens if the selection fails on a DB table as well.

1112

Now after adding the DEFAULT NULL addition to the select statement no dump and the procedure executes the next statement.

13


 

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s