Re: text to point conversion not working. ( cannot cast type text to point ) - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: text to point conversion not working. ( cannot cast type text to point )
Date
Msg-id 20060928102805.GC10591@svana.org
Whole thread Raw
In response to text to point conversion not working. ( cannot cast type text to point )  (Dan Libby <dan@libby.com>)
List pgsql-general
On Wed, Sep 27, 2006 at 08:14:29PM -0600, Dan Libby wrote:
> Hi all,
>
> Using pgsql 8.0.1
>
> I'm just starting with using the geometry data types in postgres, and ran into
> what seems like a very basic problem.  Namely, I can't seem to convert/cast
> type text into type point when that text results from any expression.  Ie, it
> *only* works for a plain string literal.

String literals are not text. You can however cheat a little like so:

# SELECT point_in( textout ( '1' || ',2' ) );
 point_in
----------
 (1,2)
(1 row)

textout turns a text value to a "string literal" (sort of) which is
then parsed by the point input function.

If you want you can encapsulate this into a function and create the
cast yourself.

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

pgsql-general by date:

Previous
From: "Adnan DURSUN"
Date:
Subject: Can i see server SQL commands ?
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Definition of return types for own functions?