嵌套数组和关联数组有什么区别? [英] What is the difference between nested array and associative array?

查看:113
本文介绍了嵌套数组和关联数组有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有两个链接 http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/composites.htm#LNPLS99981

使用不同类型的PL的目的Oracle中的/SQL集合

通过引用以上两个链接,我有两个疑问

by referring above two links i have two doubt

1.哪个是正确的嵌套表?

1.Which one is correct nested table?

2.如果oracle doc是正确的,则嵌套表和关联数组之间有什么区别?

2.If the oracle doc is correct what is the difference between nested table and associative array?

推荐答案

这是另一个不常见的区别.您可以将两个嵌套表与=<>进行比较,但不能对关联数组进行比较.

Here is another difference which is not that commonly known. You can compare two nested tables with = or <> but associative array you cannot.

DECLARE

    TYPE associative_array IS TABLE OF INTEGER INDEX BY PLS_INTEGER;
    a_var_associative_array associative_array;
    b_var_associative_array associative_array;

    TYPE nested_table IS TABLE OF INTEGER;
    a_var_nested_table nested_table := nested_table(1, 2, 3, 4, 5);
    b_var_nested_table nested_table := nested_table(5, 4, 3, 2, 1);

BEGIN

    IF a_var_nested_table = b_var_nested_table THEN
        -- Note, the different order of values!
        DBMS_OUTPUT.PUT_LINE ( 'TRUE' );
    ELSE
        DBMS_OUTPUT.PUT_LINE ( 'FALSE' );
    END IF;

    -- IF a_var_associative_array = b_var_associative_array THEN -> gives you an error! 

END;

使用嵌套表时,您还可以使用多集运算符多集条件 SET 不可用关联数组.

When you work with nested tables you can also use Multiset Operators, Multiset Conditions and SET which are not available for associative arrays.

这篇关于嵌套数组和关联数组有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆