if [ $returncode -eq 0 ]
then
query_msg=`$ISQL -S $USERNAME/$PASSWD@$SERVICENAME <<EOJ
set serveroutput on;
set heading off;
set feedback off;
set linesize 150;
declare
out_value varchar2(32767);
BEGIN
SELECT MESSAGE into out_value FROM RED.ERROR_LOG WHERE PROC = 'colour' and
to_char(to_date(DT,'DD-MON-YY')) = to_char(to_date(sysdate,'DD-MON-YY'));
dbms_output.put_line(out_value);
END;
/
EOJ`
echo $query_msg > $DATADIR/colour_DB.log
在该日志中,我沿垃圾值获取查询结果?我在plsql块中声明变量时缺少什么?可以帮我吗?
查询结果:-
+query_msg=$'declare\n*\nERROR at line 1:\nORA-01403: no data found\nORA-06512: at line 5'
+ echo declare 0 1 221.log 132.log 321.log 456.log --> these are the files in the server path(unwanted result).
一种可能的解决方法是在SQL语句的开头用SPOOL命令替换echo $query_msg > $DATADIR/colour_DB.log
:
SPOOL colour_DB.log