My first PL/pgSQL function
My first PL/pgSQL function
От:
Didier Gasser-Morlay <didiergm@gmail.com>
Дата:
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
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