on 05-12-2014 9:58 PM
Hi folks,
I have a piece of code that is performing a value lookup for a single string in my procedure, and it's working great;
select fieldValue INTO tempVariable from myTable;
Then I use the results of tempVariable further down in my procedure. The problem is that occasionally no value is found and then the entire procedure stops executing. How can I add an error handler for this? It's not like I can evaluate the value returned in tempVariable after this line executes because the line fails to complete. I'm not finding anything in SQL guide but I'm in a rush so maybe i'm not looking in right place.
Thanks,
-Patrick
Hi Patrick,
In such cases, I initially used to get the COUNT first and keep it in a variable.
Then IF COUNT > 0 then i would allow other statements to follow else we can SIGNAL the exception.
Hope this helps.
Regards,
Krishna Tangudu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Khrishna,
This would not have worked yesterday as I could not step past the select statement without getting the null error. Today i'm able to step past the select and so I added the logic similar to yours and is working fine. I think the server was behaving eraticly yesterday and we have several problems with the indexserver in the past with it hanging and having to restart HANA. Strangely this issue and another I just posted yesterday (fetch row error) are working this morning without me changing any code and without the server being restarted so I'm baffled! So for now, thanks to you guys and I'm crossing my fingers we don't have more issues with this server.
Thanks,
-Patrick
Hi Patrick,
Not sure what you would like to do after catching SQL Exception in this case. May be you give an example.
In general there are various ways to handle SQL Exception and is described in SQL Script guide.
http://help.sap.com/hana/SAP_HANA_SQL_Script_Reference_en.pdf
Please check chapter 7.6
Thanks,
Sagar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.