[英]Is there a way to use SET MARKUP CSV on in the Command window in PL/SQL Developer?
My code currently that I am running in the Command Window in PL/SQL Developer:我目前在 PL/SQL Developer 的命令 Window 中运行的代码:
SET MARKUP CSV ON DELIMITER | QUOTE OFF
SET FEEDBACK OFF
SPOOL C:\Users\Desktop\SpoolTest.csv
select *
from Vendor_data t
where rownum < 20
;
SPOOL OFF;
My output:我的 output:
222339 |067 |001
306811 |045 |001
024253 |067 |001
I need to remove the trailing spaces:我需要删除尾随空格:
222339|067|001
306811|045|001
024253|067|001
I am getting Cannot SET MARKUP.我收到无法设置标记。 I have to run my spooling in a command window in PL/SQL Developer.
我必须在 PL/SQL Developer 的命令 window 中运行我的假脱机。 Is there a way to do this?
有没有办法做到这一点? This is a snippet of code which is actually quite long.
这是一段实际上很长的代码片段。
SET
commands belong to Oracle's command line tool, SQL*Plus. SET
命令属于 Oracle 的命令行工具 SQL*Plus。
I don't use PL/SQL Developer (and quick Google doesn't return anything useful), so - does PL/SQL Developer support SET
commands at all?我不使用 PL/SQL Developer(并且快速的 Google 不会返回任何有用的东西),所以 - PL/SQL Developer 是否支持
SET
命令? If not, you're out of luck, but you could install Oracle Client (if you already don't have it) and run your script directly in SQL*Plus.如果没有,那么您就不走运了,但是您可以安装 Oracle 客户端(如果您还没有它)并直接在 SQL*Plus 中运行您的脚本。
On the other hand & unless I'm wrong, SET MARKUP CSV
is valid for Oracle 18c and above;另一方面,除非我错了,否则
SET MARKUP CSV
对 Oracle 18c 及以上版本有效; in lower versions, it is SET MARKUP HTML
you can use (ie no CSV
option).在较低版本中,您可以使用
SET MARKUP HTML
(即没有CSV
选项)。
The PL/SQL Developer's command-line tool is a different product than Oracle SQL*Plus
command-line utility, and it has a different set of supported commands. PL/SQL Developer 的命令行工具与 Oracle
SQL*Plus
命令行实用程序是不同的产品,它具有不同的受支持命令集。 PL/SQL Developer's command line mimics a real SQL*Plus functionality but does it only partially. PL/SQL Developer 的命令行模仿了真正的 SQL*Plus 功能,但只是部分地模仿了它。 For example, it doesn't support the
SET MARKUP CSV
command.例如,它不支持
SET MARKUP CSV
命令。 You can find the full list of supported commands in the PL/SQL Developer's Manual (Help -> User's Guide).您可以在 PL/SQL Developer's Manual (Help -> User's Guide) 中找到支持的命令的完整列表。
In your case, trailing spaces appear because you are printing headers of columns.在您的情况下,出现尾随空格是因为您正在打印列的标题。 Apparently, PL/SQL Developer tries to align rows by the maximum length of the column:
显然,PL/SQL Developer 尝试按列的最大长度对齐行:
spool file.txt
select ao.object_name, ao.object_id, ao.created, ao.status
from all_objects ao
where rownum <= 3;
OBJECT_NAME OBJECT_ID CREATED STATUS
-------------------------------------------------------------------------------- ---------- ----------- -------
TS$ 16 26.01.2017 VALID
ICOL$ 20 26.01.2017 VALID
Keeping in mind that PL/SQL Developer's supports of SET commands is very limited, we can achieve the CSV like spooling by simply not printing headers and setting colwidth to 1:请记住,PL/SQL Developer 对 SET 命令的支持非常有限,我们可以通过简单地不打印标题并将 colwidth 设置为 1 来实现类似假脱机的 CSV:
spool file.txt
set colsep |
set heading off
set colwidth 1
select ao.object_name, ao.object_id, ao.created, ao.status
from all_objects ao
where rownum <= 3;
spool off
it saves this to the spool file:它将它保存到假脱机文件:
TS$|16|26.01.2017 13:52:45|VALID
ICOL$|20|26.01.2017 13:52:45|VALID
C_FILE#_BLOCK#|8|26.01.2017 13:52:45|VALID
If you must print the headers, you can add an additional select from dual before the main sql just to print headers.如果您必须打印标题,您可以在主 sql 之前从双重添加额外的 select 以打印标题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.