pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: Trying to write a function...
2+ messages / 2 participants
[nested] [flat]

* Re: Trying to write a function...
@ 2002-07-24 18:26  Josh Berkus <josh@agliodbs.com>
  parent: Wim <wdh@belbone.be>
  0 siblings, 0 replies; 2+ messages in thread

From: Josh Berkus @ 2002-07-24 18:26 UTC (permalink / raw)
  To: Wim <wdh@belbone.be>; 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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Trying to write a function...
@ 2002-07-24 19:10  Wim <wdh@belbone.be>
  0 siblings, 1 reply; 2+ messages in thread

From: Wim @ 2002-07-24 19:10 UTC (permalink / raw)
  To: pgsql-sql

Hello,

I'm trying to write a function that add new rows to a table, but I don't 
succeed.....
It's something like this:

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?


Cheers!

Wim.




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2002-07-24 19:10 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-07-24 19:10 Trying to write a function... Wim <wdh@belbone.be>
2002-07-24 18:26 ` Josh Berkus <josh@agliodbs.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox