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).

Similar Messages

  • A question about input values inside PL/SQL block

    Dear all,
    I would appreciate if you could kindly help me with this question.
    Consider the following code.
    DECLARE
      myvar1 NUMBER;
      myvar2 NUMBER;
      myvar3 NUMBER;
    BEGIN
      myvar1 := &1;
      myvar2 := &2;
      myvar3 := &3;
      DBMS_OUTPUT.put_line('myvar1 = ' || myvar1);
      DBMS_OUTPUT.put_line('myvar2 = ' || myvar2);
      DBMS_OUTPUT.put_line('myvar3 = ' || myvar3);
    END;
    /This program reads three values as input and prints them. However, I noticed that if instead of writing
    myvar1 := &1;
    myvar2 := &2;
    myvar3 := &3;I write
    myvar1 := '&1';
    myvar2 := '&2';
    myvar3 := '&3';The program will have very same result. I would like to know whether there is a semantic difference between both syntax,
    that is, is there any difference between for example &myvar1 and 'myvar1'?
    Thanks in advance,
    Dariyoosh

    Try this
    CREATE TABLE test_sem  (x VARCHAR2(10), y NUMBER)
    INSERT INTO test_sem VALUES ('A',1);
    INSERT INTO test_sem VALUES ('B',1);
    INSERT INTO test_sem VALUES ('C',1);
    INSERT INTO test_sem VALUES ('D',1);
    SELECT * FROM test_sem WHERE x='&1' --OK
    SELECT * FROM test_sem WHERE x=&1 -- error not a valid number
    SELECT * FROM test_sem WHERE y=&1 -- ok
    SELECT * FROM test_sem WHERE y='&1' -- ok since numbers can be converted to strings'&1' is for characters &1 for numbers;
    You can verify form above test case
    Regards,
    Bhushan

  • 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.

  • Selecting user input from Select option into smart form

    Hi,
    when i use parameter then i wil show company code in smart-form output
    but when i use  select option then its throwing error parameter specified here is different
    what should i do in this case i want to design a big select option screen for taking user input
    REPORT  ZMM.
    TABLES BSEG.
    DATA : V_FORMNAME TYPE TDSFNAME VALUE 'ZPUR_REG',
           V_FMNAME TYPE RS38L_FNAM.
    *PARAMETERS SO_BUKRS TYPE BUKRS.
    SELECT-OPTIONS : SO_BUKRS FOR BSEG-BUKRS.
    DATA : Z_CONTROL TYPE SSFCTRLOP,      "Smart Forms: Control structure
            Z_OPTIONS TYPE SSFCOMPOP.      "SAP Smart Forms: Smart Composer (transfer) options.
    MOVE 'X' TO : Z_control-no_dialog,        "SAP Smart Forms: General Indicator
                   Z_options-tdnewid,          "New Spool Request (Print Parameters)
                   z_control-PREVIEW.         "Print preview
    MOVE 'LP01' TO Z_options-tddest.         "Spool: Output device
    MOVE space  TO Z_options-tdimmed.        "Print Immediately (Print Parameters).
    MOVE 'PRINTER' TO Z_control-device.      "Output device
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        FORMNAME = V_FORMNAME
      IMPORTING
        FM_NAME  = V_FMNAME.
    CALL FUNCTION V_FMNAME
      EXPORTING
        CONTROL_PARAMETERS = Z_CONTROL
        OUTPUT_OPTIONS     = Z_OPTIONS
        USER_SETTINGS      = ''
        BUKRS              = SO_BUKRS.
    pls help me in this regards.
    ketan..

    hi
    thnx for your reply
    can u pls elaborate in my code
    now i changed code   BUKRS    = SO_BUKRS-low.
    either i can give low or high but how to select from range
    REPORT  ZMM.
    TABLES BSEG.
    DATA : V_FORMNAME TYPE TDSFNAME VALUE 'ZPUR_REG',
           V_FMNAME TYPE RS38L_FNAM.
    *PARAMETERS SO_BUKRS TYPE BUKRS.
    SELECT-OPTIONS : SO_BUKRS FOR BSEG-BUKRS.
    DATA : Z_CONTROL TYPE SSFCTRLOP,      "Smart Forms: Control structure
            Z_OPTIONS TYPE SSFCOMPOP.      "SAP Smart Forms: Smart Composer (transfer) options.
    MOVE 'X' TO : Z_control-no_dialog,        "SAP Smart Forms: General Indicator
                   Z_options-tdnewid,          "New Spool Request (Print Parameters)
                   z_control-PREVIEW.         "Print preview
    MOVE 'LP01' TO Z_options-tddest.         "Spool: Output device
    MOVE space  TO Z_options-tdimmed.        "Print Immediately (Print Parameters).
    MOVE 'PRINTER' TO Z_control-device.      "Output device
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        FORMNAME = V_FORMNAME
      IMPORTING
        FM_NAME  = V_FMNAME.
    CALL FUNCTION V_FMNAME
      EXPORTING
        CONTROL_PARAMETERS = Z_CONTROL
        OUTPUT_OPTIONS     = Z_OPTIONS
        USER_SETTINGS      = ''
        BUKRS              = SO_BUKRS-low.
    ketan..

  • Showing user input in a JFrame

    i need to be able to take user-given values and display them in a JFrame. i'm testing the input of a sudoku puzzle. i have a sudokuComponent and a sudokuViewer.
    i'm confused as to where to place my code that will do the process of taking user input (via Scanner class) and testing it for certain conditions.
    i dont think figuring out the testing conditions should be hard, i'm just having trouble with getting the input read in correctly and a way of getting it displayed on the JFrame which displays the sudoku puzzle with the values so far.
    i was given a tip that said i needed to use the method repaint() of JFrame to see the updates.
    SUDOKUCOMPONENT
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Rectangle;
    import java.awt.geom.Line2D;
    import javax.swing.JPanel;
    import javax.swing.JComponent;
    import java.util.Scanner;
    public class SudokuComponent extends JComponent
         public void paintComponent(Graphics g)
              //recover graphics2s
              Graphics2D g2 = (Graphics2D) g;
              //Construct the Sudoku square
              Rectangle box = new Rectangle(20, 20, 270, 270);
              g2.draw(box);
              g2.draw(new Line2D.Double(20, 110, 290, 110)); //horizontal
              g2.draw(new Line2D.Double(20, 200, 290, 200));
              g2.draw(new Line2D.Double(110, 20, 110, 290)); //vertical
              g2.draw(new Line2D.Double(200, 20, 200, 290));
    }SUDOKUVIEWER
    import javax.swing.JFrame;
    import java.util.Scanner;
    public class SudokuViewer
       public static void main(String[] args)
          JFrame frame = new JFrame();
          final int FRAME_WIDTH = 350;
          final int FRAME_HEIGHT = 350;
          frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
          frame.setTitle("Sudoku Viewer");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          SudokuComponent component = new SudokuComponent();
          frame.add(component);
          frame.setVisible(true);
    }

    I have improved your application to show how it can be programmed.
    For more information you can see about
    KeyListener:
    http://java.sun.com/docs/books/tutorial/uiswing/events/keylistener.html
    MouseListener:
    http://java.sun.com/docs/books/tutorial/uiswing/events/mouselistener.html
    and of course use repaint() when you want to update your component
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Rectangle;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.geom.Line2D;
    import java.util.LinkedList;
    import java.util.List;
    import javax.swing.JComponent;
    public class SudokuComponent extends JComponent {
        SudokuElement currentElement = new SudokuElement();
        List<SudokuElement> elementList = new LinkedList<SudokuElement>();
        public SudokuComponent(){
            addMouseListener(new MyMouseListener());
            setFocusable(true);
            addKeyListener(new MyKeyListener());
        public void paintComponent(Graphics g) {
            //public void paint(Graphics g) {
            //recover graphics2s
            Graphics2D g2 = (Graphics2D) g;
            //Construct the Sudoku square
            Rectangle box = new Rectangle(20, 20, 270, 270);
            g2.draw(box);
            g2.draw(new Line2D.Double(20, 110, 290, 110)); //horizontal
            g2.draw(new Line2D.Double(20, 200, 290, 200));
            g2.draw(new Line2D.Double(110, 20, 110, 290)); //vertical
            g2.draw(new Line2D.Double(200, 20, 200, 290));
            // show place where user can type a digit
            g2.draw(new Line2D.Double(currentElement.x - 10, currentElement.y, currentElement.x + 10, currentElement.y));
            // show all typed digits
            for(SudokuElement elem : elementList ){
               g2.drawString(elem.digit + "", elem.x, elem.y);
        class SudokuElement {
            int digit;
            int x;
            int y;
            SudokuElement getCopy(){
                SudokuElement elem = new SudokuElement();
                elem.x = x;
                elem.y = y;
                elem.digit= digit;
                return elem;
        class MyMouseListener extends MouseAdapter {
            public void mouseClicked(MouseEvent e) {
                System.out.println("mouse clicked: x = "  + e.getX() + " y = " + e.getY());
                currentElement.x = e.getX();  // It is better to use local coordinats 0 .. 9
                currentElement.y = e.getY();
                repaint(); 
        class MyKeyListener extends KeyAdapter {
            public void keyTyped(KeyEvent e) {
                char ch = e.getKeyChar();
                System.out.println("char typed= " + ch);
                if( Character.isDigit(ch) ){  // Filter only digits
                    currentElement.digit = Character.digit(ch, 10);
                    elementList.add(currentElement.getCopy());
                    repaint();
    }

  • Need an interactive "Prompting and receiving input mechanism " in PL/SQL

    Can anyone suggest, possibility of an interactive "Prompting and receiving input mechanism " in PL/SQL blocks.
    Thanks in advance.
    Regards,
    srini

    Use client side tools with PL/SQL engine:
    http://www.oracle.com/technology/documentation/forms.html

  • 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

  • Accepting User input in SQL*Plus

    I am writing a SQL script in SQL*Plus that accepts a value from the user and plugs that value into a variable that exist in several locations outside of the PL/SQL block.
    I am able to do this, yet everytime this variable is encountered, the user is prompted for input. I would like to have the user prompted only once at the beginning and then use that value throughout. This seems like a simple task, yet I cannot get it to work.
    Any help would be greatly appreciated.

    You can use &&<variable_name> and it will define the variable and use it throughout the SQL code.

  • How to accept user inputs from  sql script

    I want to create Tablespace useing sql script , but the location of the data file I need accept from user . (to get the location of the data file ) .
    How can I accept user input from pl/sql .
    Example :
      CREATE TABLESPACE  TSPACE_INDIA LOGGING
         DATAFILE 'H:\ORACLE_DATA\FRSDB\TSPACE_INDI_D1_01.dbf'
         SIZE 500M  AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED
         EXTENT MANAGEMENT LOCAL;here I need to accept location of the datafile from user ie : 'H:\ORACLE_DATA\FRSDB\TSPACE_INDI_D1_01.dbf'

    Hi,
    Whenenever you write dynamic SQL, put the SQL text into a variable. During development, display the variable instead of executing it. If it looks okay, then you can try executing it in addition to displaying it. When you're finished testing, then you can comment out or delete the display.
    For example:
    SET     SERVEROUTPUT     ON
    DECLARE
        flocation     VARCHAR2 (300);
        sql_txt     VARCHAR2 (1000);
    BEGIN
        SELECT  '&Enter_The_Path'
        INTO    flocation
        FROM    dual;
        sql_txt :=  'CREATE TABLESPACE SRC_TSPACE_INDIA LOGGING
         DATAFILE' || flocation || ' "\SRC_TSPACE_INDI_D1_01.dbf" ' || '
         SIZE 500M  AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED
         EXTENT MANAGEMENT LOCAL ';
        dbms_output.put_line (sql_txt || ' = sql_txt');
    --  EXECUTE IMMEDIATE sql_txt;
    END;
    /When you run it, you'll see something like this:
    Enter value for enter_the_path: c:\d\fubar
    old   5:     SELECT  '&Enter_The_Path'
    new   5:     SELECT  'c:\d\fubar'
    CREATE TABLESPACE SRC_TSPACE_INDIA LOGGING
         DATAFILEc:\d\fubar
    "\SRC_TSPACE_INDI_D1_01.dbf"
         SIZE 500M  AUTOEXTEND ON NEXT  1280K MAXSIZE
    UNLIMITED
         EXTENT MANAGEMENT LOCAL  = sql_txt
    PL/SQL procedure successfully completed.This makes it easy to see that you're missing a space after the keyword DATAFILE. There are other errrors, too. For example, the path name has to be inside the quotes with the file name, without a line-feed between them, and the quotes should be single-quotes, not double-quotes.
    Is there some reason why you're using PL/SQL? In SQL, you can just say:
    CREATE TABLESPACE SRC_TSPACE_INDIA LOGGING
    DATAFILE  '&Enter_The_Path\SRC_TSPACE_INDI_D1_01.dbf'
    SIZE 500M  AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED
    EXTENT MANAGEMENT LOCAL;though I would use an ACCEPT command to given a better prompt.
    Given that you want to use PL/SQL, you could assign the value above to sql_txt. If you need a separate PL/SQL variable for flocation, then you can assign it without using dual, for example:
    DECLARE
        flocation     VARCHAR2 (300)     := '&Enter_The_Path';The dual table isn't needed very much in PL/SQL.
    Edited by: Frank Kulash on Jan 10, 2013 6:56 AM

  • 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

  • Count the number of columns return in an user-input sql query

    I need to do something like this
    I let an user input a sql query and then execute it
    assuming the sql query is always correct, it will return a Resultset
    then a table will pop up to accomodate the number of columns the resultset will produce
    i'm stuck at the part on how to check how many columns of data will be return in the resultset

         ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM TABLE2");
         ResultSetMetaData rsmd = rs.getMetaData();
         int numberOfColumns = rsmd.getColumnCount();

  • In which of the following sections of a PL/SQL block is a user-defined exception raised?

    Hi,
    A (somewhat elementary) question:
    In which of the following sections of a PL/SQL block is a user-defined exception raised?
    a) Exception section
    b) Declarative section
    c) Error handling section
    d) Executable section
    I'd be interested to hear people's answers.
    Thanks.

    As Etbin already noted, there are only 3 sections and user-defined exception can be raised in any of them. User-defined exception raised in declarative section example:
    declare
        year_zero exception;
        pragma exception_init(year_zero,-01841);
    begin
        declare
            v_dt date := to_date(1721420,'j');
        begin
            null;
        end;
      exception
        when year_zero
          then
            dbms_output.put_line('Year 0!');
    end;
    Year 0!
    PL/SQL procedure successfully completed.
    SQL>
    User-defined exception raised in executable section example:
    declare
        year_zero exception;
        pragma exception_init(year_zero,-01841);
        v_dt date;
    begin
        v_dt := to_date(1721420,'j');
      exception
        when year_zero
          then
            dbms_output.put_line('Year 0!');
    end;
    Year 0!
    PL/SQL procedure successfully completed.
    SQL>
    User-defined exception raised in exception handling section example:
    declare
        year_zero exception;
        pragma exception_init(year_zero,-01841);
        v_dt date;
    begin
        declare
            v_num number;
        begin
            v_num := 1 / 0;
          exception
            when others
              then
                v_dt := to_date(1721420,'j');
        end;
      exception
        when year_zero
          then
            dbms_output.put_line('Year 0!');
    end;
    Year 0!
    PL/SQL procedure successfully completed.
    SQL>
    SY.

  • SQL- 2005 : User Input in select statement's where cond [Input Parameter]

    Hi All
    i am using SQL Server 2005 , i want to select the data based on the user input in where condition,
    but i am not sure what to give in where condition,can anyone have any idea on this
    SELECT [NO]
          ,[NAME]
          ,[PAGE_COUNT]
      FROM [DS].[DB].[tablename]
    where [NO]=???
    Regards
    Chaitanya.A

    HI
    public String getEmployeeName(String employeeNumber)
              // TODO : Implement
              String name = new String();
              String exception = new String();
              try
              InitialContext initialContext = new InitialContext();
              DataSource dataSource =(DataSource) initialContext.lookup("jdbc/XXXX");
              java.sql.Connection connection = dataSource.getConnection();
              PreparedStatement stmt =connection.prepareStatement("SELECT [NAME]FROM [XXX].[ASDF].[ABCD] where [NO]=?");
              stmt.setString(1,employeeNumber);
              ResultSet result = stmt.executeQuery();
              while (result.next())
                   name = result.getString("Name");
                   connection.close();
                   return name;
              catch (Exception e)
                   exception = "Exception";
                   return exception;
    i used the above function to achieve my requirement
    Thanks
    Chaitanya.A

  • How to force sql developer to prompt for user input for every execution ?

    Hi Folks,
    Environment: Oracle 11g (on Windows 7)
    SQL Developer: *3.1.07*
    I am executing a PL/SQL code off Sql Developer. The code uses substitution variables to prompt user for input. However,I am only prompted for the user input for the very first run of the code. For the subsequent executions, the code simply picks up the user input from the very first run. This behavior persists for all subsequent runs of the code.
    I have executed the same piece of code from SQL*PLUS and the behavior seems normal (i.e. I am prompted for fresh input for every execution)
    How can flush out the old user input so I can be prompted for new user input for every run of the code in sql developer?
    Thanks in advance
    rogers42

    Hi Rogers42,
    1/try
    undefine
    undefine fred
    select '&&fred' from dual;
    [run this multiple times]
    [prompts gere]
    old:select '&&fred' from dual
    new:select 'a' from dual
    'A'
    a
    [prompts here]
    old:select '&&fred' from dual
    new:select 'b' from dual
    'B'
    b
    2/try
    exit (requires recent version of sql developer: tools->preferences->Database->worksheet->Re-initialize on script exit command)
    select '&&fred' from dual;
    exit
    run this multiple times
    [prompts here]
    old:select '&&fred' from dual
    new:select 'x' from dual
    'X'
    x
    Commit
    [prompts here]
    old:select '&&fred' from dual
    new:select 'y' from dual
    'Y'
    y
    Commit
    3/use &fred instead of &&fred
    For background see
    http://totierne.blogspot.co.uk/2010/04/substitution-and-bind-variables.html
    -Turloch
    SQLDeveloper team

Maybe you are looking for

  • Can't add file to baggage files folder

    Hi, I have a javascript file I'm trying to add to the baggage files folder. However, for some reason, I can't add it. I'm using robohelp 6 and roboosource control 3.0. When I try to add the file, nothing is added to the folder. I was able to add the

  • License requires 24 characters, mine is much longer

    I downloaded "SAP NetWeaver 7.0 SR2 TestDrive - VMware Edition" and ran it. It gives me the SUSE Linux Enterprise Server running Java. Everything goes very smooth until I have to enter my license key. I tried to import the file that was emailed to me

  • Startup disk

    I am getting an error message that my "startup disk is full.  Please delete files."   I am not that good with figuring this out, so I was hoping someone could help me out.  Any ideas?

  • Provisioning to Micorosoft Live Communication server(LCS)

    Hi All, Can any body please give me pointers for the Micorosoft LCS provisioning. I think We need to modify some attributes in AD to provision user to LCS. If it is right, the next question would be to know that attribute. Does any body know which at

  • 10.4.9 troubbles

    Ok, ive been reading alot here about 10.4.9 troubles, well my bro's iMac just ran into one! last night when he updated to 10.4.9 he said he was having troubles with safari (i actually just read that there were memory leaks and other such troubles ass