Re: How to save commands into a file then run them again?

From: <hatzinger_m_at_bmwf1f.bmwf.gv.at>
Date: 18 Oct 92 14:13:09 GMT
Message-ID: <1992Oct18.114618.49_at_bmwf1f.bmwf.gv.at>


In article <1bqit4INNbdf_at_manuel.anu.edu.au>, cxd653_at_huxley.anu.edu.au (Chunping Ding) writes:
> When I use sqlplus to organize a report, I have to write many
> commands, for example,
>
> SQL> title center 'Test report';
> SQL> column ename heading "Employee|name' format A8;
> SQL> set pagesize 100;
> SQL> set linesize 88;
> SQL> select *
> 2 from emp
> 3 where depno = 30;
>
> Is there any method to save all the commands into a file, then run the
> file?

Use your local Editor to write a file with all the commands you need. Give the file the extension ".SQL" (eg. test_report.sql). Then start it from SQL*Plus with "start test_report.sql" or "_at_test_report.sql"

> Do I have to type all the commands every time?

No. The SQL*PLUS commands such as "SET ..." or "TITLE .." are resistant since you change them or close the current SQL session.

You can also spool the result of the SQL statement to a file --->

  • TEST_REPORT.SQL ---------------- title center 'Test report'; column ename heading "Employee|name' format A8; set pagesize 100; set linesize 88;

SPOOL test_report.lis

SELECT *
  FROM emp
 WHERE deptno=30;

SPOOL OFF



                                                                          ^
 Federal Ministry of Science and Research                               B | M
<-------------------------------------------------------------------------+---->
 Computer Center                                                        W | F
                                                                          |
 Klaus-Michael Hatzinger            mail: hatzinger_m_at_bmwf1f.bmwf.gv.at   |
 Bankgasse 1/209                   phone: 0043-222-53120/5188             |
 1014 Vienna, Austria                fax: 0043-222-53120/5155             V
================================================================================
Received on Sun Oct 18 1992 - 15:13:09 CET

Original text of this message