https://pastein.ru/t/-I

  скопируйте уникальную ссылку для отправки


CREATE TYPE my_current_animal_type AS OBJECT (
    my_current_animal_name VARCHAR(100),
    my_current_gender VARCHAR(255),
    MEMBER FUNCTION get_info RETURN VARCHAR
);


CREATE TYPE BODY my_current_animal_type IS
MEMBER FUNCTION get_info RETURN VARCHAR IS
BEGIN
RETURN my_current_animal_name || ' ' || my_current_gender;
END;
END;

create table my_current_table_with_animals of my_current_animal_type;

INSERT INTO my_current_table_with_animals VALUES
(new my_current_animal_type('Tiger', 'Male'));

INSERT INTO my_current_table_with_animals VALUES
(new my_current_animal_type('Lion', 'Female'));

INSERT INTO my_current_table_with_animals VALUES
(new my_current_animal_type('Bird', 'Male'));

INSERT INTO my_current_table_with_animals VALUES
(new my_current_animal_type('Elephant', 'Male'));

INSERT INTO my_current_table_with_animals VALUES
(new my_current_animal_type('Hedgehog', 'Male'));

SELECT * FROM my_current_table_with_animals a1;

CREATE TABLE my_current_table_pets (
  id integer primary key,
  name varchar(100)
);

DESCRIBE my_current_table_pets;

--TRUNCATE TABLE bank;
insert into my_current_table_pets
  VALUES
(1, 'cat');
insert into my_current_table_pets
  VALUES (2,'dog');
insert into my_current_table_pets
  VALUES (3,'Hedgehog');

SELECT p.* FROM my_current_table_pets p;

alter table my_current_table_pets add (animal my_current_animal_type);

UPDATE my_current_table_pets p
  SET p.animal = (new my_current_animal_type('Crocodile', 'Male'));

SELECT p.* FROM my_current_table_pets p;

SELECT a.name, a.get_info() FROM my_current_table_with_animals a;