Re: Trying to write a function... - Mailing list pgsql-sql

From Josh Berkus
Subject Re: Trying to write a function...
Date
Msg-id 200207241126.27263.josh@agliodbs.com
Whole thread Raw
In response to Trying to write a function...  (Wim <wdh@belbone.be>)
List 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 BerkusAglio Database SolutionsSan Francisco



pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Problem with my query whithout double-quotes
Next
From: marc sturm
Date:
Subject: convert a bigint into a timestamp