Prompt command in PLSQL code

Hi,
In the below script giving the ability to the user to continue or Exit from the script execution.
Calling this script from a batchfile. Seems Y option is working but even "N" executing the script.
test.sql
prompt Do you want to continue script execution?
accept odg prompt 'Y / N :  ';
set termout off;
set verify off;
set heading off;
set pause off;
set echo off;
column a newline;
select decode(upper('&odg'), 'Y', 'prompt Executing ...',
                                  'prompt Stopped'
       decode(upper('&odg'), 'Y', '', 'accept return_key prompt ''Press <Return>''') a,
       decode(upper('&odg'), 'Y', '', 'exit') a
from dual;
set termout on;
SET FEEDBACK OFF
SET VERIFY OFF
SET SERVEROUTPUT ON
DECLARE
   lc_file_handle        UTL_FILE.file_type;
   lc_file_dir           VARCHAR2 (100);
   lc_file_name          VARCHAR2 (50);
   data                VARCHAR2 (500);
   v1                    ECCSYS.hwcontainer.hwcontainerserialnumber%type;
   v2                    ECCSYS.storagedevice.devicename%type;
   s2                    ECCSYS.storagedevice.isreserved%type;
   D1                SYS.DBA_DIRECTORIES.DIRECTORY_PATH%type;           
BEGIN  
SELECT DIRECTORY_PATH INTO D1 FROM SYS.DBA_DIRECTORIES WHERE DIRECTORY_NAME ='DATA_PUMP_DIR';
   lc_file_dir := 'DATA_PUMP_DIR';
   lc_file_name := '&1';
   lc_file_handle := UTL_FILE.fopen (lc_file_dir, lc_file_name, 'R');
   LOOP
      BEGIN
         UTL_FILE.get_line (lc_file_handle, data);
     v1 := SUBSTR (data,1,INSTR (data, ',', 1) - 1);
     v2 := substr(data, INSTR (data, ',', 1, 1) + 1, length(data) - INSTR (data,',', 1, 1));
       select isreserved into s2 from ECCSYS.storagedevice where devicename=v2 and storagearrayid = (select hwcontainerid from ECCSYS.hwcontainer where hwcontainerserialnumber =v1);
     DBMS_OUTPUT.PUT_LINE(v1 ||' '|| v2 ||' '|| s2);
      EXCEPTION
         WHEN NO_DATA_FOUND
         THEN
            EXIT;
      END;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.PUT_LINE('Please put the file ' || lc_file_name || ' into location :' || D1);
      UTL_FILE.fclose (lc_file_handle);
END;
accept return_key prompt 'Press <Return>'
EXIT;O/P
C:\ECC\Repository\admin\rambdb\dpdump>test.bat
Enter FILE NAME: test.txt
test.txt
SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 18 01:05:19 2013
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning and OLAP options
Do you want to continue script execution?
Y / N :  N
000190300153 170 0
000190300153 171 0
Press <Return>
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning and OLAP options
C:\ECC\Repository\admin\rambdb\dpdump>

I don't see how this part would work:
select decode(upper('&odg'), 'Y', 'prompt Executing ...',
                                  'prompt Stopped'
       decode(upper('&odg'), 'Y', '', 'accept return_key prompt ''Press <Return>''') a,
       decode(upper('&odg'), 'Y', '', 'exit') a
from dual;If the user input is other than Y, this query would return the text
'prompt Stopped', 'accept return_key prompt ''Press <Return>'', 'exit'
But these are text strings, not actual code that is executed.

Similar Messages

  • How to execute a Command Prompt command from J2SE code executing on Windows

    How to execute a Command Prompt command from J2SE code executing on Windows??
    Please help me

    [http://java.sun.com/docs/books/tutorial/getStarted/]
    ~

  • How to run a command prompt " command " through java code

    hi all,
    There is a command
    "java -jar selenium-server.jar -interactive"
    which i am running through command prompt after going to D:\MyFolder\Examples .
    i want to execute this command using java code .please help

    This has already been answered in your other two threads on this topic - http://forum.java.sun.com/thread.jspa?threadID=5221221&messageID=9898287#9898287 and http://forum.java.sun.com/thread.jspa?threadID=5221223&messageID=9898290#9898290.
    For some reason you don't want to read the reference that tells you exactly how to do what you want and how to avoid the pitfalls - http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html .

  • How to explicitely write PLSQL code for "Help - Display Error"? [SOLVED]

    I'm using menu DEFAULT&SMARTBAR and I'd like to write command in PLSQL code for "Help - Display Error" to display error. Has anyone any idea how to do this? I can not find syntaks in form help for this.
    Message was edited by:
    marussig

    Display_Error;

  • Run like Host command in plsql

    Hi,
    We are using Host command in sql*plus , but i need to implement like host command in Plsql. I refered previous post and some other links , that most of them are prefered only java stored procedure, And even that restricted previllage.
    Can you give some sample example launchiing Win OS command in plsql
    venki

    To run a batch file, you need to use the Command Shell (and please do not call it a DOS shell like some people tend to do as it is not DOS). E.g.
    c:\windows\system32\cmd.exe /c c:\temp\test.bat
    We're running cmd.exe with switch /c that tells cmd to execute the command we're passing it, and then to terminate.
    Note that we cannot interact with the shell from the PL/SQL side - we cannot answer prompts and so on. The script run, must be a proper batch/non-interactive script.
    Also, the Oracle Server process (Win32 thread actually) that is servicing our Oracle client connection, is running the command for us. This thread itself is a background service process. It could run in Windows configured environment (VM/Virtual Machine) that is not allowed to interact with the desktop - or have limited or no access to certain files, folders and programs.
    Technically speaking, this is what happens:
    1) we pass the command to execute from our client to the Oracle server session servicing us
    2) this Oracle thread uses the Java VM to make a Win32 call called CreateProcess()
    3) the Win32 kernel executes that process
    4) the process starts, runs and terminates
    5) the Java VM inside the Oracle Server process regains control and pass the exit code and standard output of that process to PL/SQL
    6) PL/SQL in turns, returns that very same data to our client
    If you for example run a program that pauses and expects input, or hangs.. it will cause the above series of steps to stop at step 4. With the Java VM waiting on it to complete, and we waiting for the Java VM and PL/SQL call to complete.

  • Prompt command

    I'm trying to bring up a prompt command. I can bring up the window but I cannot bring up the file with it when I type it in, if that makes any cense to anyone. this is what I have in my file
    class HelloWorld{
    public static void main(string[]args)
    system.out.printin("Hello World!");
    and I saved it in a File in Cdrive named Week 1 Directory and I'm supposed to send a picture of the command prompt to the proffesor but I can't get it to work. can anyone tell me what is going on.
    thanks need all the help i can get

    1. Compile your source code with javac. Ensure there are no exceptions and that all .class files are built
    2. Open a command line (on windows, run 'cmd')
    3. Run 'java mypackage/myapp' - java will actually open a command line if you didn't run from the command line.

  • Running a command from java code

    hi all,
    There is a command
    "java -jar selenium-server.jar -interactive"
    which i am running through command prompt after going to D:\MyFolder\Examples .
    i want to execute this command using java code .please help

    subratjyetki wrote:
    please answer in detail or if posible can u give the code for thisOnce more -
    The detail is given in the reference. Why don't you read it?
    I could give you the code but it will cost you �100 per hour.

  • Unix command from Plsql block

    Hi all ,
    I have tried unix command from PLSQL Block,
    Please see the code.
    DECLARE
    stat INTEGER;
    host_command varchar2(100);
    errormsg VARCHAR2(80);
    command varchar2(2000);
    BEGIN
    command:='touch /home/oracle/testting.txt';
    dbms_pipe.reset_buffer;
    host_command:= dbms_pipe.unique_session_name;
    dbms_output.put_line('host_command:'||host_command);
    dbms_pipe.pack_message(command);
    dbms_output.put_line('pack message:'||command);
    stat := dbms_pipe.send_message(host_command);
    dbms_output.put_line('stat:'||stat);
    IF stat <> 0 THEN
    raise_application_error(-20000, 'Error:'||TO_CHAR(stat)||' sending on pipe');
    END IF;
    stat := dbms_pipe.receive_message(host_command);
    dbms_output.put_line('stat2:'||stat);
    IF stat <> 0 THEN
    raise_application_error(-20000, 'Error:'||TO_CHAR(stat)||' receiving on pipe');
    END IF;
    dbms_pipe.unpack_message(errormsg);
    dbms_output.put_line('errormsg:'||errormsg);
    IF errormsg <> 'SUCCESS' THEN
    raise_application_error(-20000, 'Execution error: '||errormsg);
    END IF;
    END;
    Nothing happend from this code just getting only following result with error.
    -----------------result-----------------------------
    host_command:ORA$PIPE$002D19820001
    pack message:touch /home/oracle/testting.txt
    stat:0
    stat2:0
    errormsg:touch /home/oracle/testting.txt
    DECLARE
    ERROR at line 1:
    ORA-20000: Execution error: touch /home/oracle/testting.txt
    ORA-06512: at line 33
    Can any one tell me what i doing wrong in this code.
    I m working on Oracle 11g and AIX unix server.

    This is the forum for the SQL Developer product, not for general PL/SQL questions. There is a link to the SQL and PL/SQL forum in the announcement at the top of this forum.

  • To run a command using java code

    hi all,
    There is a command
    "java -jar selenium-server.jar -interactive"
    which i am running through command prompt after going to D:\MyFolder\Examples .
    i want to execute this command using java code .please help

    subratjyetki wrote:
    please answer in detail or if posible can u give the code for thisThe detail is given in the reference. Why don't you read it?
    I could give you the code but it will cost you ?100 per hour.

  • How to use "choose file with prompt" command?

    I need to use "choose file with prompt" command and I want give user possibility choose ONLY images (jpeg, png, gif). So, I write like this:
    choose file with prompt "Please, choose images for processing..." of type {"JPEG Image"}
    But this doesn't work! - All files (including jpegs) are dimmed, and user can't choose any....
    So, how can I filter JPEGs, PNGs and GIFs?

    I have found, that most of images on my computer has missing file_type, I don't know why..... so "type identifier of (info for (choose file))" also doesn't work properly.
    The only one way that 100% works is use Uniform Type Identifier (UTI) -- details here: http://www.huw.id.au/code/fileTypeIDs.html
    thanks.
    iMac G3, PowerBook G3 FW   Mac OS X (10.4.5)  

  • Prompt command with JBuilder

    i have just purchased my first JAVA book
    "A Framework for Programming and Problem Solving"
    Anyway, I have not gotten far at all because it asks me to use the prompt command early on to find the directory or make up one. I don't understand what that means. It came with a CD Rom with JBuilder on it. Why am I having to type using the command prompt and notepad as an editor? Is the JBuilder not the compiler/editor? I am confused and frustrated. Please help.

    JBuilder is an IDE (Integrated Development Environment).
    The Java SDK contains the compiler.
    Notepad is a text editor.
    There are many ways to enter, compile and run Java
    programs. JBuilder is one environment, but it separates
    the programmer from what is actually going on within the
    computer. The author is probably trying to encourage
    you to use notepad and the command prompt so that
    you will understand what JBuilder does for you when you
    tell it to "Make MyProject".
    IMHO, when you are first learning to program, using a
    text editor is probably best because you are required to
    write all of the code and you control the compilation and
    execution yourself. When you understand the basics of
    programming it's great to use an IDE for the features that
    they include. I would also suggest that you use TextPad
    instead of notepad. It can be used to highlight Java code
    and can also be configured to compile and run your
    programs.
    Hope that helps!
    Mark

  • Spanish characters getting garbled while executing command using Java code

    Hi,
    I try to execute a command using java code. output of the command contains spanish characters. Few of these characters getting garbled after the command execution.
    Runtime r = Runtime.getRuntime();
              Process p = null;
    String pgm="ipconfig /all";
              try
                        p = r.exec(pgm);
    BufferedReader br=new BufferedReader(new InputStreamReader
                                  (p.getInputStream()));
    while((val = br.readLine()) != null){ System.out.println(val);
              catch (Exception e)
                        return (null);
    I tried to run the code using -Duser.language=es -Duser.region=ES -Dfile.encoding=Cp850, but this did nt help. I could see the outputs properly in command prompt,
    If i redirect the output to a text file , it is getting garbled,
    Please let me know to solve this issue.

    884543 wrote:
    Hi,
    I try to execute a command using java code. output of the command contains spanish characters. Few of these characters getting garbled after the command execution.
    Runtime r = Runtime.getRuntime();
              Process p = null;
    String pgm="ipconfig /all";
              try
                        p = r.exec(pgm);
    BufferedReader br=new BufferedReader(new InputStreamReader
                                  (p.getInputStream()));
    while((val = br.readLine()) != null){ System.out.println(val);
              catch (Exception e)
                        return (null);
    I tried to run the code using -Duser.language=es -Duser.region=ES -Dfile.encoding=Cp850, but this did nt help. I could see the outputs properly in command prompt,
    If i redirect the output to a text file , it is getting garbled,
    Please let me know to solve this issue.Set the character set to UTF-8 to your InputStreamReader, for More details on usage refer the java api :
    http://download.oracle.com/javase/6/docs/api/java/io/InputStreamReader.html

  • ORA-01403: no data found Error in PLSQL code raised during plug-in processing.

    Hello OTN community,
    We are having the access to APEX problem. a New user was setup to access the APEX application. When I test to login as a new user, I get the message "ORA-01403: no data found Error in PLSQL code raised during plug-in processing.". When click OK to the disply message, the application will take me out of the sstem. I need help to even understand what is happening. I didn't develop the application, there is no documentation for this application, I am just supporting the application whenever there is a problem and I am new to APEX. As you can see I need help to figure this thing out. Your help is dearly appreciated.
    Thank you OTN

    Try to check the query that is executed and check if there is data or not

  • How to write a file in unix server through oracle plsql code

    Hi All,
    My requirement is to create and write a file (any file for eg txt file) in unix box with in a specified directory through oracle plsql code.
    Oracle sits in windows server.
    using utl_file package we can create directory where oracle resides and write it there in oracle server in our case windows..
    But here we need to create,write a file but in unix server which is different server than where the oracle server resides..
    we are using Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    Can any one one please help me out in this issue...
    Thanks in Advance.
    Prakash

    Mr Prakash,
    Why are you asking this question multiple times in every forum you can spell?
    Valid responses have been presented to you already two times.
    Can you explain why you can't follow them up, but continue to abuse this forum by repeating doc questions?
    Sybrand Bakker
    Senior Oracle DBA

  • Hye master.i want to install windows 8.1 but it can't and the prompt command had been out on my laptop screen.

    When i boot the cd,it can boot but after a while,the prompt command had been display on my laptop screen then i can't install the windows.anyone can help me?i'm from malaysia.thank you all

    Hi,
    Please refer to the guide provided by
    T. Kujala to correctly install Windows 8.1, if you have already followed the instruction, and the issue persists, then please post a screen shot of the "prompt command displayed on the screen" you mentioned for better understanding. Meanwhile,
    please make sure that the installation CD itself is not broken.
    Yolanda Zhu
    TechNet Community Support

Maybe you are looking for

  • Related to BSP

    Hi friends, I would like to know oe to use the select-options in BSP programing. Thanks in advance.    regards,   kishore

  • Printing of german characters

    Hello Friends, I am new to SDN and would like to know something. I want to print special german characters via SAP like 2 dots on alphabet A and O. How can I get those printed on the document. Currently these special characters are not printed but a

  • Help with Nokia N70 + Belkin Bluetooth USB + OS 10.4.6

    Hello I've seen previous threads relating to the problems Apple's Bluetooth File Exchange has in recognising/pulling up the contents of a Nokia N70. The advice for N70 users wishing to transfer their photos to the Mac has been to send photos individu

  • Why are images desaturated?

    I've struggled with this problem off an on for years, never truly understanding what fixed or caused the problem. I work on a MAC OSX and use Lightroom 4 and Photoshop CS4 exclusively.  In the past, I was told the issue was my color profile, and I've

  • OEM 10G discovery on solaris

    My 10G OEM console/repository is recognizing nodes with 9i databases (w/ 10G agents installed)... but not nodes with 10G databases (10.1.0.2) installed. Emctl start agent has been run on both, oratab files and listeners appear correct, no firewalls i