How to get the dimension of a DECLAREd variable in SPs?
-
26-09-2019 - |
문제
Suppose I declared some variables in SPs.
DECLARE _R1 VARCHAR(25);
DECLARE _R2 DECIMAL(4,0);
DECLARE _R3 DECIMAL(3,0);
DECLARE _R4 DECIMAL(2,0);
How do I get their dimensions like 25, 4, 3, 2?
해결책
One option is to create a really long value.
Than put in the variable, and run the length() function on it. As it will keep only as much value as the definition says it returns the correct length.
Now remains to find out how to do this without affecting the current value.
SET _R1=LPAD('',1000,1);
RETURN(LENGTH(_R1));
제휴하지 않습니다 StackOverflow