I’m working on a PL/SQL algorithm, with Oracle.
I currently have a procedure which have one single numeric parameter. My procedure have to create a string which contains as much ‘0’ as the parameter value.
I am currently using a for loop to achieve this:
MY_STRING VARCHAR2(30);
FOR I IN 1..MY_PARAMETER
LOOP
MY_STRING := CONCAT(MY_STRING, '0');
END LOOP;
Is it possible to do it in a linear way ? I mean without a loop, or even with one single statement.
Any help would be appreciated !
Thanks.
You can use LPAD() to achieve this:
SELECT LPAD('0', my_parameter, '0') FROM DUALHere is the link to the manual:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions082.htm#i1371196