Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id B2ED34758DE for ; Thu, 21 Feb 2002 19:18:44 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g1M0IQS12047; Thu, 21 Feb 2002 19:18:26 -0500 (EST) To: ishapiro@cogitations.com (Irv Shapiro) Cc: pgsql-sql@postgresql.org Subject: Re: Casting pairs of floating point variables as a point in plpgsql In-reply-to: <758d9f0.0202181102.77fbc9ea@posting.google.com> References: <758d9f0.0202181102.77fbc9ea@posting.google.com> Comments: In-reply-to ishapiro@cogitations.com (Irv Shapiro) message dated "18 Feb 2002 11:02:10 -0800" Date: Thu, 21 Feb 2002 19:18:26 -0500 Message-ID: <12044.1014337106@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200202/296 X-Sequence-Number: 6719 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