Examples of usages of anydata data types in Oracle

Source: Internet
Author: User

---create waterfall
Create or replace type Waterfall is Object (name Varchar2 (), height number);

--Create River
Create or replace type Rivertest is Object (name Varchar2 (), length number);

Create or replace procedure Anydatatest
/*
* This example demonstrates a way to pass multiple different data type elements in a collection when parameters are passed
* You can convert all elements of different data types to the Anydata type to add to the collection, and then between programs
* Pass multiple data elements through a collection.
* then the corresponding type of member method is called according to the actual type of the element in the subsequent processing.
*/
Is
Type Feature_array is Varray (2) of sys.anydata;
V_feature Feature_array;
WF Waterfall;
RV Rivertest;
Ret_val number;
V_index Pls_integer;
Begin
V_feature: = Feature_array (
Anydata.convertobject (
Waterfall (' Waterfall1 ', 12)
),
Anydata.convertobject (
Rivertest (' Rivertes ', 34)
)
);
--Traversing the collection
V_index: = V_feature.first;
While (V_index was not null)
Loop
Case V_feature (v_index). Gettypename
When ' BISBNK. WATERFALL ' Then
Ret_val: = V_feature (V_index). GetObject (WF);
Dbms_output.put_line (' Waterfall name: ' | | Wf.name | | ' Height: ' | | Wf.height);
When ' BISBNK. Rivertest ' Then
Ret_val: = V_feature (V_index). GetObject (RV);
Dbms_output.put_line (' river name: ' | | Rv.name | | ' Length: ' | | Rv.length);
Else
Dbms_output.put_line (' unknow type: ' | | V_feature (V_index). Gettypename);
End case;
V_index: = V_feature.next (V_index);
End Loop;
exception
When No_data_found Then
Dbms_output.put_line (' No data found ');
Raise
When others then
Dbms_output.put_line (sqlcode| | ': ' | | SQLERRM);
Raise
End

Examples of usages of anydata data types in Oracle

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.