Spool to a file with the database name


column dbn new_value dbname noprint
select global_name dbn from global_name;

spool &dbname..txt