Andreas Kretschmer <[EMAIL PROTECTED]> writes:
>> cast it to varchar(8):

> As i said in a private mail to Scott (sorry): the suggested way don't
> work, at least with 8.1. Maybe this works better in more recent
> versions.

Yes, it works a lot better in 8.2:
http://archives.postgresql.org/pgsql-committers/2006-08/msg00222.php

If you really need the right output type in 8.1, you could force the
issue with an extra level of sub-select:

regression=# create table foo (f1 varchar(8));
CREATE TABLE
regression=# create view voo as select f1::varchar(8) from (select * from foo 
union select * from foo) ss;
CREATE VIEW
regression=# \d voo
            View "public.voo"
 Column |         Type         | Modifiers 
--------+----------------------+-----------
 f1     | character varying(8) | 
View definition:
 SELECT ss.f1::character varying(8) AS f1
   FROM ( SELECT foo.f1
           FROM foo
UNION 
         SELECT foo.f1
           FROM foo) ss;


                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to