0

I get the following error when inserting the following values:

ERROR at line 1: ORA-01438: value larger than specified precision allowed for this column

    insert into comands values(
        '11111111A',
        '05MAY21',
        col_products(
                t_products(
                        'Rice with chicken',
                        1000,
                        (select ref(inf) from infoNutri inf where inf.num_calories=1000)
                    )
            )
    );
    
    create or replace type t_comandas is object(
        id varchar2(9),
        date date,
        products col_products 
    );
    /
create or replace type t_products as object(
    name varchar2(20),
    price number(4,2),
    info_nutritional ref t_infoNutritional
)
  • 1
    How is `t_products` defined? (`'05MAY21'` is a string not a date, so you are relying on implicit conversion for that, but it is a side issue.) – Alex Poole May 28 '21 at 20:19
  • 1
    @AlexPoole Hello again! I just added t_products. – noobieCoder May 28 '21 at 20:22
  • 1
    Well, 1000 [exceeds the precision](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Data-Types.html#GUID-75209AF6-476D-4C44-A5DC-5FA70D701B78) of `number(4,2)`... look at the examples in the documentation. – Alex Poole May 28 '21 at 20:30
  • 1
    @AlexPoole I thought Oracle uses the same precision as float in SQL, but it seems I am wrong. Anyway, thanks again and I'll try to stop asking pointless questions here :) – noobieCoder May 28 '21 at 20:36

0 Answers0