Re: pad column with leading zeros or space

From: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: pad column with leading zeros or space
Date: 2002-01-23 23:53:12
Message-ID: 73309C2FDD95D11192E60008C7B1D5BB0452DDAE@snt452.corp.bcbsm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks all (special thanks to Tom, Tom and Stephan):

I have two views down and one more to figure out. So far, the
results is pretty much what is required. Only time will tell
if 'The Powers That Be' change their minds.

If anyone is interested, this is what I did: I derived this from
a table that I had already created and populated with data.
Since creating a table with fix-length characters and padded
values wasn't going to work, I did:

[snip sql]

/*
--creating special view of bp_disease

drop view v_bp_disease;
create view v_bp_disease as
select
lpad (bp_disease_id::text,10,'0') as bp_disease_id,
rpad (bp_dis_label::text,30,' ') as bp_dis_label
from bp_disease
;
*/
[/snip]

What's interesting is that in the original table, I had to have
a column that had to increment with each new row. That would
return a regular number (I think I might have used serial
for this instance).

The view makes it look like the specs; zeros in front of
incrementing numbers, space behind the right places.

I have more questions, but I think I'll quit for
now ...

Thanks again!

-X

-----Original Message-----
From: Tom Pfau [mailto:T(dot)Pfau(at)emCrit(dot)com]

Use a view:

create view v_devel as
select lpad(bp_member_id::text, 10, '0') as bp_member_id, ... from
t_devel;

[snip]

Browse pgsql-general by date

  From Date Subject
Next Message Johnson, Shaunn 2002-01-24 00:02:35 pg_dump question
Previous Message Bruce Momjian 2002-01-23 22:53:00 Re: persistent portals/cursors (between transactions)