如何使用pl sql中的匿名块打印出整个表? [英] how to print out the whole table using anonymous block in pl sql?

查看:93
本文介绍了如何使用pl sql中的匿名块打印出整个表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用DBMS_OUTPUT.PUT_LINE,但是行数仅超过1.表中没有任何东西按顺序递增,所以我不能使用循环.有什么方法可以打印出表格中的每一行?

I want to use DBMS_OUTPUT.PUT_LINE, but the number of rows exceeds just 1. There is nothing in the table which increments sequentially, so I can't use a loop. Is there some way to print out each row in the table?

推荐答案

尝试使用类似的方法.

try with something like this.

SET SERVEROUTPUT ON
     BEGIN
          -- A PL/SQL cursor
          FOR cursor1 IN (SELECT * FROM table1) 
          LOOP
            DBMS_OUTPUT.PUT_LINE('Column 1 = ' || cursor1.column1 ||
                               ', Column 2 = ' || cursor1.column2);
          END LOOP;
     END;
        /

这篇关于如何使用pl sql中的匿名块打印出整个表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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