oracle - How to use bind variable value as prompt in SQL*Plus ACCEPT command -


i'd use bind variable value input prompt in sql*plus script. here's i've tried:

1) defined bind variable follows

sql>var prompt varchar2(100) 

2) , assigned value using pl/sql

sql>exec select 'your name' :prompt dual 

3) can print or select bind variable value follows:

sql>select :prompt dual;  :prompt ------------------------------------ name   sql>print prompt  prompt ------------------------------------ name 

4) i'd have "your name" being shown accept prompt don't know how can achieved:

sql>accept input prompt 'prompt' prompt  sql>accept input prompt ':prompt' :prompt 

5) able assign bind value substitution variable, done that:

sql>define prompt = 'your name subst'  sql>accept input prompt '&prompt.>' name subst>bob  sql>def input define input           = "bob" (char) 

the way see done spooling temp.sql file , running using @temp.sql seems terrible hack

you use the column ... new_value syntax query, unless you're running script (so set termout off takes effect) you'll blank lines:

sql> var prompt varchar2(100) sql> exec select 'your name' :prompt dual  pl/sql procedure completed.  sql> set feedback off sql> column o_prompt new_value n_prompt noprint sql> select :prompt o_prompt dual;    sql> accept input prompt '&n_prompt.>' name>bob sql> def input define input           = "bob" (char) 

i don't think there's way define substitution variable directly bind variable, or use bind variable in purely client statement define, accept, etc. (other print, client command exists purpose).

of course, if you're doing don't need bind variable, can more directly just:

sql> set feedback off sql> column o_prompt new_value n_prompt noprint sql> select 'your name' o_prompt dual;    sql> accept input prompt '&n_prompt.>' name>bob sql> def input define input           = "bob" (char) 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -