U0100053: GaussDB does not support default values or NOT NULL for records in the package
Description
GaussDB does not support default values or NOT NULL for records in the package.
Database Type and Version
- Source database type and version: Oracle versions supported by UGO
- Target database type and version: GaussDB versions supported by UGO
Syntax Example
Oracle script:
CREATE OR REPLACE PACKAGE simple_record_pkg AS
TYPE person_rec IS RECORD (
id NUMBER := 0,
name VARCHAR2(100) := '无名氏',
age NUMBER := 18,
is_active BOOLEAN := TRUE
);
FUNCTION create_default_person(v_age person_rec) RETURN person_rec; -- The data type is RECORD, and a default value is used.
END simple_record_pkg;
/
CREATE OR REPLACE PACKAGE BODY simple_record_pkg AS
FUNCTION get_default_person RETURN person_rec ;
FUNCTION get_default_person RETURN person_rec IS
v_default person_rec;
BEGIN
RETURN v_default;
END;
FUNCTION create_default_person(v_age in person_rec ) RETURN person_rec IS
v_person person_rec := v_age;
BEGIN
DBMS_OUTPUT.PUT_LINE('===== 人员信息 =====');
DBMS_OUTPUT.PUT_LINE('ID: ' || v_person.id);
DBMS_OUTPUT.PUT_LINE('姓名: ' || v_person.name);
DBMS_OUTPUT.PUT_LINE('年龄: ' || v_person.age);
DBMS_OUTPUT.PUT_LINE('活跃: ' ||
CASE WHEN v_person.is_active THEN '是' ELSE '否' END);
RETURN v_person;
END;
END simple_record_pkg;
/
Suggestion
1. Comment out the record with default values in the package.
2. Assign a default value to the record.
Script compatible with GaussDB:
CREATE OR REPLACE PACKAGE simple_record_pkg AS
TYPE person_rec IS RECORD (
id NUMBER /* := 0*/,
name VARCHAR2(100) /*:= '无名氏'*/,
age NUMBER /* := 18*/,
is_active BOOLEAN /* := TRUE*/
);
FUNCTION create_default_person(v_age person_rec ) RETURN person_rec;
END simple_record_pkg;
/
CREATE OR REPLACE PACKAGE BODY simple_record_pkg AS
FUNCTION get_default_person RETURN person_rec ;
FUNCTION get_default_person RETURN person_rec IS
v_default person_rec;
BEGIN
RETURN v_default;
END;
FUNCTION create_default_person(v_age in person_rec ) RETURN person_rec IS
v_person person_rec := v_age;
BEGIN
----Assign a default value to the record.
v_person.id:=0;
v_person.name:='无名氏';
v_person.age:=18;
v_person.is_active:=TRUE;
DBE_OUTPUT.PRINT_LINE('===== 人员信息 =====');
DBE_OUTPUT.PRINT_LINE('ID: ' || v_person.id);
DBE_OUTPUT.PRINT_LINE('姓名: ' || v_person.name);
DBE_OUTPUT.PRINT_LINE('年龄: ' || v_person.age);
DBE_OUTPUT.PRINT_LINE('活跃: ' ||
CASE WHEN v_person.is_active THEN '是' ELSE '否' END);
RETURN v_person;
END;
END simple_record_pkg;
/
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot