[英]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我正在尝试将 %type 与 object 类型一起使用
for eg,例如,
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...但是我无法像方法 1 中那样创建 object 类型...
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..我可以使用方法 2 创建 object 类型,但是当我在我的应用程序中使用它时会出现一些功能问题,如下所述。
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.我使用第二种方法面临的问题是,每当我更改表中 Salary 列中数据类型的精度时,我都必须更改删除 object 类型并重新创建它。 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.此外,我还必须更改 API 和 UI 中的代码。如果我可以在创建 object 类型时使用 %type,则肯定可以避免这种情况。 But I am unable to do so because Oracle throws error.但我无法这样做,因为 Oracle 会抛出错误。 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...有没有办法将 %type 应用于 object 类型列。请帮助我......我尝试了一切,但我一直面临着这个障碍......
No, Oracle does not support %TYPE for object attributes - because %TYPE is PL/SQL syntax, not SQL.不,Oracle 不支持 object 属性的 %TYPE - 因为 %TYPE 是 PL/SQL 语法,而不是 SQL。
Why not just declare i_salary as NUMBER with no precision and scale?为什么不直接将 i_salary 声明为没有精度和比例的 NUMBER?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.