Re: Casting pairs of floating point variables as a point in plpgsql
В списке pgsql-sql по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: Casting pairs of floating point variables as a point in plpgsql |
| Дата | |
| Msg-id | 12044.1014337106@sss.pgh.pa.us обсуждение |
| Ответ на | Casting pairs of floating point variables as a point in plpgsql (ishapiro@cogitations.com (Irv Shapiro)) |
| Список | pgsql-sql |
ishapiro@cogitations.com (Irv Shapiro) writes:
> How do I cast the logitude and latitude floatig point numbers, stored
> in my plpgsql variables into a point datatype so I can use it with the
> earthdistance function.
> I tried the following and it returns a syntax error on the "as":
> select cast((m_zip_info1, m_zip_info2) as point) <@>
> cast((m_merchant_zip1, m_merchant_zip2) as point) into m_miles;
You cannot "cast" two floats into a point (a cast always operates on
a single data value). However, a moment's perusal of pg_proc shows
that there is a function point(float8,float8), so this should work:
select point(m_zip_info1, m_zip_info2) <@> point(m_merchant_zip1, m_merchant_zip2) into m_miles;
regards, tom lane
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера