SQL*Plus 中的清除屏幕

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13661757/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 12:23:43  来源:igfitidea点击:

Clear Screen in SQL*Plus

sqloraclesqlplus

提问by Jason Kemeys

I'm running the following report but getting an error

我正在运行以下报告但出现错误

/* Simple table formatting */

clear screen;
accept Report_File char prompt 'Enter a file name for summary report ';

/*Set up column headers*/
col StoreCode format A8 heading 'Store Code';
col DESCRIPTION format A8 heading 'Item Description';
col PRICE format 9999.99 heading 'Price';
col QUANTITY format 999 heading 'Quantity';
col (Price*Quantity) format 9999.99 heading 'Value';

/*Format and title pages */

set Pause off;
set Feedback off;
set Space 6;
set newpage 2;
set pagesize 54;
set linesize 200;
set underline =;
title center 'Current Stock Value by Store' skip 2 left -
            'prepared by Jason Kemeys' &Report_Officer right -
            &Todays_Date skip4;
btitle center format 999 SQL.PNO;

/* Set breaks and computes */

break on StoreCode skip 2 on SuppCode skip 1 on Report;
compute sum of (Price*Quantity) on StoreCode;
compute sum of (Price*Quantity) on Report;

/*Select data & send to file*/

spool &Report_File;

select StoreCode, Description, Quantity, Price, (Price*Quantity)
from Stocks
order by StoreCode;

spool off;

/* Clear all settings */

clear breaks;
clear columns;
clear computes;
set Pause on;

Just need to know why its showing the error and how to get it running; first time doing a report in SQL.

只需要知道为什么它会显示错误以及如何让它运行;第一次用 SQL 做报告。

This is the error I'm getting

这是我得到的错误

clear screen; * ERROR at line 2: ORA-00900: invalid SQL statement

清屏;* 错误在第 2 行:ORA-00900:无效的 SQL 语句

回答by nagendra

cl scris the command used to clear screen in SQL.

cl scr是用于在 SQL 中清除屏幕的命令。

回答by Ben

I suspect this is dependent on the version of Oracle you are using.

我怀疑这取决于您使用的 Oracle 版本。

This should work in version 11.2but to quote from the 10g documentation:

应该适用于 11.2 版,但引用自10g 文档

CLEAR SCREEN is not available in SQL*Plus.

CLEAR SCREEN 在 SQL*Plus 中不可用。

The same note isn't there in the 11.1 documentation, which would imply that you're using Oracle 10g or earlier. If this supposition is true then there's little that you can do.

11.1 文档中没有相同的注释,这意味着您使用的是 Oracle 10g 或更早版本。如果这个假设是真的,那么你无能为力。

It's possiblethat you can utilise the hostcommand in SQL*Plus to run cls, if you're using Windows, or clear, if you're using Linux, but I'm not certain that it would have exactly the same effect. If it were possible it would simply be:

这是可能的,你可以利用host在SQL * Plus命令来运行cls,如果你使用的是Windows,或者clear,如果你正在使用Linux,但我不能肯定它会具有完全相同的效果。如果可能的话,它只会是:

host cls

hostruns an operating system command from SQL*Plus, and so will appearto clear the screen.

host从 SQL*Plus 运行操作系统命令,因此将出现清除屏幕。

回答by vishwaraj

simply use cl scrcommand to clear the SQL plus.

只需使用cl scr命令清除 SQL plus。

回答by tvCa

Very few occurances of ";" in your code is actually needed. For example, the "clear screen" command to start with, doesn't need a semicolon. It will work, when you add one, but I wouldn't be sure about all the subsequent commands in that same file. Commands that need them, are limited to INSERT, UPDATE, DELETE, COMMIT, ROLLBACK, and such.

很少出现“;” 在您的代码中实际上是需要的。例如,“清除屏幕”命令开始时不需要分号。当您添加一个时它会起作用,但我不确定同一文件中的所有后续命令。需要它们的命令仅限于 INSERT、UPDATE、DELETE、COMMIT、ROLLBACK 等。

Secondly, if you get weird feedback from SQL-files, and if you have written them outside of Linux/Unix, this often ends up in SQLPLUS complaining about invisible characters. Look at that file via both VI and CAT commands, and note anything weird.

其次,如果您从 SQL 文件中得到奇怪的反馈,并且如果您是在 Linux/Unix 之外编写它们的,这通常会导致 SQLPLUS 抱怨不可见字符。通过 VI 和 CAT 命令查看该文件,并注意任何奇怪的地方。