Skip to content
Advertisement

Oracle SQL3 3 nesting tables insert problem

I’m making an SQL3 script where I create types and then create tables and nested tables. The prolem I’m getting happens when I want to insert a row where it says :

ORA-00932: inconsistent datatypes: expected UDT got CHAR

this is an online reproduction of the problem where the types and tables are already created, you can try to insert: https://www.tutorialspoint.com/oracle_terminal_online.php?fbclid=IwAR0GgaLe2_GvGsEb80eB-D0uKDSDJDr1WNBPiK3mHQqpJQrtfacQ1cf03NA

the following is the types creation script

this one is the table creation script

and finally the script I’m using to insert my new rows

the error message I’m getting is

1 row created.

ERROR at line 10:

ORA-00932: inconsistent datatypes: expected UDT got CHAR

I’d be glad if anyone can guide me through this, thanks.

Advertisement

Answer

You are specifying a T_SET_Message collection but you then need T_Message objects within that; you’re supplying the attributes of that object type, not an actual object of the type. The first element in the (non-)collection is a string, hence the error you get – you’ve supplied a string ('Paris...') when it’s expecting to see a UDT (T_Message('Paris...', ...)).

You are also doing the same thing with the T_SET_Contact collection.

You need to wrap your current attributes in object constructors; so this works:

db<>fiddle

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement