pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Defining Field Types with view
2+ messages / 2 participants
[nested] [flat]

* Defining Field Types with view
@ 2004-09-01 20:27  Traci Sumpter <Traci.Sumpter@opus.co.nz>
  0 siblings, 1 reply; 2+ messages in thread

From: Traci Sumpter @ 2004-09-01 20:27 UTC (permalink / raw)
  To: pgsql-sql

Cheesy one here....

I created a view similar to

Select field1, field2 from table
	where field3 = 'Fred'
UNION
Select field1, field2 from table
	where field3 = 'Wilma';

When the view contains just one sql statement the field definitions e.g.
charater varying (20) however when both are in the fields turn into
character varying (no size).

this is causing a problem when referring to the fields within Dephi/VB
because they think the varchar fields are memo.


I have got around it by creating another view which selects
field1::varchar(100) , field2 varchar(50) from firstview.


I have tried casting the fields within the first view but to no sucess.

Any way to get over this???

Cheers




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Defining Field Types with view
@ 2004-09-01 22:41  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Traci Sumpter <Traci.Sumpter@opus.co.nz>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2004-09-01 22:41 UTC (permalink / raw)
  To: Traci Sumpter <Traci.Sumpter@opus.co.nz>; +Cc: pgsql-sql

"Traci Sumpter" <Traci.Sumpter@opus.co.nz> writes:
> Cheesy one here....

Got a cheesy answer for you --- cast the result ...

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

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2004-09-01 22:41 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-09-01 20:27 Defining Field Types with view Traci Sumpter <Traci.Sumpter@opus.co.nz>
2004-09-01 22:41 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox