Oracle Custom Field Type

Source: Internet
Author: User

Oracle Custom Field Type target: define a method for writing data types Use a custom TYPE to CREATE a table for a field Add a data method for querying data other define a TYPE of SQL code CREATE OR REPLACE TYPE PropertyValue AS OBJECT (number_value number, string_value varchar2 (2000), date_value date, member function getNumberValue RETURN number, member function getStringValue RETURN varchar2, member function getDateValue RETURN date ); compile a TYPE method SQL code CREATE OR REPLACE TYPE BODY PropertyValue AS MEMBER FUNCTI ON getNumberValue RETURN number as begin return number_value; END getNumberValue; member function getStringValue RETURN varchar2 as begin return string_value; END getStringValue; member function ready RETURN date as begin return date_value; END ready; END; SQL code create table IGRP_SYS_PROPERTIES (nid number primary key, propertyKey varchar2 (2000), propertyValue Property Value, propertyType varchar2 (2000), description varchar2 (2000), createUserId number, modifyUserId number, createDate date, modifyDate date ); create sequence SQ_IGRP_PROPERTYID start with 1 increment by 1 MAXVALUE 1E27 MINVALUE 1 nocycle cache 20 NOORDER; -- Add comments to the columns comment on column IGRP_SYS_PROPERTIES.nid is 'pk unique value '; comment on column IGRP_SYS_PROPERTIES.propertyKey is 'Property key '; Comment on column IGRP_SYS_PROPERTIES.propertyValue is 'attribute name'; comment on column comment is 'attribute type'; comment on column IGRP_SYS_PROPERTIES.description is 'description'; comment on column comment is 'create user id '; comment on column IGRP_SYS_PROPERTIES.modifyUserId is 'modify user id'; comment on column IGRP_SYS_PROPERTIES.createDate is 'creation date'; comment on column IGRP_SYS_PR OPERTIES. modifyDate is 'modify date'; add data SQL code insert into IGRP_SYS_PROPERTIES VALUES (SQ_IGRP_PROPERTYID.nextval, 'xxx', PropertyValue (10, null, null), 'number', 'xxx ', 101,101, sysdate, sysdate); commit; query data SQL code select isp. propertyValue. getNumberValue () as myValues from IGRP_SYS_PROPERTIES isp where isp. propertyKey = 'xxx' and isp. propertyType = 'number'; other 1. when the data type is used in a data table, its BODY cannot be changed. Therefore, you must DROP the table related to the type before you can modify its BODY. 2. There is a problem with EXPORT and IMPORT. 3. SQL * Plus COPY commands cannot be used in custom data types.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.