Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql LINUX下如何在DBMS_OUTPUT.put_行中添加新行字符_Sql_Linux_Oracle_Unix_Plsql - Fatal编程技术网

Sql LINUX下如何在DBMS_OUTPUT.put_行中添加新行字符

Sql LINUX下如何在DBMS_OUTPUT.put_行中添加新行字符,sql,linux,oracle,unix,plsql,Sql,Linux,Oracle,Unix,Plsql,在UNIX中,在SQL脚本中,我有以下代码: LOOP DBMS_OUTPUT.put_line (p_key||'|'||p_loc||'\n'); END LOOP LOOP DBMS_OUTPUT.put_line (p_key||'|'||p_loc); DBMS_OUTPUT.new_line; END LOOP 输出为: 5482004|Dir/3-30-2017/file:47923.xml 5482009|Dir/3-30

在UNIX中,在SQL脚本中,我有以下代码:

LOOP    
  DBMS_OUTPUT.put_line (p_key||'|'||p_loc||'\n');    
END LOOP
LOOP    
  DBMS_OUTPUT.put_line (p_key||'|'||p_loc);    
  DBMS_OUTPUT.new_line;    
END LOOP
输出为:

5482004|Dir/3-30-2017/file:47923.xml

5482009|Dir/3-30-2017/file:49288.xml
20 5482004|Dir/3-30-2017/file:447923.xml 5482009|Dir/3-30-2017/file:449288.xml 5482010|Dir/3-30-2017/file:449739.xml 5482012|Dir/3-30-2017/file:45015.xml
但是在Linux中,由于\n不起作用,我将用以下代码替换上述代码:

LOOP    
  DBMS_OUTPUT.put_line (p_key||'|'||p_loc||'\n');    
END LOOP
LOOP    
  DBMS_OUTPUT.put_line (p_key||'|'||p_loc);    
  DBMS_OUTPUT.new_line;    
END LOOP
输出为:

5482004|Dir/3-30-2017/file:47923.xml

5482009|Dir/3-30-2017/file:49288.xml
20 5482004|Dir/3-30-2017/file:447923.xml 5482009|Dir/3-30-2017/file:449288.xml 5482010|Dir/3-30-2017/file:449739.xml 5482012|Dir/3-30-2017/file:45015.xml
此格式的输出在每行之后没有新行。请建议循环中正确的内容


另外,我也尝试过DBMS|u OUTPUT.put_line p|u key | |'|'| | p| loc | | chr10,但输出仍然没有新行。

请参考下面的内容,以便回答这个问题

你可以使用chr10 我的代码中,我试图交换数字,我需要新行,所以我使用了chr10

DECLARE 
    A NUMBER;
    B NUMBER;
    TEMP NUMBER;
BEGIN
    A:=&A;
    B:=&B;
    DBMS_OUTPUT.PUT_LINE(chr(10)||'BEFORE SWAP A is : '||A||' AND B is : '||B);
    TEMP:=B;
    B:=A;
    A:=TEMP;
    DBMS_OUTPUT.PUT_LINE(' AFTER  SWAP A is : '||A||' AND B is : '||B);
END;
/

因此,在换行之前,在输出中A是:1,B是:2,我得到了新的一行。

我使用DBMS_output.put_line p_key | | | | | | p| loc | chr10;但输出仍然是5482004 | Dir/3-30-2017/file:447923.xml 5482009 | Dir/3-30-2017/file:449288.xml 5482010 | Dir/3-30-2017/file:449739.xml 5482012 | Dir/3-30-2017/file:45015.xml格式,而不是新行oneLOOP DBMS|output.put|u行p|u key | | | | | | | | | | | p| loc;DBMS_OUTPUT.put_linechr10;结束循环我尝试了同样的方法,但对输出格式没有任何影响