Re: separar datos de un campo

From: Miguel Angel Hernandez Moreno <miguel(dot)hdz(dot)mrn(at)gmail(dot)com>
To: Hellmuth Vargas <hivs77(at)gmail(dot)com>
Cc: Lista PostgreSql <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: separar datos de un campo
Date: 2011-08-19 16:39:12
Message-ID: CAGYOd3p+oH2K9jniTB3-tg-qt+hvwhjguBqqdHriP4guFoLGkw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

muchas gracias a todos

las funciones split_part y el manejo de puntos como array me han servido de
mucho,
son lo que necesitaba

split_part(campo1::text,',',1),
split_part(campo1::text,',',2),

campo1[0] as x,
campo1[1] as y

El 19 de agosto de 2011 11:31, Hellmuth Vargas <hivs77(at)gmail(dot)com> escribió:

> Hola
> según veo en la documentación, para acceder a los componentes x,y de
> un datos point seria similar al de los arreglos por lo tanto para x
> seria campo[0] y para y campo[1]
>
> osea que un select tentativo seria
>
> SELECT campo_punto[0] AS x, campo_punto[1] AS y FROM tabla....
>
>
> http://www.postgresql.org/docs/8.4/static/functions-geometry.html
>
> "It is possible to access the two component numbers of a point as
> though the point were an array with indexes 0 and 1. For example, if
> t.p is a point column then SELECT p[0] FROM t retrieves the X
> coordinate and UPDATE t SET p[1] = ... changes the Y coordinate. In
> the same way, a value of type box or lseg can be treated as an array
> of two point values."
>
> 2011/8/19 Miguel Angel Hernandez Moreno <miguel(dot)hdz(dot)mrn(at)gmail(dot)com>:
> > Saludos lista
> >
> > Tengo un campo tipo point en una tabla, el cual contiene la latitud (
> > coordenada posotiva)y longitud (coordenada negativa)
> >
> > (-100.298390507273,25.6720346672794)
> >
> > lo que deseo es hacer un select a este registro pero manejarlo de tal
> forma
> > que me regrese por separado las coordenadas,
> > pense manejarlo con expresiones regulares en uan funcion de postgres y
> > evaluar el registro
> >
> > pero no se si podria hacer mejor solo en un select
> >
> > --
> > ISC Miguel Angel Hernandez Moreno
> >
> >
>
>
>
> --
> Cordialmente,
>
> Ing. Hellmuth I. Vargas S.
> -
> Enviado a la lista de correo pgsql-es-ayuda (pgsql-es-ayuda(at)postgresql(dot)org
> )
> Para cambiar tu suscripción:
> http://www.postgresql.org/mailpref/pgsql-es-ayuda
>

--
ISC Miguel Angel Hernandez Moreno

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Miguel Angel Hernandez Moreno 2011-08-19 16:52:18 Re: Problemas con pgpool
Previous Message Hellmuth Vargas 2011-08-19 16:31:32 Re: separar datos de un campo