Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

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

0 Kudos

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

1 ACCEPTED SOLUTION

lbreddemann
Active Contributor
0 Kudos

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.

2 REPLIES 2

lbreddemann
Active Contributor
0 Kudos

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.

pfefferf
Active Contributor
0 Kudos

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