sequences in functions - Mailing list pgsql-sql

From Graham Vickrage
Subject sequences in functions
Date
Msg-id NDBBJABDILOPAOOMFJHOMEPNCDAA.graham@digitalplanit.com
Whole thread Raw
Responses Re: sequences in functions
List pgsql-sql
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 '
DECLAREid INT;
BEGINSELECT 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



pgsql-sql by date:

Previous
From: Joerg Hessdoerfer
Date:
Subject: Re: Continuous inserts...
Next
From: Yury Don
Date:
Subject: Re: sequences in functions