User input in a loop

Hi,
I am trying to write a script where by a user will be prompted to enter a new value each time it loops. So far, the script only prompts me once and the it keeps using the same value over and over again instead of prompting me to insert new value.
How can i fix this. My script is below.
declare
v_count number(2):=1;
v_compno number(10);
begin
loop
select compid into v_compno from amos.componentunit
where compno=&compno;
dbms_output.put_line(v_compno);
v_count:=v_count +1;
exit when v_count=10;
end loop;
end;
Thanks in advance.

The '&compno' is a element of SQL*Plus, is not a element of PL/SQL.
On the other hand , the loop is a syntax element of PL/SQL,
SQL*Plus has no corresponding command.
Sorry, I have no idea.
But, can you try this?
SQL> set serverout on
SQL> declare
  2    v_count number(2):=1;
  3  begin
  4    for p in (select ename,deptno from scott.emp
  5               where ename in (&ename)) loop
  6      dbms_output.put_line(p.ename||' belongs '||p.deptno);
  7      v_count:=v_count +1;
  8      exit when v_count=10;
  9    end loop;
10  end;
11  /
Enter value for ename: 'SCOTT','KING'
old   5:              where ename in (&ename)) loop
new   5:              where ename in ('SCOTT','KING')) loop
SCOTT belongs 20
KING belongs 10
PL/SQL procedure successfully completed.

Similar Messages

  • Wait for user input in for loop

    I'm pretty new to labview and I'm having a hard time figuring out how to do this. Basically, I need the user to press a GO button and data aquisition will take place saving it in an array, then the program will wait for the user to press the GO button again and the data aqusition will add more values to the array, and the whole process will repeat 5 times and finally it will average the values.
    To try and figure out how to do this, I tried making a program that loops 5 times and adds a random number to an array with each loop (using shift registers) but I CANNOT figure out how to make each loop iteration wait on the user to press a button. Any advice?

    Hi Roger,
    you can use a dialog in your for loop, or better you use an event structure to react on user inputs. If you use the event structure you can count the button press events and store them in a shift register. With a compare function you can check if your limit is reached and react on it.
    Mike

  • Modifying user input in for loop

    Hello,
    I am making a program in order to control two velmex motors. As part of my program, I have two nested for loops. The inner for loop formats a user specified input in ascii commands and the outer loop tells the program how many times to run that specific inner loop pattern. 
    I want to modify the program so that two motors work together in a "snake pattern". In other words, the first outer loop should take the original user input, but then the second time the outer loop runs the direction of one of the motors (all of the associated values with one motor are stored in an individual cluster and these clusters are sorted and placed into an array), should be reveresed by mulltiplying the step size * -1. The third time the outer loop runs, the direction of one the motors (the same motor) should be reveresed again so it is moving in its original direction etc.
    Hope that made sense...
    I have attached my code for clarification - any help would be really appreciated
    Thanks,
    Mridu

    mnanda98 wrote:
    Hi RavensFan,
    Do you mean I need to wire a constant into the VISA read?
    Isn't that exactly what I said?
    Also I am making progess, but now when I run the program I get the error "timeout expired before the operation completed". From what I understand, the timeout would only expire if it is not picking up on the termination character, which I have put in.. Can you look at my code maybe and tell me what may be the problem?
    It looks like you've set the termination character to be a carriage retrrun (decimal 13) just fine.  So if you are getting a timeout error, that means you are either not sending the commands correctly and the device is not responding, or the termination character is not actually a carriage return like you said.
    Do you have any software that the vendor of the device  might have supplied that can prove to you that it is communicating correctly?  Is any data returned in the string indicators when it finally times out?
    Thanks in advance,
    Mridu
     And why do you still have the VISA Close inside the loop closing the port on each iteration?  It belongs after the while loop.

  • User input in the middle of the loop

    How can I take user input in the middle of the loop and execute the rest of the loop?
    FOR .. LOOP
    User input…………;
    Update with User input;
    END LOOP;
    Thanks in advance.
    Edited by: Oracle_Power on Jul 29, 2009 11:36 AM

    Forms has no mechanism like that where you can prompt the user for input.
    An Alert is the closest thing, but alerts only accept three button pushes; no keyboard input is allowed.
    If you describe what you need, someone might help you redesign your code so it appears to act like a looping process.
    Edit: Thanks Andreas, your suggestion below is a good solution.

  • User input in loop

    For some reason I could not find information about user input in the first chapters of my programming book, therefore I decided to find out on my own. using google gave me a few hints, but I cannot figure out how to solve this problem: when trying to assign the same variable a new value I get a error. how would you solve this?
    program:
    package henke;
    import java.util.Scanner;
    public class Main {
        public static void main(String[] args) {
           System.out.println("\n\n\t\t\tWelcome to the 'guess my number' game!\n");
           while(true){
               System.out.println("\nChose your option: \n" +
                   "1\) Guess the random number!\n" +
                   "2\) Make the computer guess your number!\n" +
                   "3\) Exit\n");
               int option;
               Scanner in = new Scanner(System.in);
               System.out.print("Your option: ");
               option = in.nextInt();
               in.close();
               if(option == 1){
                   System.out.println("Not built yet. ");
               else if(option == 2){
                   System.out.println("Will be built last. ");
               else if(option == 3){
                   break;
               else{
                   System.out.println("Illegal option.. ");
    }output including error messages:
    run:
                            Welcome to the 'guess my number' game!
    Chose your option:
    1) Guess the random number!
    2) Make the computer guess your number!
    3) Exit
    Your option: 1
    Not built yet.
    Chose your option:
    1) Guess the random number!
    2) Make the computer guess your number!
    3) Exit
    Exception in thread "main" java.util.NoSuchElementException
            at java.util.Scanner.throwFor(Scanner.java:838)
            at java.util.Scanner.next(Scanner.java:1461)
            at java.util.Scanner.nextInt(Scanner.java:2091)
            at java.util.Scanner.nextInt(Scanner.java:2050)
            at henke.Main.main(Main.java:18)
    Your option: Java Result: 1
    BUILD SUCCESSFUL (total time: 1 second)

    thanks for the links. some googling made it possible for me to finish this script. It might be somewhat messy since I have just written it (no complaints about the output though). and oh, I didn't finish the 'while ... and ...' loop somwhere in there since I didn't have the energy. I should really go to sleep now. bye
    package javaapplication;
    import java.util.Scanner;
    public class Main {
        public static void main(String[] args) {
        System.out.println("\n\n\t\t\tWelcome to the 'guess my number' game!\n");
    //    Startup delay
        System.out.print("|");
            for(int i = 0; i <= 30; i++) {
                 System.out.print("=");
                 try {
                     Thread.sleep(300);
                 catch (InterruptedException ie){
        System.out.println("|\nJob's done!");
                //Den stora loopen
           while(true){
               System.out.println("\nChose your option: \n" +
                   "1) Guess the random number!\n" +
                   "2) Make the computer guess your number!\n" +
                   "3) Quit\n");
               Scanner in = new Scanner(System.in);
               System.out.print("Your option: ");
               int option = in.nextInt();
               //in.close();
               //Guess the random number!
               if(option == 1){
                   System.out.print("Number of possibilities: ");
                   int numPosA = in.nextInt();
                   int secretA = (int)(Math.random()*numPosA);
                   int iA = 0;
                   while(true){
                       iA++;
                       System.out.print("Your guess: (between 0 and "+ (numPosA -1)+ ") ");
                       int guessA = in.nextInt();
                       if(guessA == secretA){
                           System.out.println("Correct! The secret number is "+ secretA+
                                   " - you guessed "+ guessA+ "! It only took you "+ iA+
                                   " guesses!");
                           System.out.println("\nPress enter to return to the main menu. ");
                           try {
                               System.in.read();
                           } catch (java.io.IOException ie) {}
                           break;
                   else if(guessA > secretA){
                       System.out.println("To high. Try again. ");
                   else if(guessA < secretA){
                       System.out.println("To low. Try again. ");
                   else{
                       System.out.println("Illegal option. ");
               //Make the computer guess your number!
               else if(option == 2){
                   System.out.print("Number of possibilities: ");
                   int numPosB = in.nextInt();
                   //while(secretB >= 1) and (secretB <= numPosB){
                   System.out.print("The secret number: (has to be between 1 and "
                           + numPosB+ ") ");
                   int secretB = in.nextInt();
                   int iB = 0;
                   while(true){
                       iB++;
                       int guessB = (int)(Math.random()*numPosB+1);
                       if(guessB == secretB){
                           System.out.println("The computer figured out your secret number! "+
                                   "The computer guessed "+ guessB+ " - and your secret number is "+
                                   secretB+ ". It took "+ iB+ " random numbers!");
                           System.out.println("\nPress enter to return to the main menu. ");
                           try {
                               System.in.read();
                           } catch (java.io.IOException ie) {}
                           break;
                       else if(iB >= numPosB * 2){
                           System.out.print("The computer has guessed "+ (numPosB * 2)+ " times."+
                                   "no more chances!");
                           System.out.println("\nPress enter to return to the main menu. ");
                           try {
                               System.in.read();
                           } catch (java.io.IOException ie) {}
                           break;
               //Quit
               else if(option == 3){
                   break;
               //Else
               else{
                   System.out.println("Illegal option.. ");
    }

  • How to capture user input for customer exit processing?

    I need to calculate the number of working days elapsed in the current fiscal quarter BASED on the USER INPUT on the reporting front.  i.e., say the fiscal quarter started on 1 July 2005 and if the user enters 10 July 2005, I should get the value 8 (Assume that Monday through Friday are all workdays).  If the user enters 12 July 2005, I should get 10.  I have written customer exits and know how to use factory calendar, but <b>THE CHALLENGE</b> is how do I <b>CAPTURE</b> the user input and use it in my exit?  During the varible definition, if I select the check box "Ready for input" then the customer exit is not being processed and unless I check that box I can't get a user entry!  If I look at the import values in the customer exit, I see i_t_var_range with type rrs0_t_var_range.  My strong feeling is that this parameter gets the user input, but I am unable to use it as the customer exit is not being called if I make the user to input the data.  Based on the empirical evidence, I felt that user input and customer exit can not co-exist!!  Please somebody prove me wrong and let me know how can I use the user input to process my "customer-exit" variable.  I would really appreciate any input from the BW community here.

    Hi Sameer,
    Most likely, I'm missing something, but I think that the answer is very simple.
    CASE I_VNAM.
    WHEN 'YOUR_CUSTOMER_EXIT_VAR'.
    IF I_STEP = 2. “ After selecting of input variable
    LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
    WHERE VNAM = 'USER_INPUT_VAR'.
    CLEAR L_S_RANGE.
    L_S_RANGE-LOW = LOC_VAR_RANGE-LOW(4).
    APPEND L_S_RANGE TO E_T_RANGE.
    ENDLOOP.
    ENDIF.
    ENDCASE.
    In this typical user exit coding you have a user entered value in LOC_VAR_RANGE (originally in I_T_VAR_RANGE) and you construct your user exit variable value in E_T_RANGE.
    Best regards,
    Eugene
    Message was edited by: Eugene Khusainov

  • Calling report from a form with user input parameters

    Hello,
    I am new to Oracle reports. I have an application coded in 6i. I am currently running the application in Oracle Forms Builder 9i. There are also few reports which are called from the forms. Since the application was developed in 6i, the report was called using Run_Product. The forms pass a set of user parameters to the report using the parameter list pl_id. The syntax used was Run_Product(REPORTS, 'D:\Report\sales.rdf', SYNCHRONOUS, RUNTIME,FILESYSTEM, pl_id, NULL);
    I learnt that the Run_product doesnt work in 9i and we need to use run_report_object. I have changed the code to use run_report_object and using web.show_document () i am able to run the report from the form. There are 2 parameters that need to be passed from forms to reports. The parameters are from_date and to_date which the user will be prompted to enter on running the form. In the report, the initial values for these parametes are defined. So, the report runs fine for the initial value always. But when i try to change the user inputs for the form_date and to_date, the report output doesnt seem to take the new values, instead the old report with the initial values(defined in the report) runs again.
    Can someone give me the code to pass the user defined parameters to the report from the forms? I have defined a report object in the forms node as REPTEST and defined a parameter list pl_id and added form_date and to_date to pl_id and used the following coding:
    vrepid := FIND_REPORT_OBJECT ('REPTEST');
    vrep := RUN_REPORT_OBJECT (vrepid,pl_id);
    But this doesnt work.
    Also, Should the parameters defined in the forms and reports have the same name?

    Thanks for the quick response Denis.
    I had referred to the document link before and tried using the RUN_REPORT_OBJECT_PROC procedure and ENCODE functions as given in the doc and added the following SET_REPORT_OBJECT_PROPERTY in the RUN_REPORT_OBJECT_PROC :
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_OTHER,' FROM_DATE='||:BLK_INPUT.FROM_DATE||' TO_DATE='||:BLK_INPUT.TO_DATE||' paramform=no');
    But this also dint work. Please help me understand what difference does setting paramform=no OR paramform=yes make?
    In the report, i have defined the user parameters as FROM_DATE and TO_DATE respectively so that they match the form datablock BLK_INPUT items FROM_DATE and TO_DATE.
    My WHEN_BUTTON_PRESSED trigger is as below:
    DECLARE
    report_id report_object;
    vrep VARCHAR2 (100);
    v_show_document VARCHAR2 (2000) := '/reports/rwservlet?';
    v_connect VARCHAR2 (30) := '&userid=scott/tiger@oracle';
    v_report_server VARCHAR2 (30) := 'repserver90';
    BEGIN
    report_id:= find_report_object('REPTEST');
    -- Call the generic PL/SQL procedure to run the Reports
    RUN_REPORT_OBJECT_PROC( report_id,'repserver90','PDF',CACHE,'D:\Report\sales.rdf','paramform=no','/reports/rwservlet');
    END;
    ... and the SET_REPORT_OBJECT_PROPERTY code in the RUN_REPORT_OBJECT_PROC procedure is as:
    PROCEDURE RUN_REPORT_OBJECT_PROC(
    report_id REPORT_OBJECT,
    report_server_name VARCHAR2,
    report_format VARCHAR2,
    report_destype_name NUMBER,
    report_file_name VARCHAR2,
    report_otherparam VARCHAR2,
    reports_servlet VARCHAR2) IS
    report_message VARCHAR2(100) :='';
    rep_status VARCHAR2(100) :='';
    vjob_id VARCHAR2(4000) :='';
    hidden_action VARCHAR2(2000) :='';
    v_report_other VARCHAR2(4000) :='';
    i number (5);
    c char;
    c_old char;
    c_new char;
    BEGIN
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_COMM_MODE,SYNCHRONOUS);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_FILENAME,report_file_name);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_SERVER,report_server_name);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESTYPE,report_destype_name);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESFORMAT,report_format);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_OTHER,' FROM_DATE='||:BLK_INPUT.FROM_DATE||' TO_DATE='||:BLK_INPUT.TO_DATE||' paramform=no');
    hidden_action := hidden_action ||'&report='||GET_REPORT_OBJECT_PROPERTY(report_id,REPORT_FILENAME);
    hidden_action := hidden_action||'&destype='||GET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESTYPE);
    hidden_action := hidden_action||'&desformat='||GET_REPORT_OBJECT_PROPERTY (report_id,REPORT_DESFORMAT);
    hidden_action := hidden_action ||'&userid='||get_application_property(username)||'/'||get_application_property(password)||'@'||get_application_property(connect_string);
    c_old :='@';
    FOR i IN 1..LENGTH(report_otherparam) LOOP
    c_new:= substr(report_otherparam,i,1);
    IF (c_new =' ') THEN
    c:='&';
    ELSE
    c:= c_new;
    END IF;
    -- eliminate multiple blanks
    IF (c_old =' ' and c_new = ' ') THEN
    null;
    ELSE
    v_report_other := v_report_other||c;
    END IF;
    c_old := c_new;
    END LOOP;
    hidden_action := hidden_action ||'&'|| v_report_other;
    hidden_action := reports_servlet||'?_hidden_server='||report_server_name|| encode(hidden_action);
    SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_OTHER,'pfaction='||hidden_action||' '||report_otherparam);
    -- run Reports
    report_message := run_report_object(report_id);
    rep_status := report_object_status(report_message);
    IF rep_status='FINISHED' THEN
    vjob_id :=substr(report_message,length(report_server_name)+2,length(report_message));
    message('job id is'||vjob_id);pause;
    WEB.SHOW_DOCUMENT(reports_servlet||'/getjobid'||vjob_id||'?server='||report_server_name,' _blank');
    ELSE
    --handle errors
    null;
    END IF;
    In the code - " hidden_action := hidden_action ||'&'|| v_report_other; " in the RUN_REPORT_OBJECT_PROC procedure above, how do i make sure that the v_report_other variable reflects the user input parameters FROM_DATE and TO_DATE ??? v_report_other is initialised as v_report_other VARCHAR2(4000) :=''; in the procedure. Will ensuring that the v_report_other contains the user input parameters FROM_DATE and TO_DATE ensure that my report will run fine for the input parameters?
    Thanks in advance.
    Edited by: user10713842 on Apr 7, 2009 6:05 AM

  • Asking for user input in the middle of a function

    Here's my issue.
    I need to launch and input window in the middle of a function for user input.  Before I can continue through the function I need a response back from the user first.  Psuedo code below:
    function
         function begins
         pop up window is launched to ask for user input
         function continues after users submits input
         user input from pop up window is used in function return value
    Let me know if you need more clarification but this is essentially what I'm attempting to do.

    The way actionScript works it isn’t really designed to work that way
    Is there any reason why you have to only use one function as you have written
    I think you really do need to split up your code into sections that a, set up the pop-up with  event listeners waiting for the input to be completed, trigger the pop up with user input, then have a handler function that then interprets the results of the user action.
    Trying to force the system into a closed loop while waiting will be a bad idea.
    By using a pop-up or an alert window that is set to be modal, you are effectively stopping your application doing anything else until the user input has been completed, but still not locking the app into a closed loop. Imagine what would happen if you did put the system into a closed loop, the mouse movement wouldn’t be updated, the screen wouldn’t refresh and the system wouldn’t be able to handle your user input. the reason for using async model is you are able to let the system still do all its background task (move the mouse, give inputs focus, keep the screen drawn etc) but still tell a part of your app to ‘wait for input’ before carrying on it execution of your logic
    Do you come from another programming language? Maybe one that uses less of an OOP approach? I only ask, as the method you are describing is much more like how I had to program when  I worked on computers years ago as an assembly programmer.
    In actionscript and most other modern languages and Oss you don’t have total control of the system and cant lock it into an action as you describe.
    You need to have an asynchronous approach to situations like you describe and let the system run in the back ground while you are waiting for input (or date from a server for that matter)
    Please excuse me if I am telling you things you already know.
    What exactly is your use case for this? Maybe if we knew exactly what you are working on I might be able to offer a solution that would make sense for your particular situation.
    Hope all is going well and please feel free to contact me if you are stuck

  • Taking user input in a PL/SQL block

    Can someone tell me if it is possible to to take user input from within a PL/SQL loop? I mean I want that for each iteration in the loop, the program first take user input, and then based on that input, it perform specific operations. Then it repeats this process for each subsequent iteration of loop.
    If it is not possible in PL/SQL, is there any other alternative?
    Thanks.

    > I'm afraid I have no idea how to get the server to ask questions of the user,
    especially when it essentially operates in a kind of batch mode.
    Yep. To expand a tad on what Hans mentioned here.
    To accept input, the process needs to be able to read from this input device. Let's make it a keyboard. The PL/SQL process needs to read keyboard input.
    The keyboard is attached to a PC 1000km away in a branch office. The Oracle server process, running on a server in the data centre, executes this PL/SQL code.
    So now this PL/SQL process has to automagically hack its way across the network. It needs to remove the keyboard plug from that client PC. It somehow must get that keyboard rewired, across that 1000km, into the server platform at the data centre. And only then can the Oracle server process running that PL/SQL code read from that keyboard input device and accept user input.
    It is important, when developing in Oracle, to grasp just what client-server is and how it works. And not to confuse something like a SQL*Plus Client Process (submitting PL/SQL code) with the Oracle Server Process (parsing and executing that submitted PL/SQL code).

  • How to write table name in SQL according to the user input

    hi
      i want to select data from a table , and the table name, field name is input by the user, for example, user input table name T1, field name F1 and i want to construct a SQL like select F1 into a_var from T1 . how does the SQL statement written? thanks for your advice.

    hi
    for ur requirement u should go for field sysmbols...
    dynamic internal tables..
    u can chk this....
    TYPE-POOLS : slis.
    PARAMETERS : p_struc LIKE dd02l-tabname.
    DATA : it_fieldcat TYPE lvc_t_fcat,
            t_output TYPE REF TO data .
    FIELD-SYMBOLS: <t_output> TYPE table ,
                   <wa_output> TYPE ANY,
                   <fval> TYPE ANY.
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      I_BUFFER_ACTIVE              = I_BUFFER_ACTIVE
       i_structure_name             = p_struc
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_BYPASSING_BUFFER           = I_BYPASSING_BUFFER
      I_INTERNAL_TABNAME           = I_INTERNAL_TABNAME
      CHANGING
        ct_fieldcat                  = it_fieldcat
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3
    IF sy-subrc <> 0.
    MESSAGE i000(bctrain) WITH 'MERGE FAILED'.
    *ELSE.
    MESSAGE i000(bctrain) WITH 'MERGE SUCCESS'.
    ENDIF.
    CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
    ASSIGN t_newline->* TO <fs_dyntable>.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
       I_STYLE_TABLE             =
        it_fieldcatalog           = it_fieldcat
       I_LENGTH_IN_BYTE          =
      IMPORTING
        ep_table                  = t_output
       E_STYLE_FNAME             =
      EXCEPTIONS
        generate_subpool_dir_full = 1
        OTHERS                    = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ASSIGN t_output->* TO <t_output>.
    SELECT * up to 10 rows FROM
       (p_struc)  INTO
       CORRESPONDING FIELDS OF
       TABLE <t_output>.
    *write : / 'dynamic table created'.
    LOOP AT <t_output> ASSIGNING  <wa_output>.
      DO.
        ASSIGN component sy-index of structure <wa_output> to <fval>.
        IF sy-subrc <> 0.
          WRITE : /.
          EXIT.
        ELSE.
          WRITE : <fval>.
        ENDIF.
      ENDDO.
    ENDLOOP.
    Message was edited by:
            Premalatha G

  • How to use Pl/sql block to edit check user input

    Hi,
    Please advise on PL/SQL Block code that could be used to Check User input from within a Loop and proceed conditionally based upon User Supplied compliant Input. Thanks in advance.

    Hi,
    yakub21 wrote:
    You could use the ACCEPT to get user input and then assign the input to a variable that could then be verified.
    I believe that anything is possible because we don't yet have proof that it is not!
    I do have code that can accept user input. Is it PL/SQL code? Sybrand was clearly talking about PL/SQL:
    sybrand_b wrote:
    Pl/sql is for server side code, it is not a front end tool, and it is incapable of the functionality you describe.If you do have PL/SQL code that accepts user input, please post an example. A lot of people, including me, would be very interested.
    Pass the user-input value to a variable and then assign that value to another variable from within a Declare of a PL/SQL Block.
    The opportunity here is to figure a way to loop with user input until desired input is entered by the user before proceeding with the code. I'm using PL/SQL Block because I don't want the code to persist. I just want to run it as part of database configuration procedure. ThanksIt sounds like you're talking about SQL*Plus, which is a very poor tool for looping or branching.
    It's possible, but it's not pretty. The following thread shows one way of looping in SQL*Plus:
    Re: How to give the different values to runtime parameters in a loop?

  • Accepting user input and executing a PL/SQL block using it

    Hi All,
    I am working on a requirement wherein I have to accept values from the user for the various arguments to be supplied to a PL/SQL block and then execute it using these values. For now, I am using the following logic:
    PROMPT Enter value for the Category
    ACCEPT cCategory CHAR PROMPT 'Category:'
    DECLARE
    cCategry CHAR(1) := '&cCategory';
    BEGIN
    DBMS_OUTPUT.PUT_LINE('The value of the Category as entered by you is' || cCategory);
    END;
    PROMPT Press y if you want to proceed with the current values, or press n if you want to re-enter the values
    ACCEPT cChoice CHAR Prompt 'Enter y or n:'
    DECLARE
    cCategry CHAR(1) := '&cCategory';
    sErrorCd VARCHAR2(256);
    sErrorDsc VARCHAR2(256);
    BEGIN
    IF '&cChoice' = 'y'
    THEN
    DBMS_OUTPUT.PUT_LINE('Starting with the process to execute the stored proc');
    --- schema1.package1.sp1(cCategry, sErrorCd, sErrorDsc);
    --- DBMS_OUTPUT.PUT_LINE('Error Code :' || sErrorCd);
    --- DBMS_OUTPUT.PUT_LINE(' Error Description :' || sErrorDsc);
    ELSIF '&cChoice' = 'n'
    THEN
    Now I want that the proc again start executing in the loop from the 1st line i.e. PROMPT Enter value for the Category. However i see that this is not possible to do that PROMPT statements and accepting user inputs execute only on the SQL prompt and not inside a PL/SQL block.
    Is there an alternate method to establish this?
    Thanks in advance.

    Hi,
    You can write a genric procedure to achive the desired output. Pass 'Y' or 'N' in the procedure.
    Call that procedure in simple pl/sql block during runtime using substituton operator.
    For ex
    create or replace procedure p1(category_in in varchar2)
    IS
    BEGIN
    if (category_in='Y')
    then
    prcdr1()
    /** Write your logic here ***/
    elsif(category_in='N') then
    prcdr2()
    /** write your logic here***/
    end if;
    exception
    /***write the exception logic ***/
    end p1;
    Begin
    p1('&cat');
    end;Regards,
    Achyut K
    Edited by: Achyut K on Aug 6, 2010 5:20 AM

  • User Input in Dos Programs

    Hi, sorry for such as newbie type question but iv just started programming in Java (so im used to the simpleness of vb). I have a simple Java Dos program, and i understand the system. functions but was wondering how i could get the > user input prompt. any help would be greatly appreciated. thanks!
    WC

    See if this isn't what you want:
    import java.io.*;
    // This program displays the user's input
    public class GetInput {
         public static void main(String[] args) throws IOException {
              // This is how we set things up to read lines of text from the user.
              BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
              // Loop forever
              for(;;) {
                   // Display a prompt to the user
                   System.out.print("Type something> ");
                   // Read a line from the user
                   String line = in.readLine();
                   // If the input is null or if the user types �quit�, then quit
                   if (line.equals("") || line.equals("quit"))
                         break;
                   try {
                        System.out.println(line);
                   // If anything goes wrong, display a generic error message
                   catch(Exception e) {
                        System.out.println("Invalid Input");
    }

  • Selection Screen - User input to select option only through f4 help,

    Hi..
    In case of selection screen,  I need selection screen such a that user input must be through search help not manual entry is allowed/ possible

    TYPES:BEGIN OF ty,
          field1 TYPE char01,
          END OF ty.
    DATA:it TYPE TABLE OF ty,
         wa TYPE ty.
    data:v_var type c.
    select-options:so for v_var.
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF screen-name = 'SO-LOW'  .
          screen-input = 0.
          MODIFY SCREEN.
        ENDIF.
        IF screen-name = 'SO-HIGH'  .
          screen-input = 0.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR so-low.
      CLEAR it[].
      wa-field1 = 'A'.
      APPEND wa TO it.
      wa-field1 = 'B'.
      APPEND wa TO it.
      CLEAR wa.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield    = 'FIELD1'
          dynpprog    = sy-cprog
          dynpnr      = sy-dynnr
          dynprofield = 'SO-LOW'
          value_org   = 'S'
          display     = 'F' "F = Force
        TABLES
          value_tab   = it[].
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR so-high.
      CLEAR it[].
      wa-field1 = 'A'.
      APPEND wa TO it.
      wa-field1 = 'B'.
      APPEND wa TO it.
      CLEAR wa.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield    = 'FIELD1'
          dynpprog    = sy-cprog
          dynpnr      = sy-dynnr
          dynprofield = 'SO-HIGH'
          value_org   = 'S'
          display     = 'F' "F = Force
        TABLES
          value_tab   = it[].

  • How to write customer exit in my BI query to get (current fiscal quarter) and (current fiscal quarter - 1 ) without user input

    Hi all,
    I need your help how to write customer exit in my BI query to get (current fiscal quarter) and (current fiscal quarter - 1 ) without user input.
    in my query info object is 0CALQUARTER and variable is ZFIS_QTR.
    in 0CALQUARTER fiscal quarter stored in 201301,201302,201303,201304 and 201401 format, for current fiscal quarter 201401 and (current fiscal quarter - 1 ) would be 201304.
    please replay ASAP to deliver the report to client.
    thanks in advance.
    -- Rakesh Nagpure

    I am Getting the same error for both the codes that i have written...
    Do i Need to write sth else in the code...
    Code:
    WHEN 'ZVLIVELEASES'.
      IF I_STEP = 2.
            L_DATE = SY-DATUM.
            SELECT * FROM "DSO_ACTIVE_TABLE"
                INTO TABLE ITAB_LL where "EXPIRY_DATE" > L_DATE.
            LOOP AT ITAB_LL INTO WA_LL.
            CLEAR l_s_range.
            l_s_range-sign = 'I'.
            l_s_range-opt = 'EQ'.
            l_s_range-low = WA_LL-"EXPIRY_DATE".
           APPEND L_S_RANGE TO E_T_RANGE.
            ENDLOOP.
       ENDIF.
    Error: Error for variable in customer enhancement ZLIVELEASES

Maybe you are looking for

  • Crashes when I try to access Quicktime Videos

    Safari is crashing when I try to access certain Quicktime videos. When I run the commercial videos on the Apple iPad page or try to download the trailer for the movie Thor on the iTunes Movie Trailers page Safari crashes. In addition, when I try to a

  • Create a DMS Document

    Hi All, I have a requirement to upload  document from the application server to the DMS. We have a standard BAPI available for creating a document in DMS i.e. BAPI_DOCUMENT_CREATE2 but I am not able to attach  application server file along with this.

  • Regarding MOSD 454811.1 ( Upgrading OracleAS 10g Forms and Reports in Oracl

    I Installed R12.1.1 and now upgrading it to 12.1.3. I am following document 1080973.1. As per MOSD 1080973.1, We need to upgrade Upgrading to the Latest OracleAS 10g 10.1.3.x Patch Set in Oracle E-Business Suite Release 12. Currently Version is 10.1.

  • My database not listed at SQL data source in Web Expression 4

    Can anyone help me out? Am not sure whether this is the correct place for my problem. I set up SQL Server 2005. Created a database named "employee" and a table under it "emp_info" I tried to connect it from Microsoft Web Expression 4 through SQL Data

  • Drag event handling in JFXPanel has performance implications with expensive event handlers

    We have a drag event handler that is a little expensive, takes something like 20ms. The respective code must be run in a synchronous manner however. That is no problem in a pure JavaFX environment, as less drag events are created when CPU load is hig