I know how to create a sequence in pl sql. However, how would I set the values to all have say 3 digits? is there another sql statement to do this when I create a sequence?
so an example would be:
000
001
012
003
Thanks guys!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First, just to be clear, you do not create sequences in PL/SQL. You can only create sequences in SQL.
Second, if you want a column to store exactly three digits, you would need the data type to be
VARCHAR2(or some other string type) rather than the more commonNUMBERsince aNUMBERby definition does not store leading zeroes. You can, of course, do that, but it would be unusual.That said, you can use the “fm009” format mask to generate a string with exactly 3 characters from a numeric sequence (the “fm” bit is required to ensure that you don’t get additional spaces– you could
TRIMthe result of theTO_CHARcall as well and dispense with the “fm” bit of the mask).