1

Topic: nullif and repeated expr1 - a bug?

create sequence gen$test;
alter sequence gen$test restart with 0;
select nullif (gen_id (gen$test, 1), 0) from rdb$database

If to fulfill this request - that increment always will be 2.  there is a repeated calculation expr1 that from the description does not follow. A bug?

2

Re: nullif and repeated expr1 - a bug?

AnyUser;
No. It is a singularity of operation with expressions
Expressions not  and are calculated anew at each usage

nullif (gen_id (gen$test, 1), 0) = case when gen_id (gen$test, 1) =0 then null else gen_id (gen$test, 1) end

3

Re: nullif and repeated expr1 - a bug?

AnyUser> the Bug?
No, not a bug. I precisely remember that described it somewhere.
In , most likely.

4

Re: nullif and repeated expr1 - a bug?

P.S. At what it concerns not only generators;
And the increment at all always will be 2. Behind prescription
Years I any more will not recall, but 3 - was exact; can, and 4 too.

5

Re: nullif and repeated expr1 - a bug?

Probably, here it would be better to get a temporal invisible variable before transmission in case
Otherwise really kontr-intuitively it turns out.
Let not a bug, but quite to itself a rake, "gotcha"
On the other hand, nullif same for compatibility entered, it seems still Oleg Loa, with any other server, most likely MS SQL
It is necessary to check up, how in it it fulfills.

6

Re: nullif and repeated expr1 - a bug?

Oracle and NULLIF - reefs

7

Re: nullif and repeated expr1 - a bug?

AnyUser;
By the way what for it

nullif (gen_id (gen$test, 1), 0)

You there that in-1 drop generators? A trick in itself

8

Re: nullif and repeated expr1 - a bug?

It concerned not only nullif, AFAIR.

9

Re: nullif and repeated expr1 - a bug?

Denis wrote:

you there that in-1 drop generators? A trick in itself

No, it is a synthetic example. Function with similar behavior (if not this "the thin moment") was simply necessary.

10

Re: nullif and repeated expr1 - a bug?

Argument...
There, , the good thing is mentioned, a cache of results of expressions
[quote =] if you specify as the first argument heavy (and not declared as DETERMINISTIC) function