pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Yury Don <yura@vpcit.ru>
To: pgsql-sql@postgresql.org
Subject: Re: sequences in functions
Date: Fri, 18 Aug 2000 20:07:11 +0600
Message-ID: <638911580.20000818200711@vpcit.ru> (raw)
In-Reply-To: <NDBBJABDILOPAOOMFJHOMEPNCDAA.graham@digitalplanit.com>
References: <NDBBJABDILOPAOOMFJHOMEPNCDAA.graham@digitalplanit.com>

Hello Graham,

Friday, August 18, 2000, 6:24:15 PM, you wrote:

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

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

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

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

GV>         RETURN id;
GV> END;
GV> ' LANGUAGE 'plpgsql';


GV> And the error message is

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


GV> Is this because of the ' ' ???

You must to use two quotes:

SELECT nextval(''client_seq'') INTO id;

-- 
Best regards,
 Yury                            mailto:yura@vpcit.ru





view thread (3+ messages)  latest in thread

Message-ID: <638911580.20000818200711@vpcit.ru>
Permalink:  ../638911580.20000818200711@vpcit.ru/
Also on:    postgresql.org/message-id/638911580.20000818200711@vpcit.ru

 · 

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: yura@vpcit.ru
  Subject: Re: sequences in functions
  In-Reply-To: <638911580.20000818200711@vpcit.ru>
  References: <NDBBJABDILOPAOOMFJHOMEPNCDAA.graham@digitalplanit.com> <638911580.20000818200711@vpcit.ru>

* 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