Search Postgresql Archives

Re: Best approach for a "gap-less" sequence

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/16/06, Dawid Kuroczko <qnex42@xxxxxxxxx> wrote:
-- then create a function to retrieve the values:
CREATE FUNCTION gseq_nextval(t text) RETURNS integer AS $$
    DECLARE
       n integer;
    BEGIN
       SELECT INTO n gseq_value+1 FROM gapless_seq WHERE gseq_name = t
FOR UPDATE;
       UPDATE gapless_seq SET gapless_value = n WHERE gseq_name = t;
       RETURN n;
    END;
$$ STABLE LANGUAGE PLpgsql;
      ^^^^^^^^^^^
VOLATILE of course!


Regards,
  Dawid


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux