pl/pgsql frustration

Поиск
Список
Период
Сортировка
От John Wells
Тема pl/pgsql frustration
Дата
Msg-id 1123989565.21366.10.camel@localhost.localdomain
обсуждение исходный текст
Ответы Re: pl/pgsql frustration  (John Wells <jb@sourceillustrated.com>)
Re: pl/pgsql frustration  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-general
Guys,

I'm trying to write a simple function that will return a table's actual
row count on PostgreSQL 7.4.  I've tried two different versions (see
below), both with the same result:

"ERROR:  syntax error at or near "select" at character 127"

I've also tried a cursor example found in the interactive 7.4 docs and
get a similar 'select' error.  Am I missing something here or is
something else going on?  Thanks for any help you can provide.

John
----
create or replace function count_rows (text) returns integer as '
declare
  return_val int4;
  curs1 refcursor;
  table_name ALIAS FOR $1;
begin
    OPEN curs1 FOR EXECUTE 'select * from ' || quote_indent(table_name);

    fetch curs1 into return_val;
    close curs1;
end;
' language 'plpgsql';

create or replace function count_rows (text) returns integer as '
declare
  return_val int4;
  curs1 cursor FOR EXECUTE 'select count(*) from ' ||
quote_indent(table_name);
  table_name ALIAS FOR $1;
begin
    OPEN curs1;
    fetch curs1 into return_val;
    close curs1;
end;
' language 'plpgsql';


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

Предыдущее
От: "Andrew J. Kopciuch"
Дата:
Сообщение: Re: Removing tsearch2 from a database
Следующее
От: John Wells
Дата:
Сообщение: Re: pl/pgsql frustration