问题描述
CREATE OR REPLACE Type t_Au_Delivery_Service As Object ( Yes_No Integer, Delivery_Price Number, Note Varchar2(1000) ); create table AU_AUCTION_PARAM ( id_au_auction_param NUMBER not null, id_au_auction NUMBER not null, id_au_param_lib NUMBER not null, au_param_value SYS.ANYDATA ); Declare d t_Au_Delivery_Service; Begin d:= t_Au_Delivery_Service(1,1,''); d.Yes_No := 1; d.Delivery_Price := 13.765; d.Note := 'any text'; Insert Into Au_Auction_Param (Id_Au_Auction, Id_Au_Param_Lib, Au_Param_Value) Values (1, 1, Sys.Anydata.Convertobject(d)); End; and this select get error ora-22636: select t.au_param_value from AU_AUCTION_PARAM t -- ??? how to select object from anydata field?复制
专家解答
将其转换为您将其存储为的类型:
虽然我不得不问:
你为什么要把这个存储在anydata中?
存储对象类型已经足够增加了这一层复杂性。你能让你的列的类型成为对象本身吗?
create or replace type t_au_delivery_service as object ( yes_no integer, delivery_price number, note varchar2( 1000 ) ); / create table au_auction_param ( id_au_auction_param number not null, id_au_auction number not null, id_au_param_lib number not null, au_param_value sys.anydata ); declare d t_au_delivery_service; begin d := t_au_delivery_service( 1,1,'' ); d.yes_no := 1; d.delivery_price := 13.765; d.note := 'any text'; insert into au_auction_param ( id_au_auction_param, id_au_auction,id_au_param_lib,au_param_value ) values ( 1, 1, 1, sys.anydata.convertobject( d ) ); end; / select cast(t.au_param_value as t_au_delivery_service) from au_auction_param t; T_AU_DELIVERY_SERVICE(1, 13.765, 'any text')复制
虽然我不得不问:
你为什么要把这个存储在anydata中?
存储对象类型已经足够增加了这一层复杂性。你能让你的列的类型成为对象本身吗?
drop table au_auction_param purge; create table au_auction_param ( id_au_auction_param number not null, id_au_auction number not null, id_au_param_lib number not null, au_param_value t_au_delivery_service ); declare d t_au_delivery_service; begin d := t_au_delivery_service( 1,1,'' ); d.yes_no := 1; d.delivery_price := 13.765; d.note := 'any text'; insert into au_auction_param ( id_au_auction_param, id_au_auction,id_au_param_lib,au_param_value ) values ( 1, 1, 1, d ); end; / select t.au_param_value from au_auction_param t; T_AU_DELIVERY_SERVICE(1, 13.765, 'any text')复制
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
Oracle DataGuard高可用性解决方案详解
孙莹
500次阅读
2025-03-26 23:27:33
Oracle RAC 一键安装翻车?手把手教你如何排错!
Lucifer三思而后行
479次阅读
2025-04-15 17:24:06
墨天轮个人数说知识点合集
JiekeXu
403次阅读
2025-04-01 15:56:03
XTTS跨版本迁移升级方案(11g to 19c RAC for Linux)
zwtian
395次阅读
2025-04-08 09:12:48
Oracle SQL 执行计划分析与优化指南
Digital Observer
370次阅读
2025-04-01 11:08:44
【纯干货】Oracle 19C RU 19.27 发布,如何快速升级和安装?
Lucifer三思而后行
357次阅读
2025-04-18 14:18:38
Oracle 19c RAC更换IP实战,运维必看!
szrsu
338次阅读
2025-04-08 23:57:08
oracle定时任务常用攻略
virvle
313次阅读
2025-03-25 16:05:19
3月“墨力原创作者计划”获奖名单公布
墨天轮编辑部
312次阅读
2025-04-15 14:48:05
风口浪尖!诚通证券扩容采购Oracle 793万...
Roger的数据库专栏
309次阅读
2025-03-24 09:42:53