Re: functions with plpgsql

Поиск
Список
Период
Сортировка
От Andrew J. Kopciuch
Тема Re: functions with plpgsql
Дата
Msg-id 200308091804.10545.akopciuch@olympusproject.org
обсуждение исходный текст
Ответ на functions with plpgsql  ("Bernd Hoffmann" <info@unixserver.info>)
Список pgsql-php
> CREATE FUNCTION "next_id"(character varying) RETURNS integer AS '
> DECLARE
>     tabelle ALIAS FOR $1;
> BEGIN
>     SELECT MAX(id)+1 FROM tabelle;
> END;
> ' LANGUAGE 'plpgsql'
>
> query:
>
> SELECT next_id(logs);
>
> error:
>
> PostgreSQL meldet: ERROR: parser: parse error at or near "$1"
>
> Can anybody help me?


I do not think you can evaluate a declared vairable as a table name in the
SELECT statement.

I don't think you really need to do this though.  If you have the table name
already.

why go:

SELECT next_id(logs);

And write this functios instead of:

SELECT MAX(id) + 1 FROM logs;


??


Andy

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

Предыдущее
От: "Bernd Hoffmann"
Дата:
Сообщение: functions with plpgsql
Следующее
От: "Bernd Hoffmann"
Дата:
Сообщение: Re: functions with plpgsql