Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 








Interactive PL/SQL to accept input

Oracle Database Tips by Donald Burleson


Question:  I want to write interactive PL/SQL that accepts user input for my SQL.  How do I write PL/SQL to accept user input?  I want to collect parameters at runtime and pass them to a PL/SQL stored procedure.


Answer:  In SQL*Plus we have the prompt and accept syntax, but there is no direct way to make PL/SQL interactive without using PHP, Apex, Java, etc.


For making PL/SQL interactive with SQL*Plus, Laurent Schneider (author of the book Advanced SQL Programming) has this code example for interactive PL/SQL:


set feedb off ver off
col i nopri new_v i
col script nopri new_v script
select 0 i from dual where 1=0;
select to_char(0&i+1,'FM0') i,decode(0&i,5,null,'x.sql') script from dual;
undef col1
undef col2
insert into t(col1,col2) values (&col1,'&col2');


Laurent Schneider also has this Linux shell script technique for accepting user input into PL/SQL:


set feedb off

create or replace directory tmp as '/tmp';

inFile utl_file.file_type;
outFile utl_file.file_type;
x varchar2(40);
inFile := utl_file.fopen('TMP','in','R');
outFile := utl_file.fopen('TMP','out','W');
utl_file.put_line(outFile,'Enter a value for x : ');
utl_file.put_line(outFile,'you entered '||x);


$ mknod /tmp/out p; mknod /tmp/in p
$ (cat /tmp/out &);(sqlplus -s scott/tiger @interactiveplsql &



Enter a value for x :
you entered ABC123




Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster


Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.