pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Graham Vickrage <graham@digitalplanit.com>
To: pgsql-sql@postgresql.org
Subject: sequences in functions
Date: Fri, 18 Aug 2000 13:24:15 +0100
Message-ID: <NDBBJABDILOPAOOMFJHOMEPNCDAA.graham@digitalplanit.com> (raw)

I am having problems referencing sequeces in a function, I think because of
the '' characters. The function I am creating is a follows: -

CREATE FUNCTION InsertClient ( varchar, varchar, varchar, varchar, varchar,
varchar ) RETURNS int4 AS '
DECLARE
	id INT;
BEGIN
	SELECT nextval('client_seq') INTO id;

	INSERT INTO client (client_id, last_name, address1, country)
	VALUES (id, $1, $2, $3);

	INSERT INTO client_card (client_card_id, type, number, expiry_date,
client_id)
	VALUES (nextval('client_card_seq'), $4, $5, $6, id);

	RETURN id;
END;
' LANGUAGE 'plpgsql';


And the error message is

ERROR:  parser: parse error at or near "client_seq"
EOF


Is this because of the ' ' ???

Also can you pass in a array or hash to the function?

Cheers

Graham




view thread (3+ messages)  latest in thread

Message-ID: <NDBBJABDILOPAOOMFJHOMEPNCDAA.graham@digitalplanit.com>
Permalink:  ../NDBBJABDILOPAOOMFJHOMEPNCDAA.graham@digitalplanit.com/
Also on:    postgresql.org/message-id/NDBBJABDILOPAOOMFJHOMEPNCDAA.graham@digitalplanit.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: graham@digitalplanit.com
  Subject: Re: sequences in functions
  In-Reply-To: <NDBBJABDILOPAOOMFJHOMEPNCDAA.graham@digitalplanit.com>
  References: <NDBBJABDILOPAOOMFJHOMEPNCDAA.graham@digitalplanit.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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