暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 使用动态假脱机路径时的SP2-0606

askTom 2018-02-09
925

问题描述

SQL * Plus客户端: Windows 8客户端上的版本11.2.0.1.0

使用硬编码路径在假脱机文件中写入输出在任何目录中都可以工作,但是假脱机和文件名在该字符串周围带有和不带有双引号
我收到消息了
SP2-0606: Kann SPOOL nicht erstellen - Datei "&filename.LST"


原因是什么?

glogin.sql from SQL Plus

--
-- Copyright (c) 1988, 2005, Oracle.  All Rights Reserved.
--
-- NAME
--   glogin.sql
--
-- DESCRIPTION
--   SQL*Plus global login "site profile" file
--
--   Add any SQL*Plus commands here that are to be executed when a
--   user starts SQL*Plus, or uses the SQL*Plus CONNECT command.
--
-- USAGE
--   This script is automatically run
--
--Umlautproblem sqlplus beseitigen, funktioniert für Lucida Console
host chcp 1252
--set linesize 5000
set trimspool on
set pagesize 1000
--set colsep |
--set tab off
--set SQLPROMPT "_USER'@'_CONNECT_IDENTIFIER> "
--set ESCAPE \
set echo on
set feedback 1
--set pno 0


--SQL skript

--@test
set echo on
column filename new_val filename

--Quartal ermitteln
select to_char(sysdate,'Q') AS MY_QTR FROM DUAL;
--String Pfad ausgeben
--select 'W:\SG-323\TeamZentraleKatalogredaktion\Bankleitzahlen\Q' || to_char(sysdate,'Q') ||  '_' || to_char(sysdate, 'yyyy')||  '\ZD_ZZB-einspielenÄnderungskennz-A-M.txt' filename from dual;

select 'H:\Dokumente\SQL\Q' || to_char(sysdate,'Q') ||  '_' || to_char(sysdate, 'yyyy')||  '\ZD_ZZB-einspielenÄnderungskennz-A-M-testspool-hardcodiert.txt' filename from dual;

--Spool erstellen mit Spalten, Pfad in Variable
spool "&filename"
--spool H:\Dokumente\SQL\Q1_2018\ZD_ZZB-einspielenÄnderungske

专家解答

这是unicode字符,例如

SQL> col x new_value y
SQL> select 'C:\tmp\spaces and character stuffÄ\demo.dat' x from dual;

X
--------------------------------------------
C:\tmp\spaces and character stuffÄ\demo.dat

1 row selected.

SQL> spool "&&y"
SP2-0606: Cannot create SPOOL file "C:\tmp\spaces and character stuffÄ\demo.dat"
SQL> spool off
not spooling currently
SQL>
SQL>
SQL> col x new_value y
SQL> select 'C:\tmp\spaces and character stuff\demo.dat' x from dual;

X
------------------------------------------
C:\tmp\spaces and character stuff\demo.dat

1 row selected.

SQL> spool "&&y"
SQL> spool off
SQL>
SQL>


但是,如果在开始之前设置NLS_LANG,就可以了


C:\Users\hamcdc>set NLS_LANG=AMERICAN_AMERICA.AL32UTF8

C:\Users\hamcdc>sqlplus scott/tiger

SQL*Plus: Release 12.2.0.1.0 Production on Tue Feb 13 10:24:50 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Sat Feb 10 2018 08:14:24 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production


SQL> col x new_value y
SQL> select 'C:\tmp\spaces and character stuff\demo.dat' x from dual;

X
------------------------------------------
C:\tmp\spaces and character stuff\demo.dat

SQL> spool "&&y"
SQL> spool off


「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论