Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL- Left justified with zero maintaining 4 digits of number.

Re: SQL- Left justified with zero maintaining 4 digits of number.

From: Steffen Stellwag <Steffen.Stellwag_at_pcm.bosch.de>
Date: Tue, 22 Sep 1998 13:16:28 +0200
Message-ID: <3607870C.2480@pcm.bosch.de>


Lío wrote:
>
> May be I have missed something in your question. At first sight it
> seems to as simple as:
>
> To_char(id_number, '0999')
>
> You can take the id_number from a sequence or a loop structure and
> translate it to char with the leading zeroes.
>
> Excuse me if this was not your question.
>
> azhan98_at_tm.net.my wrote in message
> <6tsc3d$a9p$1_at_nnrp1.dejanews.com>...
> >Hi all,
> >
> >I have problem again.
> >I want to create a number with 4 digits.Using SQL or PL/SQL.
> >The number will be in a sequential pattern (as an ID).
> >
> >The problem is, how can I format the number so that it can be always
> >" left justified with 0 (Zero) but maintaining the 4 digit limits ".
> >

id_str := to_char(id_number);
l := length(id_str);

formatted_string := lpad(id_str,4-l,'0');

That's it Received on Tue Sep 22 1998 - 06:16:28 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US