Unix Technical Forum

Create function errors

This is a discussion on Create function errors within the Pgsql General forums, part of the PostgreSQL category; --> Hey all, I'm trying to create functions for the calls I'm making to limit the number of DB pings ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 11:13 PM
Peck, Brian
 
Posts: n/a
Default Create function errors

Hey all,



I'm trying to create functions for the calls I'm making to limit the
number of DB pings I have to make (i.e. after they are all calls make
one call that calls them in succession) and I'm getting an error.



The function is



CREATE OR REPLACE FUNCTION nearestVertex(x1 double precision, y1 double
precision,road_network character varying) RETURNS integer AS

$$

DECLARE

result integer;



BEGIN

SELECT source_id as vertex INTO result FROM $3 ORDER BY
Distance(the_geom,PointFromText(POINT( $1 $2 ))) LIMIT 1;



RETURN result;

END;

$$

LANGUAGE plpgsql;



And the error I get is



psql:/LMCO/AFUO/trunk/ASDFS_ODBC_2007_08_16/Scripts/PostgreSQL/functio
ns.sql:12: ERROR: syntax error at or near "$1"

LINE 1: SELECT source_id as vertex FROM $1 ORDER BY Distance(the_g...

^

QUERY: SELECT source_id as vertex FROM $1 ORDER BY
Distance(the_geom,PointFromText(POINT( $2 $3 ))) LIMIT 1

CONTEXT: SQL statement in PL/PgSQL function "nearestvertex" near line 5



I'm having trouble troubleshooting it since it's query is not what
should be the query actually being performed.



- Brian Peck

- 858-795-1398

- Software Engineer

- Lockheed Martin




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 11:13 PM
=?UTF-8?Q?Rodrigo_De_Le=C3=B3n?=
 
Posts: n/a
Default Re: Create function errors

On Dec 4, 2007 6:04 PM, Peck, Brian <brian.peck@lmco.com> wrote:

> SELECT source_id as vertex INTO result FROM $3 ORDER BY
> Distance(the_geom,PointFromText(POINT( $1 $2 ))) LIMIT 1;


I think you're missing a comma, e.g. POINT( $1 , $2 ).

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:36 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com