pl/sql 二维数组 - 无法到达第 2 项
在下面的代码示例中,
Type single_table_purge_type is varray(2) of varchar2(255);
Type single_table_list is table of single_table_purge_type;
purge_table single_table_list;
purge_table := new single_table_list(
new single_table_purge_type('product','Where product_id=5'),
new single_table_purge_type('customer','Where customer_id=10')
);
For x in 1..purge_table.Count
Loop
For y in 1..purge_table(x).Count
Loop
DBMS_OUTPUT.put_line( 'x='||x||' y='||y||' cell='||purge_table(x)(y));
End loop;
End loop;
DBMS_OUTPUT.put_line( 'm1 ' || purge_table(1)(1));
DBMS_OUTPUT.put_line( 'm2 ' || purge_table(1)(2));
DBMS_OUTPUT.put_line( 'm3 ' || purge_table(2)(1));
DBMS_OUTPUT.put_line( 'm4 ' || purge_table(2)(2));
我如何获取项目 (1,2) 或 (2,2)? (即 where 子句)。 当我打印出值时,我看到的只是第一个项目的重复项。
输出
m1 product
m2 product
m3 customer
m4 customer
In the following code example,
Type single_table_purge_type is varray(2) of varchar2(255);
Type single_table_list is table of single_table_purge_type;
purge_table single_table_list;
purge_table := new single_table_list(
new single_table_purge_type('product','Where product_id=5'),
new single_table_purge_type('customer','Where customer_id=10')
);
For x in 1..purge_table.Count
Loop
For y in 1..purge_table(x).Count
Loop
DBMS_OUTPUT.put_line( 'x='||x||' y='||y||' cell='||purge_table(x)(y));
End loop;
End loop;
DBMS_OUTPUT.put_line( 'm1 ' || purge_table(1)(1));
DBMS_OUTPUT.put_line( 'm2 ' || purge_table(1)(2));
DBMS_OUTPUT.put_line( 'm3 ' || purge_table(2)(1));
DBMS_OUTPUT.put_line( 'm4 ' || purge_table(2)(2));
How can i get to the items (1,2) or (2,2)? (i.e. the where clauses).
All i see is a duplicate of the first item when i print the values out.
Output
m1 product
m2 product
m3 customer
m4 customer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如图所示运行代码(添加
declare
、begin
和end
),我在 Oracle 10g 上得到以下结果:这让我相信您向我们展示的组装部件的方式有问题。请编辑您的问题以提供与您运行脚本完全相同的脚本。
(这确实应该是一条评论,但它需要的长度和格式不适合那里。)
Running your code as shown (adding
declare
,begin
, andend
), I get the following on Oracle 10g:This leads me to believe that there is something wrong in the way you are assembling the pieces you've shown us. Please edit your question to provide the script exactly as you run it.
(This really should have been a comment, but it requires length and formatting that wouldn't fit there.)