Revert scan state when prompting for variable values

Posted by Dave Jarvis on Stack Overflow See other posts from Stack Overflow or by Dave Jarvis
Published on 2010-03-11T20:53:57Z Indexed on 2010/03/11 20:59 UTC
Read the original article Hit count: 337

Filed under:
|
|

How do you detect the current SCAN state and revert it after changing it?

An exerpt from the script in question:

SET SCAN OFF
SET ECHO ON
SET SQLBLANKLINES ON

SET SCAN ON
UPDATE TABLE_NAME SET CREATED_BY = &&created_by;
SET SCAN OFF

The problem is that if the script doesn't have the first line (SET SCAN OFF), then the code to prompt the user should not turn the SCAN state off. In pseudocode, we'd like to do the following:

SET SCAN OFF
SET ECHO ON
SET SQLBLANKLINES ON

PUSH SCAN STATE
SET SCAN ON
UPDATE TABLE_NAME SET CREATED_BY = &&created_by;
POP SCAN STATE

The psudeocode PUSH SCAN STATE remembers the state so that if the code is altered by removing the first line, the rest of the script still works as expected.

© Stack Overflow or respective owner

Related posts about sql

Related posts about Oracle