Reputation: 378
I Needs to check with first 5 digits of the number variable in stored procedure. Please Find the below example.
SP:
IN "IN_CNBR" VARCHAR(100),
DECLARE v_end VARCHAR(16);
v_end is fetched from the DB and it may have a value of digit up to 16.. But i have to split the first 5 digit of the v_end and have to check with input parameter
and i have a check,
IF (((CAST(IN_CNBR AS BIGINT)) > (CAST(v_end AS BIGINT))))
Is the below one is possible?
v_end:=v_end.substring(0,5);
then
IF (((CAST(IN_CNBR AS BIGINT)) > (CAST(v_end AS BIGINT))))
Thanks in advance,
Upvotes: 0
Views: 520
Reputation:
You can set a variable to the first five characters of itself as follows:
set v_end = left(v_end,5);
or
set v_end = substr(v_end,1,5);
Note that DB2 substr
uses one-based indexing.
Upvotes: 1