Skip site navigation (1) Skip section navigation (2)

Re: sequences in functions

From: Yury Don <yura(at)vpcit(dot)ru>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: sequences in functions
Date: 2000-08-18 14:07:11
Message-ID: 638911580.20000818200711@vpcit.ru (view raw or flat)
Thread:
Lists: pgsql-sql
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(at)vpcit(dot)ru



In response to

Responses

pgsql-sql by date

Next:From: Poul L. ChristiansenDate: 2000-08-18 15:01:36
Subject: update rule loops
Previous:From: Thomas LockhartDate: 2000-08-18 13:44:34
Subject: Re: [HACKERS] [Fwd: Optimization in C]

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group