zoukankan      html  css  js  c++  java
  • oracle中anyData数据类型的使用实例

    ---创建waterfall
    create or replace type waterfall is object(name varchar2(30),height number);

    --创建river
    create or replace type rivertest is object(name varchar2(30),length number);

    create or replace procedure anydataTest
    /*
    *该实例演示了一种在参数传递时可以在集合中传递多个不同数据类型元素的例子
    *可以将不同数据类型的元素全部转换成anyData类型添加到集合中,然后在程序间
    *通过集合来传递多个数据元素。
    *然后在后续的处理中根据元素的实际类型分别调用对应类型的成员方法做相应的处理
    */
    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)
    )
    );
    --遍历集合
    v_index := v_feature.first;
    while(v_index is 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;

  • 相关阅读:
    IDF实验室-CTF训练营-牛刀小试CTF
    百度杯CTF夺旗大赛9月场writeup
    基于Mapxtreme for JAVA的电子地图设计与实现
    centos下 apache+mysql+php的安装
    ssh远程登陆
    毕业设计-JSP论文盲审系统
    Android毕业设计-微圈
    基于Android的高校饮水宝app
    小程序不支持wx.request同步请求解决方法
    微信小程序服务类目大坑:特殊行业服务类目所需资质材料
  • 原文地址:https://www.cnblogs.com/moonfans/p/4288537.html
Copyright © 2011-2022 走看看