简体   繁体   中英

Could %type be used with Object type? Is it possible because I am getting error while trying to do so

I am trying to use %type with object type

for eg,

Method 1:

  CREATE TYPE emp_object AS OBJECT(
    i_Emp_id Employee_table.emp_id%type,
    i_Emp_name  Employee_table.emp_name%type
    i_salary  Employee.salary%type);

But I am unable to create object type as in the method 1...

I am able to create object type by using method 2, but this has some functionality issue when I use it in my application as mentioned below..

Method 2:

 CREATE TYPE emp_object AS OBJECT( i_Emp_id number, i_Emp_name  varchar2(10), i_Salary Number(13,9));

The problem which i am facing with the second method is that, when ever I change the precision of the data type in Salary column in the table, I have to change drop the object type and recreate it. Also I have to change the code in the API and UI.. This could be surely avoided if I can use the %type while creating the object type. But I am unable to do so because Oracle throws error. Is there a way to apply %type for object type columns.. Please help me...I tried everything but I am facing this blocker for along time...

No, Oracle does not support %TYPE for object attributes - because %TYPE is PL/SQL syntax, not SQL.

Why not just declare i_salary as NUMBER with no precision and scale?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM