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

My first PL/pgSQL function

From: Didier Gasser-Morlay <didiergm(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org, thomas(dot)granvej6(at)gmail(dot)com
Subject: My first PL/pgSQL function
Date: 2009-11-18 16:45:04
Message-ID: 608b66ce0911180845o72bdddccj8b2b9d10c99c4baa@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
I am by no means an expert in PL/SQL but your function seems ok to me;

your currcal is fine (if you used nextval as someone suggested, you'd get
the next value, which is not what you intend, creating user<->groups links.

That said, I ddo not know if doing and insert then asking for curval is
atomic or if you could get a wrong value if someone else creates a user at
theat moment;

To be on the safe side, I always use insert ... returning syntax  this way I
know that I am getting the same value as the one inserted.

Just my 0.02EUR

Didier

pgsql-novice by date

Next:From: Mladen GogalaDate: 2009-11-18 20:22:54
Subject: Introduction
Previous:From: A. KretschmerDate: 2009-11-18 16:18:48
Subject: Re: My second PL/pgSQL function - minor problem

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