从 unix shell 脚本调用 sql 时出错
我有一个在 UNIX 上运行的 shell 脚本。像这样:
$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' <<EOF
set head on;
set feed on;
set serveroutput on;
set linesize 250;
set pagesize 1000;
column STATUS new_value VAR_STATUS ;
column JOB_NAME new_value VAR_JOB_NAME ;
BEGIN
SELECT JOB_NAME, STATUS
FROM DBA_SCHEDULER_JOB_RUN_DETAILS WHERE JOB_NAME = 'SOME_JOB' AND ACTUAL_START_DATE IN (SELECT MAX(ACTUAL_START_DATE) FROM DBA_SCHEDULER_JOB_RUN_DETAILS);
END;
/
exit
EOF
我收到错误:
ERROR at line 2:
ORA-06550: line 2, column 1:
PLS-00428: an INTO clause is expected in this SELECT statement
我做错了什么?
I have a shell script running on unix. Like this:
$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' <<EOF
set head on;
set feed on;
set serveroutput on;
set linesize 250;
set pagesize 1000;
column STATUS new_value VAR_STATUS ;
column JOB_NAME new_value VAR_JOB_NAME ;
BEGIN
SELECT JOB_NAME, STATUS
FROM DBA_SCHEDULER_JOB_RUN_DETAILS WHERE JOB_NAME = 'SOME_JOB' AND ACTUAL_START_DATE IN (SELECT MAX(ACTUAL_START_DATE) FROM DBA_SCHEDULER_JOB_RUN_DETAILS);
END;
/
exit
EOF
I get error:
ERROR at line 2:
ORA-06550: line 2, column 1:
PLS-00428: an INTO clause is expected in this SELECT statement
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每当我做这样的事情时,我都不使用 BEGIN 和 END 语句。将重定向的输入视为与从键盘键入完全相同。
Whenever I do stuff like this I don't use BEGIN and END statements. Think of the redirected input as exactly the same as you typing this from the keyboard.
当您使用 begin 和 end 时,Oracle 将视为匿名过程并期望变量声明和 into 子句将值分配给变量。
删除开始和结束并尝试。
如果您想要 Begin End,则声明相应数据类型的变量并尝试。
When you use begin and end Oracle will treat as Anonymous procedure and expect variable declaration and into clause to assign the values into variables.
Remove the begin and End and try.
If you want Begin End then declare the variables of respective datatype and try.