Using right() in a view

Поиск
Список
Период
Сортировка
Искать

Using right() in a view

От:
Chrishelring <christianhelring@gmail.com>
Дата:
Hi all,

please foregive me for this rather trivial question, but I´ve worked in it
for quite som time and could use som help now. :)

I have a table where it want to create a idkey using our municipality number
+ the road number + the housenumber.

The municipality and housenumber is in a fixed size, so they are okay. But
the road number differs from two digits up to four. I was then thinking
about doing something like this:

CREATE OR REPLACE VIEW test AS 
SELECT 
  right(cast('000' as text) || cast(road_number as text), 4) AS GEO_ADRESSE
  
FROM rk_ois.bbrbygning
WHERE ejerlav <> 0

to ensure that the road_number would be a fixed size (four digitis).
Unfortunately this doesn't work. 

Any idea on how to solve this?

Christian

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Using-right-in-a-view-tp4419141p4419141.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Re: Using right() in a view

От:
Bosco Rama <postgres@boscorama.com>
Дата:
Chrishelring wrote:
> 
> CREATE OR REPLACE VIEW test AS 
> SELECT 
>   right(cast('000' as text) || cast(road_number as text), 4) AS GEO_ADRESSE
>   
> FROM rk_ois.bbrbygning
> WHERE ejerlav <> 0
> 
> to ensure that the road_number would be a fixed size (four digitis).
> Unfortunately this doesn't work. 

Try using:
   select to_char(road_number, 'FM0000') as GEO_ADRESSE

HTH

Bosco.
FAQ