hi  Walter

Try

INSERT INTO mytable(column2) VALUES (12345)

In other words, do not try to insert the column you want to be
auto-generated. The database engine will notice that you are inserting
only a subset of the columns, and SHOULD use the default values for
the missing columns, which would be NULL unless you specified
otherwise. In the case of column1 you have specified that the default
value  would be the auto-incremented value. If your table has a
column3 then you should find that is set to NULL by my suggested
syntax.

I do not have v3 running currently so cannot test it myself, so please
report back for the benefit of myself and everyone else whether that
works for you or not.

I am also interested to know if you find my syntax works on v2.5, if
you still have it installed to test it? Please don't go to the trouble
of re-installing it just to test it.

It is arguable that v3 is correct in rejecting the syntax you have
previously used, because it does not make logical sense to tell the
database engine to insert a null when you mean something else. The
syntax I suggested will be more portable to other db engines because
it is closer to the standard.

I hope that suggestion proves helpful
Warmly
River~~

On 19/11/2020, 'Walter R. Ojeda Valiente'
sistemas2000profesio...@gmail.com [firebird-support]
<firebird-support@yahoogroups.com> wrote:
> Hello everybody
>
> A long, long time without writing neither reading this group, mostly
> because all that I need about Firebird I knew.
>
> But now, I have a doubt.
>
> With Firebird 2.5.x I can have an auto-incremental column and use it in an
> UPDATE OR INSERT, but such thing is not possible with Firebird 3.
>
> With Firebird 2.5.x a generator and a trigger are created and the value of
> the column is put automatically. So, if I write:
> UPDATE OR INSERT INTO MyTable (MyColumn1, MyColumn2) VALUES (NULL, 12345);
>
> and MyColumn1 is auto-incremental its value is set for the Firebird engine.
>
> but...if I use the new IDENTITY type in Firebird 3 I always have an error,
> writing MyColumn1 in the UPDATE OR INSERT or not writing.
>
> So, my question is:
>
> Is it possible to use UPDATE OR INSERT with an IDENTITY column?
>
> Thanks in advance.
>
> Greetings.
>
> Walter.
>


-- 
9831*2^1441403+1 is prime, >400k digits
  • ... 'Walter R. Ojeda Valiente' sistemas2000profesio...@gmail.com [firebird-support]
    • ... 'Walter R. Ojeda Valiente' sistemas2000profesio...@gmail.com [firebird-support]
      • ... 'Walter R. Ojeda Valiente' sistemas2000profesio...@gmail.com [firebird-support]
        • ... Herman Viaene herman.via...@edpnet.be [firebird-support]
          • ... 'Walter R. Ojeda Valiente' sistemas2000profesio...@gmail.com [firebird-support]
            • ... Daniel Miller dmil...@amfes.com [firebird-support]
              • ... 'Walter R. Ojeda Valiente' sistemas2000profesio...@gmail.com [firebird-support]
    • ... 'River~~' river14ap...@gmail.com [firebird-support]
      • ... Mark Rotteveel m...@lawinegevaar.nl [firebird-support]
      • ... 'Walter R. Ojeda Valiente' sistemas2000profesio...@gmail.com [firebird-support]

Reply via email to