Обсуждение: Syntax error, but where?

Поиск
Список
Период
Сортировка

Syntax error, but where?

От
Michael Trausch
Дата:
Hey guys,

I'm having a slight problem with this database that I'm trying to setup
on PostgreSQL 8.1.3... What I've got is a stored procedure that refuses
to get itself into the system, and I'm not sure why.  It is throwing a
syntax error on DECLARE, but I don't see it.  I looked at the
documentation, and as far as I can tell, my CREATE FUNCTION line looks
just as it should in structure, as does the CREATE TYPE line that is
immediately before it.

Any ideas?

The code that is failing is:

================

CREATE TYPE app_global.city_list AS (zip_code CHAR(5), city_name
VARCHAR(40), state_abbr CHAR(2), distance_miles NUMERIC(6,3));

--
-- Stored Procedures in app_global
--

CREATE FUNCTION app_global.get_zip_codes_range(zip_code CHAR(5),
range_miles NUMERIC(4,1)) RETURNS SETOF city_list AS $$FUNC_BODY$$
DECLARE
  generic_cursor REFCURSOR;
  record_returned RECORD;
  record_to_return city_list%rowtype;

================

Any help would be greatly appreciated!

    Thanks,
    Mike

Re: Syntax error, but where?

От
Bricklen Anderson
Дата:
Michael Trausch wrote:
> Hey guys,
>
> I'm having a slight problem with this database that I'm trying to setup
> on PostgreSQL 8.1.3... What I've got is a stored procedure that refuses
> to get itself into the system, and I'm not sure why.  It is throwing a
> syntax error on DECLARE, but I don't see it.  I looked at the
> documentation, and as far as I can tell, my CREATE FUNCTION line looks
> just as it should in structure, as does the CREATE TYPE line that is
> immediately before it.
>
> Any ideas?
>
> The code that is failing is:
>
> ================
>
> CREATE TYPE app_global.city_list AS (zip_code CHAR(5), city_name
> VARCHAR(40), state_abbr CHAR(2), distance_miles NUMERIC(6,3));
>
> --
> -- Stored Procedures in app_global
> --
>
> CREATE FUNCTION app_global.get_zip_codes_range(zip_code CHAR(5),
> range_miles NUMERIC(4,1)) RETURNS SETOF city_list AS $$FUNC_BODY$$

Is this actually part of the function: $$FUNC_BODY$$ ?
If so, try it as $FUNC_BODY$ (single dollar signs around identifier).

Re: Syntax error, but where?

От
Michael Trausch
Дата:
Bricklen Anderson wrote:
>
> Is this actually part of the function: $$FUNC_BODY$$ ?
> If so, try it as $FUNC_BODY$ (single dollar signs around identifier).
>

Oh, jeez.  What an oversight.  Thank you... I can't believe that I
missed that.  Sometimes, all that really is needed is a fresh pair of
eyes.  Thanks!

    - Mike