Julian Legeny wrote:
> 
> Hello,
> 
>    Is  there  possibility  to  insert NEGATIVE numbers (less than
zero)
> into the
> column of SERIAL datatype?
> 
>    For example:
>    ------------
>    I have table:
> 
>    create table TEST
>    (
>       ID SERIAL,
>       NAME VARCHAR(100) NOT NULL,
>       CONSTRAINT TEST_PK PRIMARY KEY (ID)
>    )
> 
>    and I would like to insert column ID = -1, NAME = 'name1'
> 
>    insert into TEST (ID, NAME) values (-1, 'name1')
> 
>    but I receive error:
>    ---- Error -------------------------------
>    Auto Commit: On, SQL Mode: Internal, Isolation Level: Committed
>    General error;300 POS(1) Integrity violation
>    insert into TEST (ID, NAME) values (-1, 'name1')
>    ------------------------------------------
> 
>    How  can I use column to be auto incremented and also I can insert
> NEGATIVE
> INTEGER values into this column by myself? Positive numbers is
possible
> insert
> without problems.
> 

It is not possible with datatype / default serial.
Therefore real auto-increment will not be possible with negative values.
But you may create a sequence (increment by 1), create your table with
id fixed (10) and use the sequence-value in the insert

Insert into test (seq.nextval, 'name1').
In this table your insert with -1 would be possible, too.

Elke
SAP Labs Berlin


>   Thanks for answer,
>   best regards,
> 
>   Julian Legeny
> 
> mailto:[EMAIL PROTECTED]
> 
> 
> --
> MaxDB Discussion Mailing List
> For list archives: http://lists.mysql.com/maxdb
> To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]


--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to