Call anyone spot the difference in the newsessionid value in these two
examples ?
#1 :
create procedure MM_createSessionEntry
(
...
)
as declare
newsessionid bigint not null not default ;
begin
INSERT INTO my_table
(entryID,
...
)
VALUES
(entryidkey.nextval,
...;
newsessionid = entryidkey.currval;
return newsessionid;
#2 :
create procedure MM_createSessionEntry
(
...
)
as declare
newsessionid bigint not null not default ;
begin
newsessionid = entryidkey.nextval;
INSERT INTO my_table
(entryID,
...
)
VALUES
(newsessionid ,
...;
return newsessionid;
Ok, here's the spoiler -
In the first the newsessionid being called twice whereas in the second
it gets called once (the expected behaviour). It seems that if you use
a sequence directly as a parameter it gets stepped twice. Not using it
as a paramter directly solves the issue. Coming from a pure programming
background (ie. non-DB) I can't see why this is.
Morgan.
Betty & Karl Schendel - 22 Jul 2005 14:46 GMT
>Call anyone spot the difference in the newsessionid value in these
>two examples ?
[quoted text clipped - 5 lines]
>if you use a sequence directly as a parameter it gets stepped twice.
>Not using it as a paramter directly solves the issue.
I think I saw an R3 bug-fix for something like this very recently.
It wouldn't be in the current posted builds yet.
Karl