ebi168
asked on
Problem when spooling DBMS_OUTPUT.PUT_LINE result
Hi,
I am trying to spool the output of DBMS_OUTPUT.PUT_LINE using the following code:
ORACLE_SID=DB1
export ORACLE_SID
export ORAENV_ASK=NO
BACKUP_DIR=/redo1/DB1/arch /testhotbk /
export BACKUP_DIR
. oraenv
sqlplus "/ as sysdba" <<!
spool /u03/oracle/local/output
BEGIN
for f1 in (select tablespace_name tn from dba_tablespaces)
loop
dbms_output.put_line(f1.tn );
end loop;
END;
/
spool off;
EXIT
!
But the whole thing gets spooled:
(from output.lst)
BEGIN
for f1 in (select tablespace_name tn from dba_tablespaces)
loop
dbms_output.put_line(f1.tn );
end loop;
END;
/
Can anyone tell me what is wrong and how can I just spool the content (f1.fn) put by dbms_output.
Thanks,
I am trying to spool the output of DBMS_OUTPUT.PUT_LINE using the following code:
ORACLE_SID=DB1
export ORACLE_SID
export ORAENV_ASK=NO
BACKUP_DIR=/redo1/DB1/arch
export BACKUP_DIR
. oraenv
sqlplus "/ as sysdba" <<!
spool /u03/oracle/local/output
BEGIN
for f1 in (select tablespace_name tn from dba_tablespaces)
loop
dbms_output.put_line(f1.tn
end loop;
END;
/
spool off;
EXIT
!
But the whole thing gets spooled:
(from output.lst)
BEGIN
for f1 in (select tablespace_name tn from dba_tablespaces)
loop
dbms_output.put_line(f1.tn
end loop;
END;
/
Can anyone tell me what is wrong and how can I just spool the content (f1.fn) put by dbms_output.
Thanks,
or modify your script like this:'
ORACLE_SID=DB1
export ORACLE_SID
export ORAENV_ASK=NO
BACKUP_DIR=/redo1/DB1/arch /testhotbk /
export BACKUP_DIR
. oraenv
sqlplus "/ as sysdba" <<!
spool /u03/oracle/local/output
select tablespace_name tn from dba_tablespaces;
spool off;
EXIT
!
ORACLE_SID=DB1
export ORACLE_SID
export ORAENV_ASK=NO
BACKUP_DIR=/redo1/DB1/arch
export BACKUP_DIR
. oraenv
sqlplus "/ as sysdba" <<!
spool /u03/oracle/local/output
select tablespace_name tn from dba_tablespaces;
spool off;
EXIT
!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
set serveroutput on won't solve the problem and I can't change the for loop because there will be an inner loop later on. Any more clues? Thanks
ASKER
Ok, then how could I find the result file under utl_file_dir. Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sounds good. I'll give it a try and let you know.
Why not just do this:
ORACLE_SID=DB1
export ORACLE_SID
export ORAENV_ASK=NO
BACKUP_DIR=/redo1/DB1/arch
export BACKUP_DIR
sqlplus -s "/ as sysdba" <<!
set ver off feed off echo off pages 0 lin 80 trims on term off
spool output
select tablespace_name tn from dba_tablespaces;
spool off;
EXIT
!
ebi:
I mentioned earlier on the second , alternative solution , I think it's simpler and easier.
Mike also gave out the same solution
I mentioned earlier on the second , alternative solution , I think it's simpler and easier.
Mike also gave out the same solution
Sorry seazodiak, didn't notice you had the same solution.
Also, he needs the set ... options to create a 'clean' spool file with only the file names.
ASKER
The trial has been successful using utl_file package. Sorry I can give up the for loop as I mentioned earlier. Thanks all
ASKER
I mean I can't give up the for loop.
ORACLE_SID=DB1
export ORACLE_SID
export ORAENV_ASK=NO
BACKUP_DIR=/redo1/DB1/arch
export BACKUP_DIR
. oraenv
sqlplus "/ as sysdba" <<!
set serverout on size 1000000
spool /u03/oracle/local/output
BEGIN
for f1 in (select tablespace_name tn from dba_tablespaces)
loop
dbms_output.put_line(f1.tn
end loop;
END;
/
spool off;
EXIT
!