Backing up SQL Plus environment during script

Some scripts that I inherited will blindly call SET FEEDBACK OFFeither SET ECHO OFFat the beginning of the script, and then install them at ONor OFFat the end of the script. I would like to modify these scripts to determine what value was set before running the script, and return the environment back to that value when the script exits.

How can I query the values ​​of the SQL Plus environment, save them and restore them when the script is finished?

One of the ways I thought of:

SPOOL env-backup.sql
SHOW ECHO FEEDBACK TIMING

REM ...

@env-backup.sql

But

  • Thrown values SHOW ECHO FEEDBACK TIMINGcannot be executed directly ( ECHO OFFvs SET ECHO OFF)
  • I would prefer not to create another file (or any changes to the database)

, , SqlPlus Oracle XE (10g) Windows

+3
4

SQL * Plus STORE . , . . "HELP STORE" SQL * Plus .

+7

+1

, SQL , HOST. , HOST SQLPLUS username/password@tnsname @script.sql, .

+1

Why not just specify the right values ​​for your connection in the glogin.sql script?

It is usually located in% ORACLE_HOME% \ sqlplus \ admin

From my glogin.sql:

--
-- Copyright (c) 1988, 2005, Oracle.  All Rights Reserved.
--
-- NAME
--   glogin.sql
--
-- DESCRIPTION
--   SQL*Plus global login "site profile" file
--
--   Add any SQL*Plus commands here that are to be executed when a
--   user starts SQL*Plus, or uses the SQL*Plus CONNECT command.
--
-- USAGE
--   This script is automatically run
--
set pagesize 60
set linesize 500
set wrap off

Then simply re-run all the scripts that change your environment (or run @ glogin.sql).

0
source

Source: https://habr.com/ru/post/1770968/


All Articles