Skip to Content
author's profile photo Former Member
Former Member

Exception Handling in HANA

Hi,

I have created a UDF with try and catch block to handle invalid dates.


My select statement is taking more time than the usual time if I use this function.


How to optimize my below code? or Is there any other way to handle the exception.


Please provide your suggestions.


Below is my function to handle the exception.

CREATE FUNCTION <schema name>.<function name>(INPUT VARCHAR(100))

RETURNS OUTPUT DATE LANGUAGE SQLSCRIPT SQL SECURITY INVOKER

AS

BEGIN

DECLARE EXIT HANDLER FOR SQLEXCEPTION

BEGIN

OUTPUT:=NULL;

END;

OUTPUT:=TO_DATE(:INPUT);

END;

Regards,

Ranjith.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Sep 09, 2016 at 06:04 AM

    Introduction:

    Exception handling is a method for handling exception and completion conditions in an sqlscripts procedure. There are three tools can be used:

    • EXIT HANDLER
    • CONDITION
    • SIGNAL or RESIGANL.

    The DECLARE EXIT HANDLER parameter allows you to define exception handlers to process exception conditions in your procedures.

    You can explicitly signal an exception and completion condition within your code using signal and RESIGNAL.

    More Informations: SAP HANA Central

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.