Skip to Content

Error while running the database procedure in HANA - string is too long exception

My database procedure is defined as below -

CREATE PROCEDURE EXAMPLE_SCALAR_VARIABLES7 ( IN IV_CUSTOMID NVARCHAR(8) , IN IV_ADDITIONAL_DISCOUNT INTEGER )

LANGUAGE SQLSCRIPT

SQL SECURITY INVOKER

READS SQL DATA AS

LV_DISCOUNT NVARCHAR;

LV_NEW_DISCOUNT NVARCHAR;

BEGIN

SELECT DISCOUNT

INTO LV_DISCOUNT FROM SFLIGHT.SCUSTOM WHERE ID = :IV_CUSTOMID;

LV_NEW_DISCOUNT := :LV_DISCOUNT +

:IV_ADDITIONAL_DISCOUNT;

END;

After creating this procedure via SQL console,

I call the procedure as below-

CALL "HANAUSER"."EXAMPLE_SCALAR_VARIABLES7" ( 00000001, 10 );

But i am getting an error while executing this -

SAP DBTech JDBC: [359]: string is too long: [359] "HANAUSER"."EXAMPLE_SCALAR_VARIABLES7": line 9 col 1 (at pos 240): [359] (range 3) string is too long exception

Please tell me what is the issue conceptually thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jul 27, 2016 at 04:44 AM

    Your declarations of

    LV_DISCOUNT NVARCHAR;

    LV_NEW_DISCOUNT NVARCHAR;

    are in an odd place and don't have any length information.

    If I'm not mistaken, the default length then is 1.

    Later on you try to select DISCOUNT, which is probably a number, into the LV_DISCOUNT variable. Looks like the value in DISCOUNT is not a single digit number, so after conversion into a character string, the result is longer than 1 characters.

    And that's where the error message comes from.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 27, 2016 at 04:48 AM

    You declared your variables LV_DISCOUNT and LV_NEW_DISCOUNT with only NVARCHAR without length information. That means that you have an NVARCHAR(1) by default which cannot store the result of the discount selection from your table SFLIGHT.SCUSTOM. So the length of the LV_[NEW]_DISCOUNT variables has to be increased.

    I think that also the NVARCHAR type is wrong here. A discount is a numeric value in normal cases. You also do an arithmetic operation in your coding, which is a further indicator for me, that it should be numeric.

    Regards,

    Florian

    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.