07-27-2016 5:23 AM
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
07-27-2016 5: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.
07-27-2016 5: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.
07-27-2016 5: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