Re: pad column with leading zeros or space

Поиск
Список
Период
Сортировка
От Johnson, Shaunn
Тема Re: pad column with leading zeros or space
Дата
Msg-id 73309C2FDD95D11192E60008C7B1D5BB0452DDAE@snt452.corp.bcbsm.com
обсуждение исходный текст
Ответ на pad column with leading zeros or space  ("Johnson, Shaunn" <SJohnson6@bcbsm.com>)
Список 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.Pfau@emCrit.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]

В списке pgsql-general по дате отправления:

Предыдущее
От: "Johnson, Shaunn"
Дата:
Сообщение: pg_dump question
Следующее
От: "Command Prompt, Inc."
Дата:
Сообщение: pgManage (GUI PostgreSQL front end)