Re: Trying to write a function...

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Wim <wdh(at)belbone(dot)be>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Trying to write a function...
Date: 2002-07-24 18:26:27
Message-ID: 200207241126.27263.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Wim,

> CREATE FUNCTION f_addrtr (varchar(16),varchar(32)) RETURNS bool AS '
> DECLARE
> index int4;
> BEGIN
> index := 'nextval('s_routerid')';
> INSERT INTO t_routers VALUES (index, $1, $2);
> RETURN 1;
> END;'
> LANGUAGE 'plpgsql';
>
> What am I doing wrong?

Bad quotes, bad data type usage. Change as follows:

CREATE FUNCTION f_addrtr (varchar(16),varchar(32)) RETURNS bool AS '
DECLARE
index int4;
BEGIN
index := nextval(''s_routerid'');
INSERT INTO t_routers VALUES (index, $1, $2);
RETURN TRUE;
END;'
LANGUAGE 'plpgsql';

--
-Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Wim 2002-07-24 19:10:41 Trying to write a function...
Previous Message Stephan Szabo 2002-07-24 18:24:12 Re: Problem with my query whithout double-quotes