【发布时间】:2020-01-23 21:08:06
【问题描述】:
如何演变用户定义的构造函数签名?
给定一个具有表依赖项的 Oracle PL/SQL 用户定义类型,而不是用创建/替换语句替换它们,我需要改进这些类型。我通过 alter 语句找到了Oracle documentation on how to drop/add attributes, and drop/add member functions,但我没有看到有关如何演化构造函数签名的信息。我需要在不创建新表/类型并将数据迁移到新的更新类型的情况下执行此操作。就我而言,使用 FORCE 也不起作用。
例如,给定以下类型,我如何更新用户定义的构造函数签名以包含在初始化期间使用的新参数?
-- Create new type
CREATE OR REPLACE TYPE test_type AS OBJECT (
test_attribute NUMBER(1, 0),
CONSTRUCTOR FUNCTION test_type(
p_test_attribute NUMBER DEFAULT NULL
)
RETURN SELF AS RESULT
);
-- Make this new type have table dependents
CREATE OR REPLACE TYPE test_type_table
AS TABLE OF test_type;
CREATE TYPE test_child_obj AS OBJECT (
test_type_field test_type_table
);
-- Add new attribute via alter statement
ALTER TYPE test_type
ADD ATTRIBUTE (new_attribute NUMBER)
CASCADE NOT INCLUDING TABLE DATA;
我想将构造函数签名更新为以下内容:
CONSTRUCTOR FUNCTION test_type(
p_test_attribute NUMBER DEFAULT NULL,
p_new_attribute NUMBER DEFAULT NULL
)
RETURN SELF AS RESULT
我希望会有如下所示的 alter 语句,但我找不到合适的 alter 语句。请帮忙。
ALTER TYPE test_type
ADD CONSTRUCTOR FUNCTION test_type(
p_test_attribute NUMBER DEFAULT NULL,
p_new_attribute NUMBER DEFAULT NULL
)
RETURN SELF AS RESULT
CASCADE NOT INCLUDING TABLE DATA;
【问题讨论】:
标签: oracle plsql constructor alter