Create function errors

From: "Peck, Brian" <brian(dot)peck(at)lmco(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Create function errors
Date: 2007-12-04 23:04:41
Message-ID: 18E2675C0D478E4494108B55120A61AF12707818@emss01m15.us.lmco.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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:D:/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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2007-12-04 23:35:57 Re: Vacuum output redirect
Previous Message Joshua D. Drake 2007-12-04 22:52:20 Re: [GENERAL] PostgreSQL Beta4 released