Create function errors

Поиск
Список
Период
Сортировка
От Peck, Brian
Тема Create function errors
Дата
Msg-id 18E2675C0D478E4494108B55120A61AF12707818@emss01m15.us.lmco.com
обсуждение исходный текст
Ответы Re: Create function errors  ("Rodrigo De León" <rdeleonp@gmail.com>)
Список 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/functions.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

 

В списке pgsql-general по дате отправления:

Предыдущее
От: "Andrus"
Дата:
Сообщение: Avoid huge perfomance loss on string concatenation
Следующее
От: Raymond O'Donnell
Дата:
Сообщение: Re: Vacuum output redirect