如何更新oracle数据库中的subtype属性值?
How to update subtype attribute values in oracle database?
如何更新子类型的列值?
这样的代码无法访问学生的成绩属性:
update persons set grade = 'graduated';
CREATE OR REPLACE TYPE person (
name varchar2(20),
age number,
address varchar2(20)
) NOT FINAL;
CREATE OR REPLACE TYPE student UNDER person (
grade varchar2(20)
) NOT FINAL;
CREATE TABLE persons OF person;
INSERT INTO persons VALUES (student('Jon', 'undergraduate'));
如何将学生成绩更改为 'graduated'?
应该可行
update persons s set VALUE(s) = student(treat(value(s) as student).name, 'graduated');
我找到了问题的答案。
这是更新子类型属性的代码:
DECLARE
s student;
BEGIN
select treat(value(p) as student) into s from persons p where name = 'Jon';
s.grade = 'graduated';
update persons p set value(p) = s where name = 'Jon';
END;
如何更新子类型的列值?
这样的代码无法访问学生的成绩属性:
update persons set grade = 'graduated';
CREATE OR REPLACE TYPE person (
name varchar2(20),
age number,
address varchar2(20)
) NOT FINAL;
CREATE OR REPLACE TYPE student UNDER person (
grade varchar2(20)
) NOT FINAL;
CREATE TABLE persons OF person;
INSERT INTO persons VALUES (student('Jon', 'undergraduate'));
如何将学生成绩更改为 'graduated'?
应该可行
update persons s set VALUE(s) = student(treat(value(s) as student).name, 'graduated');
我找到了问题的答案。
这是更新子类型属性的代码:
DECLARE
s student;
BEGIN
select treat(value(p) as student) into s from persons p where name = 'Jon';
s.grade = 'graduated';
update persons p set value(p) = s where name = 'Jon';
END;