ORA-00936 缺少表达式错误
ORA-00936 missing expression error
我正在尝试 运行 以下查询以进行登录审核,但出现以下错误:
ERROR at line 13:ORA-00936: missing expression.
这是脚本。我对此很陌生,不清楚缺少哪个表达式。任何帮助将不胜感激。
whenever sqlerror exist rollback
set feed on
set head on
set arraysize 1
set space 1
set verify on
set pages 25
set lines 80
set termout on
clear screen
spool aud_last_logon.lis
undefine number_of_days
col username for a10
col os_username for a10
col timestamp for a9
col logoff_time for a9
col returncode for 9999
col terminal for a10
col userhost for a10
select a.username,
os_username,
a.timestamp,
a.logoff_time,
a.returncode,
terminal,
userhost
from dba_audit_session a
where (a.username,a.timestamp) in
(select b.username,max(b.timestamp)
from dba_audit_session b
group by b.username)
and a.timestamp<(sysdate-&&number_of_days)
/
spool off
问题可能出在您运行处理它的方式上;假设您必须 运行 此代码:
spool d:\temp\spool.txt
undefine x
select &&x from dual
/
spool off
如果您简单地将这段代码剪切并粘贴到 SQLPLUS 中,您将得到:
SQL> spool d:\temp\spool.txt
SQL> undefine x
SQL> select &&x from dual
2 /
Enter value for x:
old 1: select &&x from dual
new 1: select from dual
select from dual
*
ERROR at line 1:
ORA-00936: missing expression
SQL> spool off
SQL>
原因是在交互模式下,/
之后的换行符用作 x
的 "value",因此出现错误。
如果您将此代码保存到文件中并 运行 它,您将获得所需的内容:
SQL> start d:\temp\test.sql
Enter value for x: 9
old 1: select &&x from dual
new 1: select 9 from dual
9
----------
9
我正在尝试 运行 以下查询以进行登录审核,但出现以下错误:
ERROR at line 13:ORA-00936: missing expression.
这是脚本。我对此很陌生,不清楚缺少哪个表达式。任何帮助将不胜感激。
whenever sqlerror exist rollback
set feed on
set head on
set arraysize 1
set space 1
set verify on
set pages 25
set lines 80
set termout on
clear screen
spool aud_last_logon.lis
undefine number_of_days
col username for a10
col os_username for a10
col timestamp for a9
col logoff_time for a9
col returncode for 9999
col terminal for a10
col userhost for a10
select a.username,
os_username,
a.timestamp,
a.logoff_time,
a.returncode,
terminal,
userhost
from dba_audit_session a
where (a.username,a.timestamp) in
(select b.username,max(b.timestamp)
from dba_audit_session b
group by b.username)
and a.timestamp<(sysdate-&&number_of_days)
/
spool off
问题可能出在您运行处理它的方式上;假设您必须 运行 此代码:
spool d:\temp\spool.txt
undefine x
select &&x from dual
/
spool off
如果您简单地将这段代码剪切并粘贴到 SQLPLUS 中,您将得到:
SQL> spool d:\temp\spool.txt
SQL> undefine x
SQL> select &&x from dual
2 /
Enter value for x:
old 1: select &&x from dual
new 1: select from dual
select from dual
*
ERROR at line 1:
ORA-00936: missing expression
SQL> spool off
SQL>
原因是在交互模式下,/
之后的换行符用作 x
的 "value",因此出现错误。
如果您将此代码保存到文件中并 运行 它,您将获得所需的内容:
SQL> start d:\temp\test.sql
Enter value for x: 9
old 1: select &&x from dual
new 1: select 9 from dual
9
----------
9