PL/SQL - Leading zeros

I have a table that I am trying to concatenate the alpha, next_number, suffix, and length fields together with leading zeros. I cannot get the length to work correctly. If I put 10 in the field "LENGTH" then it work fine. However, I want the user to be able to define the length via a table.

So the above concatenate the alpha, next_num, and suffix together. The leading zeros is the length so for this example, say 10. If my alpha, next_num, and suffix is 12345, it should display as 0000012345 with 0 leading zeros since my length is 10.

Just thought of something:
If you take the output and put it back into a numeric data type, you will lose the leading zeros. LPAD returns one of the character data types like varchar2, clob, etc.. you need to keep it as such.

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Thanks slightwv. Found out the length (6 character) wasn't long enough when my data is 7 characters long.

Reason why I kept mentioning PL/SQL is because this is the platform I am working with is Oracle. Sometimes people tried giving me MS SQL answers and find out it's Oracle platform, and syntax may be a bit different. Example, instead of "Print" for output it's "dbms_output.put_line" instead for oracle. Just like your example, using "||" to concatenate is different than "+" for MS SQL. So I just want to clarify that.

Featured Post

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:
ht…