Skip to Content

Return code after INSERT or UPDATE in hana sql script

Hi Experts,

How to capture return code after INSERT or UPDATE or UPSERT in hana database.

Below is the code which i am trying.

create procedure "ABC"."EFG"

AS

BEGIN

declare str varchar(500);

declare v_stmt varchar(10);

v_matnr := '123456';

str := 'insert into "SCHE"."ZTEST_TABLE" values (' ||V_MATNR|| ')';

v_stmt := EXEC (:STR);

END;

Thanks,

Ebinezar

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Nov 18, 2015 at 08:13 AM

    Hi Ebinezar,

    what do you mean with return code?

    What you can check after insert,update, upsert is the number of updated rows. Therefore we have the system variable ::ROWCOUNT.

    BTW, you do not need to use EXEC in you procedure. You can rewrite the procedure as follows:

    create procedure "ABC"."EFG"

    AS

    BEGIN

    declare str varchar(500);

    declare v_stmt varchar(10);

    declare v_matnr varchar(10);

    v_matnr := '123456';

    insert into "SCHE"."ZTEST_TABLE" values ( :V_MATNR) ;

    END;

    Best regards,

    Katharina

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 09, 2015 at 01:39 PM

    Hello,

    You're probably looking for an sql general exit handler.

    Example from the official documentation:

    Exception Handling Examples - SAP HANA SQLScript Reference - SAP Library

    BRs,

    Lucas de Oliveira

    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.