Orable ... as in Oracle .. get it? Eh, eh? Oh yes, Oracle fans can find that and all sorts of other creative puns over at the IHOC. But I didn't pick Matt's submission just so I could plug the club ... or even so I could share the obligatory Oracle Consultant link. No, today's code actually represents an impressive combination of both the use and avoidance of the built-in string padding function, RPAD ...
/* Prepare firstname */ IF v_first_nm IS NULL THEN v_first_nm := RPAD_SPACES ( 9 ); END IF; IF LENGTH ( v_first_nm ) < 9 THEN v_first_nm := RPAD ( v_first_nm , 9 , ' ' ); END IF; /* Prepare lastname */ IF v_last_nm IS NULL THEN v_last_nm := RPAD_SPACES ( 15 ); END IF; IF LENGTH ( v_last_nm ) < 15 THEN v_last_nm := RPAD ( v_last_nm , 15 , ' ' ); END IF; /* ED: Snip ... */ FUNCTION RPAD_SPACES ( SPACES NUMBER ) RETURN CHAR IS PADVAR VARCHAR2 ( 60 ); PAD CHAR ( 1 ) := ' '; LOOPVAR NUMBER ( 2 ); BEGIN IF SPACES = 1 THEN RETURN PAD; ELSIF SPACES = 2 THEN RETURN PAD || PAD; ELSE FOR LOOPVAR IN 1 ..SPACES - 2 LOOP PADVAR := PAD || RPAD ( PAD , LOOPVAR + 1 , ' ' ); END LOOP; RETURN PADVAR; END IF; END;
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!