| From: | Michael Glaesemann <grzm(at)seespotcode(dot)net> |
|---|---|
| To: | "Hari Patel" <hariwise(at)gmail(dot)com> |
| Cc: | "Sean Davis" <sdavis2(at)mail(dot)nih(dot)gov>, pgsql-novice(at)postgresql(dot)org |
| Subject: | Re: Setting sequence ids after importing data |
| Date: | 2006-05-09 02:20:07 |
| Message-ID: | 4BF1F818-DD83-4F0E-9BFC-2152613566C9@seespotcode.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
On May 9, 2006, at 10:59 , Hari Patel wrote:
> CREATE function set_sequence_ids() RETURNS INTEGER AS '
> DECLARE
> arg INTEGER;
> BEGIN
> select into arg max(id) from foo;
> select setval('foo_id_seq', 10);
> return arg;
> END;
> ' LANGUAGE 'plpgsql';
>
> I get the following error in psql.
>
> psql:func.sql:9: ERROR: syntax error at or near "foo_id_seq" at
> charact
> er 152
> psql:func.sql:9: LINE 6: select setval('foo_id_seq', 10);
> psql:func.sql:9: ^
Try just
setval('foo_id_seq',10)
or
PEFORM setval('foo_id_seq', 10)
It's just a function call, and since you're not saving the return
value, you don't use SELECT. SELECT has different syntax in PL/pgSQL
than in SQL.
Hope this helps.
Michael Glaesemann
grzm seespotcode net
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2006-05-09 03:07:27 | Re: Setting sequence ids after importing data |
| Previous Message | Hari Patel | 2006-05-09 01:59:07 | Re: Setting sequence ids after importing data |