Re: temp sequence

From: Adrian Klaver <aklaver(at)comcast(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: Sim Zacks <sim(at)compulab(dot)co(dot)il>
Subject: Re: temp sequence
Date: 2008-02-03 15:34:38
Message-ID: 200802030734.38305.aklaver@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Saturday 02 February 2008 10:39 pm, Sim Zacks wrote:
> "PostgreSQL 8.2.4 on i386-pc-linux-gnu, compiled by GCC
> i386-pc-linux-gnu-gcc (GCC) 4.1.1 (Gentoo 4.1.1)"
>
> I am creating a temporary sequence in a function and it seems like it is
> not going away after the function finishes.
> The front end is in MS Access 2000 and I have a single connection. When I
> call the function once it works, when I call it a second time, it gives me
> an error that the sequence already exists. When I restart the application,
> I can call the function again.
>
> I solved the problem by using: alter sequence seq_linenum restart with 1;
>
> The manual states:
> If specified, the sequence object is created only for this session, and is
> automatically dropped on session exit. Existing permanent sequences with
> the same name are not visible (in this session) while the temporary
> sequence exists, unless they are referenced with schema-qualified names.
>
> I thought that a function would be considered its own session, is that
> incorrect?

The connection is the session. The function is the transaction. If you are
going to maintain the connection you will need to drop the sequence inside
the function after using it.

>
> Thank you
> Sim
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

--
Adrian Klaver
aklaver(at)comcast(dot)net

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Enrico Sirola 2008-02-03 16:35:35 Re: arrays of floating point numbers / linear algebra operations into the DB
Previous Message Guido Barosio 2008-02-03 15:02:44 Re: PostgreSQL Certification