Accepting input in PL/SQL

My requirement is Accepting Input from KeyBoard in the LOOP PL/SQL Block.
Becasue of PL/SQL constraints I am not able to accept value in the loop
except the first time. Please advice me is there any other options in PL/SQL
to accept input from the keyboard in the loop.

I'm not sure how you can do this, perhaps someone else does.
I suggest writing a Shell Script or Batch file which accepts the input and then runs SQL*Plus and your script with arguments.
Good Luck,
Eric Kamradt

Similar Messages

  • Accepting dynamiv user input using PL/SQL

    Hi,
    I need to accept dynamic number of user input values.
    What i need is i will enter the number of employees to be created.
    If i enter 2 then i need to dynamically accept 2 employee details.
    DECLARE
       v_emp_cnt    NUMBER;
       v_emp_id     VARCHAR2 (15);
       v_emp_name   VARCHAR2 (200);
    BEGIN
       v_emp_cnt := &v_emp_cnt;
       FOR i IN 1 .. v_emp_Cnt
       LOOP
          DBMS_OUTPUT.PUT_LINE('INSIDE LOOP');
          v_emp_id := &v_emp_id;
          v_emp_desc := &v_emp_Desc;
          INSERT INTO emp_details (process_id,
                                            column11,
                                            column12,
                                            column13)
            VALUES   ('EMPLOYEES',
                      'EMP-' || i,
                      v_emp_id,
                      v_emp_desc);
       END LOOP;
    END;
    /Can anyone let me know if this is the right approach to acheive my requirement. Please suggest alternatives.
    Thanks
    Vamsi Krishna

    PL/SQL is a server-side language-- it doesn't have the ability to interact with a user. A client application such as SQL*Plus, can both prompt for input and submit SQL statements to the database. It's probably possible to hack together a SQL*Plus script that could do something like what you appear to be looking for but using SQL*Plus for this sort of thing would generally be the wrong architectural solution. You'd generally be better off with a small shell script that prompted the user for data and then called a stored procedure.
    Justin

  • Using accept command within PL/SQL block

    Hi all i have a following Pl/SQL block which ia =as follows :-
    declare
    begin
    ...certain statements using while
    end;
    i need to take the user input using accept
    if i put the accept stmt betweeen begin and end i am getting following error :-
    accept myv number default 10 prompt 'Enter a number: '
    ERROR at line 48:
    ORA-06550: line 48, column 8:
    PLS-00103: Encountered the symbol "MYV" when expecting one of the following:
    := . ( @ % ;
    ORA-06550: line 48, column 30:
    PLS-00103: Encountered the symbol "PROMPT" when expecting one of the following:
    * & = - + ; < / > at in is mod remainder not rem
    <an exponent (**)> <> or != or ~= >= <= <> and or like
    between || multiset member SUBMULTISET_
    Let me know how can i include accept stmt in Pl/SQL block
    Thanks

    You're missing a fundamental concept here.
    PL/SQL = embedded 4GL programming language in the Oracle database.
    SQL*Plus = CLI (Command Line Interface) client for an Oracle database.
    The ACCEPT command is a SQL*Plus command. Not a PL/SQL command.
    The PL/SQL engine sits inside the Oracle Server Process that services your client (SQL*Plus) session. That server process does not know who/what/where you are as a physical client. It does not know what platform and o/s you are using. It does not know what client you are using. It is after all a server process and should not and need not to know that.
    Nor can that Oracle Server Process running on the Data Server Platform access you client's hard drive, keyboard, mouse, screen, printer and so on.
    PL/SQL running in this Oracle Server Process therefore cannot read your keyboard to accept end-user input. PL/SQL therefore cannot write data to your screen.
    You need to make a clear distinction between SQL*Plus (a client) and Oracle PL/SQL (the server).

  • PC as a bluetooth Device and accept input from other devices

    I need to set my PC up as a bluetooth device by use of a bluetooth dongle connected to my PC. I need to have a program running on my PC that will detect other bluetooth devices and connect with them, accept input from them. Please help me do this. anyone got code for this? Thank you a gazillion in advance !! :)

    There's no way to do is with standard Java as far as i know. You'll have to use JNI to use native libraries.

  • BAdI: Field LIFNR not ready to accept input (Change will not be adopted)

    Dear Guruz...\
    given below is the warning with message number
    BAdI: Field LIFNR not ready to accept input (Change will not be adopted)
    Message no. MIGO050
    while i am trying to enter the batch name for removal for scrapping and clicking check this warning is being displayed.
    KIndly if you are having any other solutions in customizing other than using BADI... pl discuss..

    Hi,
    You must have some kind of BAdI (probably MB_MIGO_ITEM_BADI och MB_MIGO_BADI) that places a value in the field LIFNR (vendor). However, this field is not open for entry and hence SAP ignores the value provided by the BAdI.
    Either correct your BAdI so it doesn't populate the field when the latter is not available (e.g. based on the mvt /special stock ind.) or live with this warning message - it is harmless.
    BR
    Raf

  • How to prompt for user input in PL/SQL

    How do I prompt for user input in PL/SQL?
    I am writing a piece of code where the user may choose, by clicking either of three buttons on an alert, to have the system assign a value to a variable, to input a value or to do neither?
    If the user chooses to input the value I want to update a set of database fields with the value.
    I have thought about showing a view where the value may be entered into a field displayed on that view. The value will be assigned to the variable by the user clicking a command button. The question I have in this case though, is whether, after the command button is clicked, control will be passed back to the code that called the view in the first place?
    Edited by: desgordon on Sep 3, 2008 10:33 AM

    desgordon wrote:
    How do I prompt for user input in PL/SQL?
    I am writing a piece of code where the user may choose, by clicking either of three buttons on an alert, to have the system assign a value to a variable, to input a value or to do neither?OK, you're doing that in Forms...
    >
    If the user chooses to input the value I want to update a set of database fields with the value.Write PL/SQL procedure for this purpose...
    >
    I have thought about showing a view where the value may be entered into a field displayed on that view. The value will be assigned to the variable by the user clicking a command button. The question I have in this case though, is whether, after the command button is clicked, control will be passed back to the code that called the view in the first place?Not clear what you mean with view?
    But if you call your procedure in that button then yes 'control will be passed back to the code'...
    Cheers!
    Edited by: Faust on Sep 3, 2008 7:57 PM
    Too slow...

  • Server 2012 not accepting inputs either via console or RDP

    Hello Experts,
    I have a server 2012 standard running in a physical box with 3 virtual machines running in hyper-v session. For sometime now, i have been running into strange issues where it does not accept input. I tried via RDP, console; neither method worked. It still
    holds AD and file server role. It was all working good and driving me into issues for some time now.
    It does not accept inputs via keyboard or mouse either from console or RDP. All resources such as file share, virtual machine are accessible from network. I can logon to server via console or RDP for 3 to 5 min right after server has been hard restarted
    and again it stops accepting inputs.
    Can someone help me out work around this issue as i am new to server 2012 and not sure what goes in error.
    Thanks.

    Hi koneska,
    Did you install any software recently? Please try to unistall the new installed software and if you have AV soft disable the AV soft then try again.
    Regards.
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Help on writing pl/sql stored procedure to accept input in xml format

    Hi All,
    I need to write a pl.sql stored procedure which would be getting the input as an xml.
    The requirement is that xml data recieved in below fashion needs to be inserted to 3 different tables.
    The tags under the root node directly needs to be inserted into Table1
    The tags under the first element of the root node needs to be inserted into Table2
    Can anybody help me on how to write a stored procedure which could take up the below xml as input and insert the data received into 3 different tables.
    Any sample code.pointers to achieve this could be of great help.
    The structure of the xml would be as follows:
    <AssemblyProduct>
    <AssemblyHeader>
    <Name></Name>
    <AssemblyId></AssemblyId>
    <ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
    <ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
    <ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
    </AssemblyHeader>
    <AssemblyHeader>
    <Name></Name>
    <AssemblyId></AssemblyId>
    </AssemblyHeader>
    <AssemblyHeader></AssemblyHeader>
    <ApplicationId></ApplicationId>
    <ApplicationName></ApplicationName>
    <ApplicationValidFrom></ApplicationValidFrom>
    <ApplicationValidTo></ApplicationValidTo>
    </AssemblyProduct>

    Well you could write your procedure to accept a parameter of XMLTYPE datatype and then use that value in a query inside the procedure to break the data up as required using something like XMLTABLE e.g.
    -- Nested repeating groups example:
    WITH t as (select XMLTYPE('
    <RECSET>
      <REC>
        <COUNTRY>1</COUNTRY>
        <POINT>1800</POINT>
        <USER_INFO>
          <USER_ID>1</USER_ID>
          <TARGET>28</TARGET>
          <STATE>6</STATE>
          <TASK>12</TASK>
        </USER_INFO>
        <USER_INFO>
          <USER_ID>5</USER_ID>
          <TARGET>19</TARGET>
          <STATE>1</STATE>
          <TASK>90</TASK>
        </USER_INFO>
      </REC>
      <REC>
        <COUNTRY>2</COUNTRY>
        <POINT>2400</POINT>
        <USER_INFO>
          <USER_ID>3</USER_ID>
          <TARGET>14</TARGET>
          <STATE>7</STATE>
          <TASK>5</TASK>
        </USER_INFO>
      </REC>
    </RECSET>') as xml from dual)
    -- END OF TEST DATA
    select x.country, x.point, y.user_id, y.target, y.state, y.task
    from t
        ,XMLTABLE('/RECSET/REC'
                  PASSING t.xml
                  COLUMNS country NUMBER PATH '/REC/COUNTRY'
                         ,point   NUMBER PATH '/REC/POINT'
                         ,user_info XMLTYPE PATH '/REC/*'
                 ) x
        ,XMLTABLE('/USER_INFO'
                  PASSING x.user_info
                  COLUMNS user_id NUMBER PATH '/USER_INFO/USER_ID'
                         ,target  NUMBER PATH '/USER_INFO/TARGET'
                         ,state   NUMBER PATH '/USER_INFO/STATE'
                         ,task    NUMBER PATH '/USER_INFO/TASK'
                 ) y
       COUNTRY      POINT    USER_ID     TARGET      STATE       TASK
             1       1800          1         28          6         12
             1       1800          5         19          1         90
             2       2400          3         14          7          5And then you can extract and insert whatever parts you want into whatever tables as part of the procedure.

  • Accept input from Shell script in sql*plus

    Hey! Guys..
    i need the following info.
    I am running a shell script from sql*plus. I need to accept a value from shell script into my .sql file.
    thanks..
    Harsh.

    prompt for input, pass to another shell
    # contract_status_prompt.sh
    read udate?"Enter week-ending date in format dd-mmm-yyyy: "
    contract_status_update.sh $udate >$FDWLOG/current/contractstatusupdate`date +%d%h%y`.log
    echo `date`
    # End contract_status_prompt.sh
    Read the variable passed and use in SQLPlus:
    # contract_status_update.sh
    echo "Running contract_status.sh"
    echo "create records for contract_status"
    echo `date`
    echo " "
    echo " date used is "; print $1
    echo " "
    sqlplus <<exit
    @$FDWSQL/sqlparms
    set time on
    prompt *** Set contract_status_period ***
    update contract_status_period
    set period_date = '$1';
    commit;
    exit
    etc.

  • Accept input from commandline

    Hi,
    I have an sql file with multiple accept statements.
    I would like to run this script from the DOS commandline, and supply the script with values for the accept statements.
    How can I do this? (I do not want to alter the sql-file for this)
    Regards,
    HJH

    I have an sql file with multiple accept statements.
    I would like to run this script from the DOS commandline, and supply the script with values for the accept statements.
    How can I do this? (I do not want to alter the sql-file for this)Create text file and put one value per line in proper order. For example, you have the following script script.sql :
    accept V1 char prompt 'Enter value for V1:'
    accept V2 char prompt 'Enter value for V2:'
    prompt Your input : &V1 &V2
    exitText file values.txt can be the following:
    ABC
    DEFThen use the following syntax:
    sqlplus.exe /nolog @script.sql < values.txt

  • User input from pl/sql

    How could I get user input from a pl/sql block?
    Hope that somebody can help me.
    thanx
    Amelio.

    There is a package DBMS_LOCK that has a SLEEP routine, which suspends the session for a given period of time (in seconds).
    However, you can only pause the procedure and not accept user input into the procedure during the pause.
    syntax: DBMS_LOCK.SLEEP(1) ;
    I need only to run an 'pause' or something like that within a pl/sql block. Do you know if it's possible? Thanks.

  • Hiding the users ACCEPT input

    I am developing a report at the moment that asks for user input via an ACCEPT statement. Unfortunately, when the report is shown on the screen i am also shown this:
    old   6:        and     c.customer_id = '&customer_id'
    new   6:        and     c.customer_id = '0001'Are there any techniques to hide this because it has not value to the report itself.

    Maybe SET VERIFY OFF :
    SQL> select ename,sal from emp where empno = &1;
    Enter value for 1: 7902
    old   1: select ename,sal from emp where empno = &1
    new   1: select ename,sal from emp where empno = 7902
    ENAME             SAL
    FORD             3000
    SQL> set verify off
    SQL> /
    Enter value for 1: 7902
    ENAME             SAL
    FORD             3000
    SQL>                                                             

  • [Interface] - Passing variety parameters/input to PL/SQL report

    Hi,
    I've the PL/SQL report which can allow passing in the parameter, i use '&'.
    the report is given to the end user who do not have the IDE for PL/SQL. the machanism of the report is generated into the spool file and import into excel format.
    now i am wondering how to create a tool using SQL or PL/SQL to allow the end user to choose the parameter(s) dynamically and passing into the PL/SQL to generate the report based on the input selected.
    the parameters like below:
    package code :
    week no :
    year :
    department :
    all the above parameters, the data would be selected from the existing lookup table. the user is allow to select more than 1 input for specified parameter for instance i want to spool report for week 1 until week 5.
    pls advise any solution on this topic. thanks

    hi scoot,
    thank for reply.
    yep, i'm using sql*plus and also sql navigator 4.0 .
    the user don't have the software to interact. i'm thinking of build an simple interface using VB and passing in the parameter then initiate the sql*plus to run the program in background mode.
    but if you have any other solution which not need to use other software to wirte such program , pls let me know immediately. thank

  • Table Control[Accept Input Only] - "ENTER" Key

    Hi Folks,
    I'm reviving this unanswered thread in relation to table control: when the user press enter, all the values entered disappear.
    [url]Re: Table control (Enter key)[url]
    I have a table control that accepts "ONLY" input, meaning to say, there will be no pre-loading of data in the PBO, so it will loop through the table control itself instead of looping from an internal table.
    Issue: Whenever I press "ENTER" in any column/row of my table control, ALL the values I entered disappear.
    PBO:
    PROCESS BEFORE OUTPUT.
      MODULE CLEAR_OKCODE.
      MODULE LOAD_TABLECTRL.
      LOOP WITH CONTROL TC_DATA.
        MODULE READ_DATA.
      ENDLOOP.
    module READ_DATA output.
      READ TABLE T_DATA INTO WA_DATA INDEX TC_DATA-current_line.
      data : line_count type i.
      "to increase the number of lines in table control dynamically
      describe TABLE t_data lines line_count.
      TC_DATA-lines = line_count + 10.
    endmodule. 
    PAI:
    PROCESS AFTER INPUT.
      LOOP WITH CONTROL TC_DATA.
        MODULE MODIFY_DATA.
      ENDLOOP.
    module MODIFY_DATA input.
    WHEN 'CREATE'.
      "subroutines are here, etc.
    WHEN 'DELETE'.
    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
    endmodule.
    In my ABAP Debug, the value of SY-UCOMM is BLANK whenever I press Enter.
    Thanks.

    Hi
    Your code seems to be rght only the MODIFY statament is useless:
    module READ_DATA output.
      READ TABLE T_ID_CHECK INTO WA_ID_CHECK INDEX TC_ID-current_line.
      IF SY-SUBRC EQ 0.
        ZQID_CHECK-WERKS = WA_ID_CHECK-WERKS.
        ZQID_CHECK-MATNR = WA_ID_CHECK-MATNR.
        ZQID_CHECK-LICHA = WA_ID_CHECK-LICHA.
        ZQID_CHECK-LIFNR = WA_ID_CHECK-LIFNR.
      ELSE.
        CLEAR ZQID_CHECK.
      ENDIF.
    endmodule.
    Now before LOOP of PBO try to set the lines of table control to be display, I've created this report on my system and it works fine:
    .CONTROLS T_CTRL TYPE TABLEVIEW USING SCREEN 100.
    DATA: BEGIN OF ITAB OCCURS 0,
              WERKS LIKE MARC-WERKS,
              MATNR LIKE MARC-MATNR,
              LIFNR LIKE LFA1-LIFNR,
          END   OF ITAB.
    DATA: WA LIKE ITAB.
    START-OF-SELECTION.
      DO 4 TIMES.
        ITAB-WERKS = '5010'.
        ITAB-MATNR = '1234567890'.
        ITAB-LIFNR = '0000000001'.
        APPEND ITAB.
      ENDDO.
      CALL SCREEN 100.
    PROCESS BEFORE OUTPUT.
      MODULE SET_T_CTRL.
      LOOP WITH CONTROL T_CTRL.
        MODULE READ_DATA.
      ENDLOOP.
    PROCESS AFTER INPUT.
      LOOP WITH CONTROL T_CTRL.
        MODULE MODIFY_DATA.
      ENDLOOP.
    MODULE SET_T_CTRL OUTPUT.
      DESCRIBE TABLE ITAB LINES T_CTRL-LINES.
    ENDMODULE.                 " SET_T_CTRL  OUTPUT 
    MODULE READ_DATA OUTPUT.
      READ TABLE ITAB INDEX T_CTRL-CURRENT_LINE.
      IF SY-SUBRC = 0.
        MOVE-CORRESPONDING ITAB TO WA.
      ELSE.
        CLEAR WA.
      ENDIF.
    ENDMODULE.                 " READ_DATA  OUTPUT
    MODULE MODIFY_DATA INPUT.
      MODIFY ITAB FROM WA INDEX T_CTRL-CURRENT_LINE.
      IF SY-SUBRC NE 0.
        CHECK NOT WA IS INITIAL.
        APPEND WA TO ITAB.
      ENDIF.
    ENDMODULE.                 " MODIFY_DATA  INPUT

  • How to bind/pass multiple input parameters to sql query in BPEL Process

    Hi,
    I have a requirement to invoke a query on a database table to fetch the records based on the few input values or bind variables?
    I have created a Partner link using the DBAdapter service and have used custom SQL, how can i bind and pass multiple bind/input parameters for these queries.
    foreg: if i have to query employee records based on name , desgination and age, these three params would be my input parameter that i will pass when i invoke the BPEL process, bow how can i pass these parameters to the partner link using DBADAPTER service.
    Please help
    Regards

    If the parameter-value is not known beforehand and cannot be determined based on the process instance data at that time, there are 2 options. Either invoke the PL/SQL procedure you named using a DB adapter service to get the value and pass it to the other DB adapter service. Or create a single service (e.g. PL/SQL procedure) that determines the parameter value, executes the query and returns the result. However, this is more a design issue. Does it makes sense to combine these actions in a separate service and use it or are these actions not related? You furthermore state that additional (DB adapter) services make the process heavier. Do you have strict requirements on the time process-instances may run or other such requirements? If not, I think the design-choice on whether combining these actions in a single service should have more priority.

Maybe you are looking for

  • Curve 8900 won't view surveilence cameras correctly

    Hi! I am a locksmith with Carl's Lock Shop in Co. Spgs, CO. We view a particular web site with our shop cameras in order to sell our services... The web site is www.videoalert.net You will automatically be re-directed to thier mobile site... should s

  • Start up problem-white Apple screen 'freeze'

    Yesterday morning we had a power outage and the Mac went off, of course, but I do have one of those Apple surge protector 2 plug boards.  After the power company fixed it the computer came back on OK, I used it in the normal way, then I shut it down

  • Quicktime movie showing as 0:00 seconds

    I'm using Keynote 08, OS X 10.4.11, and Quicktime 7.5, and when I try to import .avi or .mov files, nothing works. The first frame is displayed, but nothing more. When I click on the media icon, it shows that the movies are 0:00 seconds long. I alrea

  • How to create a sequence using Toplink for DUAL table

    Hi All, How do I create below sequence using TOPLINK CREATE sequence my_seq start WITH 1; Regards, Dheeraj

  • DVD player won't work on OSX 10.9.1

    When I loaded OS X 10.9.1, I am now unable to play videos on my MacBook Pro.  Is there any updates so I can get it to work?