Thank you for your answer.

but when i do the test

create table t (id numeric (38,0));
insert into t (id) values (203974809258041991228294191469794647457);

create table t1 (id decfloat (16));
insert into t1 (id) values (203974809258041991228294191469794647457);

t = kb
t1 = ok

I have to import type number from oracle and the above value is an example.

What do you advise me?

-----Message d'origine-----
De : Mark Rotteveel [mailto:m...@lawinegevaar.nl] 
Envoyé : lundi 16 décembre 2019 13:32
À : Norbert Saint Georges; For discussion among Firebird Developers
Objet : Re: [Firebird-devel] how to declare a decfloat (16) with a scale of 
zero for a column GENERATED BY DEFAULT AS IDENTITY

On 2019-12-16 09:43, Norbert Saint Georges wrote:
> Hello,
> 
> 
> can't an identity column be a decfloat (16)?
> 
>   RECREATE TABLE FIREBIRD_PARTS (
>               PART_ID DECFLOAT (16) GENERATED BY DEFAULT AS IDENTITY 
> not null
>             , PART_NAME varchar (255) not null
>             , BUY_PRICE decimal (9, 2)
> );
> 
> error: 336068881
> 
> description found in client-java:
> 
> Identity column {0} of table {1} must be of exact number type with zero 
> scale

You can't, a `DECFLOAT` is not a suitable datatype for this. An identity 
column has to be an exact number type with zero scale (== an integer 
type), and a `DECFLOAT` is a floating point type.

And if it were possible, using `DECFLOAT(16)` wouldn't make much sense: 
it has less digits than a BIGINT (16 vs 19), while it takes the same 
storage space.

The maximum value generated by the sequence backing an identity column 
is the maximum value of a `BIGINT`, so using a larger type than `BIGINT` 
has no real use, except taking more space. I'm not sure if it is 
possible to use `NUMERIC(38,0)` (which provides 38/39 digits), but given 
the restriction on the maximum value of a sequence to 2^63 - 1, using 
that type would also not make sense.

Mark

Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to