functions with plpgsql - Mailing list pgsql-php

From Bernd Hoffmann
Subject functions with plpgsql
Date
Msg-id 01b101c35eb3$6e75b2b0$3214a8c0@server
Whole thread Raw
Responses Re: functions with plpgsql
List pgsql-php
Hi,

I have some problems by using functions with plpgsql.

For example:

tbl:

CREATE TABLE "logs" (
   "id" int4 DEFAULT nextval('"logs_id_seq"'::text) NOT NULL,
   "session" varchar NOT NULL,
   "addr" inet NOT NULL,
   "host" varchar NOT NULL,
   "agent" varchar NOT NULL,
   "datum" timestamptz DEFAULT now(),
   "referer" varchar,
   CONSTRAINT "logs_pkey" PRIMARY KEY ("id")
);

function:

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?

MfG

Bernd Hoffmann


unixserver.info
96123 Litzendorf
Tel: +499505/8050485
Fax: +499505/8050486
info@unixserver.info


pgsql-php by date:

Previous
From: "David Busby"
Date:
Subject: Re: Paging results
Next
From: "Andrew J. Kopciuch"
Date:
Subject: Re: functions with plpgsql