Re: PADDING IDENTITY COLUMNS/SEQUENCE NUMBERS with ZEROES

Re: PADDING IDENTITY COLUMNS/SEQUENCE NUMBERS with ZEROES

 

  

Hi,

Edwin Uy wrote:

>Is this at all possible or is this a stupid requirement?

Yes :-)

>A customer wants to have a column that is to auto-generated, that is, DBAs call
>them IDENTITY in MSSQL and SEQUENCE in Oracle or DB2 I guess? Well, the
>easy part is you can auto-generate the values, but customer wants them
>3-char long, that is, 001, 002. Is it possible to achieve this or do I
>just format the values as they are displayed on the FORM or as they are
>extracted from SQL.


Something like this?:

create table no_thousand_alike
(nta_key varchar2(4),
somedata varchar2(32));
create sequence nta_seq;
INSERT INTO no_thousand_alike
values (to_char (nta_seq.NEXTVAL,'009'), 'Da data');
INSERT INTO no_thousand_alike
values (to_char (nta_seq.NEXTVAL,'009'), 'Mo data');
INSERT INTO no_thousand_alike
values (to_char (nta_seq.NEXTVAL,'009'), 'Even mo');
INSERT INTO no_thousand_alike
values (to_char (nta_seq.NEXTVAL,'009'),'last data');

select * from no_thousand_alike;




Oracle LazyDBA home page