pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Typecast a user-defined type?
2+ messages / 2 participants
[nested] [flat]

* Typecast a user-defined type?
@ 2000-10-04 15:48  Mark Volpe <volpe.mark@epamail.epa.gov>
  0 siblings, 1 reply; 2+ messages in thread

From: Mark Volpe @ 2000-10-04 15:48 UTC (permalink / raw)
  To: pgsql-sql

Hi,

I've created my own datatype for Postgres. I have found it necessary to be
able to convert it to text, so I could match it up with a text column in a
UNION. I figured Postgres would do this for me, but then, I'm naive. Can
someone give me a hint, or point me to the appropriate material on how to get
"value::text" to work with my new type?

Thanks,
Mark



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

* Re: Typecast a user-defined type?
@ 2000-10-04 15:59  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Mark Volpe <volpe.mark@epamail.epa.gov>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2000-10-04 15:59 UTC (permalink / raw)
  To: Mark Volpe <volpe.mark@epamail.epa.gov>; +Cc: pgsql-sql

Mark Volpe <volpe.mark@epamail.epa.gov> writes:
> someone give me a hint, or point me to the appropriate material on how to get
> "value::text" to work with my new type?

Write a function "text(yourtype) RETURNS text", and the parser will use
it for type coercions from yourtype to text.  In general any type
coercion can be provided this way --- a function of a single argument,
having the same name as its return type, represents a coercion path.

			regards, tom lane



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


end of thread, other threads:[~2000-10-04 15:59 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-10-04 15:48 Typecast a user-defined type? Mark Volpe <volpe.mark@epamail.epa.gov>
2000-10-04 15:59 ` 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