Re: Please help me to take a look of the erros in my functions. Thanks.

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: Please help me to take a look of the erros in my functions. Thanks.
Дата
Msg-id F68F09AA-FDEB-4A24-B444-21189FD2D826@gmail.com
обсуждение исходный текст
Ответ на Please help me to take a look of the erros in my functions. Thanks.  (leaf_yxj <leaf_yxj@163.com>)
Ответы Re: Please help me to take a look of the erros in my functions. Thanks.
Список pgsql-general
On 2 Apr 2012, at 22:02, leaf_yxj wrote:

> CREATE OR REPLACE FUNCTION truncate_t(tablename IN VARCHAR) RETURNS void AS
> $$
> DECLARE
>     stmt RECORD;
>     statements CURSOR FOR SELECT tablename FROM pg_catalog.pg_tables;
> BEGIN
>     IF stmt IN statements then
>         EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || '

I think you meant to use a FOR LOOP there, not IF. IF does not know to fetch a record from a CURSOR (hmm... should it
perhaps?).

http://www.postgresql.org/docs/9.1/interactive/plpgsql-cursors.html#PLPGSQL-CURSOR-FOR-LOOP

> CASCADE;';
> ELSE
>     The tablename doesn't exist.doesn
>     END IF ;
> END;
> $$ LANGUAGE 'plpgsql' security definer;

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.


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

Предыдущее
От: Alban Hertroys
Дата:
Сообщение: Re: Please help me to take a look of the erros in my functions. Thanks.
Следующее
От: Greg Smith
Дата:
Сообщение: Re: Why checkpoint_timeout had maximum value of 1h?