pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ishapiro@cogitations.com
To: pgsql-sql@postgresql.org
Subject: Casting pairs of floating point variables as a point in plpgsql
Date: 18 Feb 2002 11:02:10 -0800
Message-ID: <758d9f0.0202181102.77fbc9ea@posting.google.com> (raw)

I have a zip code database which includes pairs of floting point
numbers representing latitude and longitude.  I can retieve this data
with the following query:


Declare
  
m_zip_info1 char(5);
m_zip_info2 char(5);
m_miles integer;
m_zipcode char(5) := ''60076'';

Begin

select logitude, latitude into m_zip_info1, m_zip_info2
     from zipstate where zipcode = m_zipcode;

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;

I also tried the following, and Postgresql complained about the "::"

select (m_zip_info1,m_zip_info2)::point <@>
       (m_merchant_zip1,m_merchant_zip2)::point into m_miles;

Any help would be greatly appreciated.

Irv
ishapiro@cogitations.com



view thread (2+ messages)  latest in thread

Message-ID: <758d9f0.0202181102.77fbc9ea@posting.google.com>
Permalink:  ../758d9f0.0202181102.77fbc9ea@posting.google.com/
Also on:    postgresql.org/message-id/758d9f0.0202181102.77fbc9ea@posting.google.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ishapiro@cogitations.com
  Subject: Re: Casting pairs of floating point variables as a point in plpgsql
  In-Reply-To: <758d9f0.0202181102.77fbc9ea@posting.google.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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