开发者

Error while calling sql from unix shell script

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;
s开发者_如何学运维et 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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜