views:

362

answers:

2

Heya,

I need to set up some SET options in Oracle SQLplus command line program each time I use it, such as SET HEADING OFF and the likes to beautify my results. I found that I always have to input each line separately so Set different options and this is becoming annoying since I need to access it many times a day.

I found that there's no way to separate different SET commands with semicolons because it doesn't accept it:

SET HEADING OFF; SET LINESIZE 100;

returns an error

A solution could be adding them to a control script and create a shell alias, but I know control scripts execute and then exit and don't return you control over the command line.

So, anybody knows another solution? Or am I missing something?

A: 

Ok, answering my own question: apprently it is possible to do this:

SET HEADING OFF LINESIZE 100 PAGESIZE 0 xxx xxx

And go on adding rules as one comes up with them.

It is a simple and effective solution for now.

Lex
+1  A: 

Put all your commands in a ".sql" file (for example "format.sql") then execute them with the "@" command in Sql*plus (for example "@format").

Note that it defaults to the ".sql" suffix when looking for the command file.

For example, if "format.sql" contains the commands "set linesize 100" and "set pagesize 0":

% sqlplus

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 18 08:39:03 2010
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
SQL> show linesize
linesize 80
SQL> @format
SQL> show linesize
linesize 100
SQL> select 1+1 from dual;
     2
David Gelhar
What I need is just setup options, I execute queries by hand then, if I put them in a sql file and use "@" then I won't get a command line back to input queries.
Lex
Really? This has always worked fine for me - just run the "@" command from the SQL> prompt, and you stay in SQLPlus when the command file completes (I'll edit an example into my answer)
David Gelhar
Wonderful, it works, so both works: mine and yours, voting yours as answering my specific question :) thanks
Lex

related questions