dbms_output.put 不打印数据 [英] dbms_output.put is not printing data

查看:46
本文介绍了dbms_output.put 不打印数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 plsql 中有一个简单的程序.基本上程序没有错误,但是当我使用 dbms_output.put 时没有打印输出.

I have a simple program in plsql. Basically the program has no errors but is not printing output when I use dbms_output.put.

declare
v_name varchar(30);
v_len number;
v_number number;
  begin
    v_name := '&name';
    v_number := length(v_name);
    while v_number > 0
    loop
      dbms_output.put(v_number||'::'||substr(v_name,v_number,1));
      v_number := v_number - 1;
    end loop;
  end;

当我使用 dbms_output.put_line 时,上面的程序会产生输出,但输出在每个字符之后都有新行,我希望输出在一条水平线上.在使用 dbms_output.put 它不会抛出任何错误,但它只是给我的消息:匿名区块完成"

The above program produces output when I use dbms_output.put_line but the output has new line after ever character and I would like to have the output in a single horizontal line. On using dbms_output.put it doesn't throw any error but it just gives me the message: "anonymous block completed"

如果我做错了什么,请告诉我.

Please let me know if am doing anything wrong.

谢谢,敏捷.

推荐答案

试试这个:只需在循环末尾添加 dbms_output.put_line('') 或 dbms_output.new_line.

Try this: Just add dbms_output.put_line('') or dbms_output.new_line at the end of the loop.

declare
v_name varchar(30);
v_len number;
v_number number;
  BEGIN

    v_name := :name;
    v_number := length(v_name);
    while v_number > 0
    loop
      dbms_output.put(v_number||'::'||substr(v_name,v_number,1)|| ' ' );
      v_number := v_number - 1;
    END loop;

    dbms_output.new_line;
  end;

附言请不要使用&"用于 pl/sql 中的替换变量 (&name),因为它是 SQL*Plus 支持的功能.相反,使用这样的绑定变量 :name

P.S. Please refrain from using '&' for substitution variable (&name) in pl/sql since its a feature supported by SQL*Plus. Instead, use bind variable like this :name

这篇关于dbms_output.put 不打印数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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