문제

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));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top