Prompts the user for additional information. This information is
stored in an interactive SQL variable, which can subsequently be
used by DML and some SET statements.
1 – Environment
You can use the ACCEPT statement in interactive SQL.
2 – Format
(B)0[m[1;4mACCEPT[m[1m qq> <variable-ref> qwqwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqwqwq>[m
[1mx tq> [1;4mDEFAULT[m[1m <default-value> qqqu[m [1mx[m
[1mx[m [1mtq> [1;4mHIDE[m[1m qqqqqqqqqqqqqqqqqqqqqqu[m [1mx[m
[1mx[m [1mtq> [1;4mPROMPT[m[1m <string-literal> qqqu[m [1mx[m
[1mx[m [1mtq> [1;4mNOPROMPT[m[1m qqqqqqqqqqqqqqqqqqu[m [1mx[m
[1mx[m [1mtq> [1;4mTIMEOUT[m[1m <numeric-literal> qu[m [1mx[m
[1mx[m [1mmq> [1;4mUPPER[m[1m qqqqqqqqqqqqqqqqqqqqqj x[m
[1mmqqqqqqqqqqqqqq <qqqqqqqqqqqqqqqqqqj[m
[1m [m
(B)0[m[1mvariable-ref = [m
[1mqqwqqqqqwqqq> identifier qwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqwq>[m
[1mm> : qj[m [1mmqwqqqqqqqqqqqqqwq> : identifier j[m
[1m [m [1mm> [1;4mINDICATOR[m[1m qj[m
3 – Arguments
3.1 – DEFAULT default-value
Provides a default value to be used if the user presses the
Return key. The default value must be a correctly formatted
character string that can be converted to the data type of the
variable.
3.2 – HIDE
Disables echo of the input text. The default is to echo all input
characters.
3.3 – PROMPT string-literal
Provides a prompt string that is displayed before accepting
input.
3.4 – NOPROMPT
Disables prompting with a string.
3.5 – TIMEOUT numeric-literal
If the user does not respond within this many seconds, then an
error is returned. Negative or zero values of the numeric-literal
are ignored. The default is to wait indefinitely.
3.6 – UPPER
All lowercase characters are converted to uppercase before
assignment to the variable. The default is to leave lowercase
characters unchanged.
3.7 – variable-ref
An interactive SQL variable defined using the DECLARE Variable
statement.
4 – Examples
Example 1: Prompting Based on the PROMPT and NOPROMPT Clauses
SQL> DECLARE :x INTEGER;
SQL> DECLARE :y INTEGER;
SQL>
SQL> ACCEPT :x indicator :y PROMPT 'what value? ';
what value? 10
SQL> PRINT :x, :y;
X Y
10 0
SQL>
SQL> ACCEPT :x INDICATOR :y NOPROMPT;
11
SQL> PRINT :x, :y;
X Y
11 0
SQL>
SQL> ACCEPT :x;
Enter value for X: 12
SQL> PRINT :x;
X
12
SQL>
Example 2: Using ACCEPT to Prompt for SET FLAGS String
This sequence would be included in a script.
SQL> DECLARE :debug_flags CHAR(20);
SQL> ACCEPT :debug_flags;
Enter value for DEBUG_FLAGS: trace
SQL> PRINT :debug_flags;
DEBUG_FLAGS
trace
SQL> SET FLAGS :debug_flags;
SQL> SHOW FLAGS
Alias RDB$DBHANDLE:
Flags currently set for Oracle Rdb:
PREFIX,TRACE,MAX_RECURSION(100)