Обсуждение: ERROR: parser: parse error at or near "execute"

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

ERROR: parser: parse error at or near "execute"

От
pgsql-bugs@postgresql.org
Дата:
Christian Villa Real Lopes (chris_br@email.com) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
ERROR:  parser: parse error at or near "execute"

Long Description
I created a function to drop a table if it exists. On pgsql-7.0.3 this function returns an error, as follow :

template1=# SELECT func_drop_table('friend');
ERROR:  parser: parse error at or near "execute"

On pgsql-7.1.2 this function works fine and no error returns just the following lines :

func_drop_table
---------------
 friend


Sample Code
CREATE TABLE friend (
             firstname CHAR(15),
             lastname  CHAR(20),
             city      CHAR(15),
             state     CHAR(2),
             age       INTEGER
);

CREATE FUNCTION "func_drop_table"(TEXT)
RETURNS TEXT AS '
DECLARE
   v_reg RECORD;
   v_tab TEXT;
BEGIN
   FOR v_reg IN SELECT * FROM pg_tables WHERE tablename LIKE $1 LOOP
      v_tab := ''DROP TABLE '' || v_reg.tablename || '';'';
      EXECUTE v_tab;
   END LOOP;
   RETURN $1;
END;' LANGUAGE 'plpgsql';

SELECT func_drop_table('friend');


No file was uploaded with this report

Re: ERROR: parser: parse error at or near "execute"

От
Stephan Szabo
Дата:
On Tue, 31 Jul 2001 pgsql-bugs@postgresql.org wrote:

> Christian Villa Real Lopes (chris_br@email.com) reports a bug with a severity of 3
> The lower the number the more severe it is.
>
> Short Description
> ERROR:  parser: parse error at or near "execute"
>
> Long Description I created a function to drop a table if it exists. On
> pgsql-7.0.3 this function returns an error, as follow :
>
> template1=# SELECT func_drop_table('friend');
> ERROR:  parser: parse error at or near "execute"
>
> On pgsql-7.1.2 this function works fine and no error returns just the following lines :

IIRC, execute was added in 7.1.