简体   繁体   English

%type 可以与 Object 类型一起使用吗? 是否有可能因为我在尝试这样做时遇到错误

[英]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,例如,

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...但是我无法像方法 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 类型,但是当我在我的应用程序中使用它时会出现一些功能问题,如下所述。

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.我使用第二种方法面临的问题是,每当我更改表中 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.

相关问题 嗨,我正在尝试通过从用户获取值来创建列表,我使用了类型为object的pl SQL表。 但是插入时出现错误 - Hi, I'm trying to create a list by getting values from the user, I have used pl SQL table of type object. but I'm getting errors while inserting 我正在尝试在 ORACLE 数据库中设置一个表,当我尝试运行此命令时出现无效数据类型错误: - I am trying to set up a table in an ORACLE database and am getting an invalid data type error when I try to run this command: 在 Oracle 中,如何验证对象类型层次结构中使用的对象类型? - In Oracle, how do I verify the object type used from an object type hierarchy? 我正在尝试更改 object 关系 model 中的类型以向其添加成员 function,但它一直给我错误 - I am trying to alter a type in object relational model to add a member function to it, but it keeps giving me errors 为什么在尝试插入数据时出现此错误ORA-00904“ PBIRTHDATE” - Why am I getting this error while trying to insert data ORA-00904 “PBIRTHDATE” 尝试在Oracle中保存图片时为什么出现ORA-00936错误? - Why am I getting ORA-00936 error while trying to save picture in Oracle? 当我尝试向表中插入哪种Blob数据类型时,出现错误 - When i try to insert into the table which blob data type I am getting an error 当我尝试从JSP建立与DB的连接时,出现错误“ TNS:无法解析指定的连接标识符” - When i am trying to establish the connection to DB from JSP getting the error “TNS:could not resolve the connect identifier specified” 尝试在 Oracle 中创建表类型时出现错误 PLS-00201 - Error PLS-00201 while trying to create table type in Oracle 尝试在 PL/SQL 中执行函数,但出现错误 - Trying to execute function in PL/SQL but I am getting error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM