How to pass int array as an IN parameter to PLSQL Procedure

Hi,
How to pass int array in java to a stored procedure througn jdbc
and what type of data type I should declare to this IN parameter
in PLSQL Procedure.
Thanks,
Simi

Hi,
The best way to do what you want depends on what you want.  Start by describing what you need to do.  It's best to post some sample data (CREATE TABLE and INSERT statments) and what results you want from that sample data.  (See the forum FAQ: https://forums.oracle.com/message/9362002)
If you have ideas about how to do the job (e.g., populating a temporary table) it can be helpful to include those, too, but distinguish clearly between WHAT you need to do and HOW you might do it.
As Bencol suggested, a SYS_REFCURSOR might be the best way to pass back the results.
Since you didn't post your table, or even describe what you wanted to do with it, I'll illustrate using scott.emp, which is probably on your system.
Say you wanted a procedure that took a DATE as an argument, and returned a some designated columns (empno, ename and hiredate in the example below) for all employees hired on or after the given DATE.  You might write a procedure like this:
CREATE OR REPLACE PROCEDURE  hired_since
(   start_date  IN   DATE
,   out_data    OUT  SYS_REFCURSOR
AS
BEGIN
    OPEN out_data FOR
        SELECT  empno, ename, hiredate
        FROM    scott.emp
        WHERE   hiredate  >= start_date;
END  hired_since;
SHOW ERRORS
You can test it in SQL*Plus like this:
VARIABLE   c REFCURSOR
EXEC  hired_since (DATE '1982-01-01', :c);
PRINT :c
The output I got from this test was:
     EMPNO ENAME      HIREDATE
      7788 SCOTT      19-APR-87
      7876 ADAMS      23-MAY-87
      7934 MILLER     23-JAN-82

Similar Messages

  • How to pass an Array to jsp:param

              Hi,
              I am trying to find out how to pass an array to a jsp:param tag abnd then retrieve
              the values in the next page. Please help soon. Thanks
              Here's my code - Assume the books array has more than 1 value
              String[] books = request.getParameterValues("book");
              <jsp:include page="<%=contentPage%>" flush="true">
              <jsp:param name="bookSelected" value="<%= books %>" />
              </jsp:include>
              The 'contentPage' takes me to the next page where I have the following to retrieve
              the value of 'bookSelected'
              String[] bookSelected = request.getParameter("bookSelected");
              I tried accessing the array like this
              if(bookSelected.equals("book1"))
              but did not succeed.
              I tried accessing the array in a loop but it did not work. Here's what I tried.
              <jsp:include page="<%=contentPage%>" flush="true">
              <%for (int i = 0; i<books.length; i++){
              %>
              <jsp:param name="bookSelected" value="<%= books %>" />
              <% } %>
              </jsp:include>
              

    Hi
    tell me how you redirect from __confirmdelete.jsp:__ to deleteServlet.java..
    and post detail code of __confirmdelete.jsp:__

  • How  to Pass String array from Java to PL/SQL  and this use in CURSOR

    hi,
    I cant understand how to pass Array String as Input Parameter to the Procedure and this array use in Cursor for where condition like where SYMPTOM in( ** Array String **).
    This array containing like (SYMPTOM ) to be returned from the java to the
    pl/sql (I am not querying the database to retrieve the information).
    I cannot find an example on this. I will give the PL/SQL block
    create or replace procedure DISEASE_DTL<*** String Array ***> as
    v_SYMPTOM number(5);
    CURSOR C1 is
    select distinct a.DISEASE_NAME from SYMPTOM_DISEASE_RD a
    where ltrim(rtrim(a.SYMPTOM)) in ('Fever','COUGH','Headache','Rash') ------- ***** Here use this array element(like n1,n2,n3,n4,n5..) ******
    group by a.DISEASE_NAME having count(a.DISEASE_NAME) > 3 ----------- ***** 3 is no of array element - 1 (i.e( n - 1))*****
    order by a.DISEASE_NAME ;
    begin
    for C1rec IN C1 loop
    select count(distinct(A.SYMPTOM)) into v_SYMPTOM from SYMPTOM_DISEASE_RD a where A.DISEASE_NAME = C1rec.DISEASE_NAME;
    insert into TEMP_DISEASE_DTLS_SYMPTOM_RD
    values (SL_ID_SEQ.nextval,
    C1rec.DISEASE_NAME,
    (4/v_SYMPTOM), --------**** 4 is no of array element (n)************
    (1-(4/v_SYMPTOM)));
    end loop;
    commit;
    end DISEASE_DTL;
    Please give the proper solution and step ..
    Thanking you,
    Asish

    I've haven't properly read through your code but here's an artificial example based on a sql collection of object types - you don't need that, you just need a type table of varchar2 rather than a type table of oracle object type:
    http://orastory.wordpress.com/2007/05/01/upscaling-your-jdbc-app/

  • Using TestStand How I pass an array of data into a DLL (IPC3.dll) for serial communication

    I am ussing a DLL created by another party. I have the list of the C declaretions. I have been able to write a seq that can turn the comport ON/OFF or select a different port but I have not been able to send or recieved any data. I have created an array of bytes(unsigned 8-bit integers)to send and recieved data but nothing goes out or in.

    Hi Toro,
    There is an example in your \Examples\AccessingArrays\PassingArrayParametersToDLL directory that illustrates exactly how to pass TestStand arrays as arguments to dll functions. The source files for the .dll are located in the same directory.
    For more information on passing arrays as parameters to modules you should read the "DLL Flexible Prototype Adapter" section of Chatper 13 in the TestStand User Manual, and pay special attention to the subsection entitled "Array Parameters". You can access the User Manual from the TestStand Start Menu group, the TestStand Sequence Editor's Help menu, the \Doc directory, or online at the following link:
    http://digital.ni.com/manuals.nsf/websearch/50B69DA356B8D38C86256A0000660E6B?OpenDocumen
    t&node=132100_US
    Jason F.
    Applications Engineer
    National Instruments
    www.ni.com/ask

  • How to pass an array to a stored procedure

    create or replace package demo_pkg
    as
    type cityArray is table of city%rowtype index by binary_integer;
    procedure city_report( p_inputs in cityArray );
    end;
    CREATE OR REPLACE PACKAGE BODY demo_pkg
    AS
    PROCEDURE city_report (p_inputs IN cityarray)
    IS
    BEGIN
    FOR i IN 1 .. p_inputs.COUNT
    LOOP
    DBMS_OUTPUT.put_line ( 'citycode = '
    || p_inputs (i).city_code
    || ' CITYDESCRIPTION = '
    || p_inputs (i).city_description
    INSERT INTO testing
    (city_code, city_description
    VALUES (p_inputs (i).city_code, p_inputs (i).city_description
    commit;
    END LOOP;
    END;
    END;
    to call that procedure ia m using this
    declare
    my_data demo_pkg.cityArray;
    begin
    my_data(1).city_code := 1234;
    my_data(1).CITY_DESCRIPTION := 10;
    my_data(2).city_code := 4567;
    my_data(2).CITY_DESCRIPTION := 20;
    my_data(3).city_code := 4321;
    my_data(3).CITY_DESCRIPTION := 30;
    demo_pkg.city_report( my_data );
    end;
    but actually the procedure (demo_pkg.city_report)is called from front end(.net).how they will call this procedure in .net invironment

    Hi,
    Your exact question has been asked before, see: http://asktom.oracle.com/pls/ask/search?p_string=How+to+pass+an+array+to+a+stored+procedure
    or do a search on this forum.
    And please use this tag => (yes, just the 4 characters forming the word 'code' between curly brackets)
    *before* and *after* your example to maintain formatting and indentation, it's hard to read now....                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Pass an array of buttons by parameter

    Dear Java developers :
    I am asking about how can I pass an array of JButton by parameter.
    For example, I have a method that randomly picks a button that have an empty text (""), if not empty then the method recursively calls herself and so on until it finds an empty labeled button :
    private void randomPick(JButton buttons[]) {
              Random r = new Random();
              int n = r.nextInt(8);
              if (buttons[n].getText()!="") {
                   countClicks--;
                   randomPick(buttons[n]);
              } else {
                   buttons[n].setText("O");
                   buttons[n].setEnabled(false);
              countClicks++;
         }The problem is that I don't know neither how to pass the buttons[] in parameter of a method nor how to write the calling of the method properly.
    Thanks for your help,
    Hassanova.

    Ok sorry for my explanations I'll try to be more clear :
    I have 2 classes at this point : one that draws the interface, the other makes the treatment
    here is the 1st class :
    import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    public class TTTGameJFrameView implements ActionListener {
         JFrame frame = null;
         JButton buttons[] = new JButton[10];
         public TTTGameJFrameView() {
              setView();
         public void setView() {
              // Building the window
              frame = new JFrame("Tic Tac Toe Game");
              frame.setSize(300,300);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setLayout(new GridLayout(3,3));
              //Positioning the buttons
              for(int i = 0; i<=8; i++){
                   buttons[i] = new JButton();
                   frame.add(buttons);
                   buttons[i].addActionListener(this);
         public void close() {
              frame.dispose();
         public void display() {
              frame.setVisible(true);
         @Override
         public void actionPerformed(ActionEvent e) {
              // TODO Auto-generated method stub
    And here is the 2nd class where I don't know how to pass by parameter the buttons declared in the 1st class to the methods and hpw to call them properly....
    package test.TicTacToe;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Random;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    public class TTTGameModel {
         JButton buttons[] = new JButton[10];
         JFrame frame = null;
         JButton buttons[] = new JButton[10];
         private void setView() {
              // Building the window
              frame = new JFrame("Tic Tac Toe Game");
              frame.setSize(300,300);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setLayout(new GridLayout(3,3));
              //Positioning the buttons
              for(int i = 0; i<=8; i++){
                   buttons[i] = new JButton();
                   frame.add(buttons);
                   buttons[i].addActionListener(this);
              frame.setVisible(true);
         private int[][] winPositions = new int[][] {
                   {0,1,2}, {3,4,5}, {6,7,8},
                   {0,3,6}, {1,4,7}, {2,5,8},
                   {0,4,8}, {2,4,6}
         private int countClicks = 0;
         private boolean win = false;
         private String buttonLetter = "";
         private String xOrO = "";
         public void actionPerformed(ActionEvent e, JButton buttons[]) {
              for(int i=0; i<=8; i++) {
                   if(e.getSource().equals(buttons[i])) {
                        buttons[i].setText("X");
                        buttons[i].setEnabled(false);
              if ((countClicks <= 8) && (win==false)) {
                   randomPick(buttons);
                   countClicks++;
                   whoWins(buttons);
                   System.out.println("click�");
              //System.out.println(countClicks);
         private void whoWins(JButton buttons[]) {
              for (int i=0; i<=7; i++) {
                   if (buttons[winPositions[i][0]].getText().equals(buttons[winPositions[i][1]].getText()) &&
                        buttons[winPositions[i][1]].getText().equals(buttons[winPositions[i][2]].getText()) &&
                        buttons[winPositions[i][0]].getText()!="")
                        win = true;
              System.out.println(countClicks + " " + win);
              showWinner(win,countClicks);
         private void showWinner(boolean isWin, int count) {
              if(count % 2 == 0)
                   xOrO = "O";
              else
                   xOrO = "X";
              if (isWin == true){
                   JOptionPane.showMessageDialog(null,"The "+xOrO+" Player Wins!");
                   System.exit(0);
              else if ((isWin == false) && (count >= 9)){
                   JOptionPane.showMessageDialog(null,"Draw Game");
                   System.exit(0);
         private void buttonClick(ActionEvent e) {
         private void randomPick(JButton buttons[]) {
              Random r = new Random();
              int n = r.nextInt(8);
              if (buttons[n].getText()!="") {
                   countClicks--;
                   randomPick(buttons[n]);
              } else {
                   buttons[n].setText("O");
                   buttons[n].setEnabled(false);
              countClicks++;
         private void randomPick(JButton button) {
              // TODO Auto-generated method stub
         public static void main(String[] args) {
              TTTGameJFrameView tt = new TTTGameJFrameView();
              tt.setView();
              tt.display();
    Thank you very much I appriciate your patience !
    Hassanova.

  • How to pass a value to the export parameter for a method (public instance)?

    Hello,
      I am trying ABAP OO newly. How to pass a value to the export parameter for a method (public instance) called in a report? This *export parameter has a reference type of structure.
    Thanks in advance,
    Ranjini

    Hi,
    "class definition
    class lcl... definition.
      public section.
        method m1 imporitng par type ref to data.  "now you can pass any reference to the method, but this way you have to maintain this reference dynamically inside the method (you can't be sure what that reference is really "pointing" at)
    endclass.
    "in program
    data: r_lcl type ref to lcl...
    create object r_lcl.
    call method r_lcl
      exporting
         par    =  "pass any reference variable here
    Regards
    Marcin

  • How to pass xml data as objects into Database using store procedures

    Hi All,
         I don't have much knowledge on store procedure,can anybody help how to pass the xml as objects in Database using store procedure.
    My Requirement is I have a table with three fields EMPLOYEE is table name and the fields are EMP_ID,EMP_TYPE AND EMP_DET,I have to insert the employees xml data into corresponding fields in the table.
    Input Data
    <ROWSET>
       <ROW>
         <EMP_ID>7000</EMP_ID>
          <EMP_TYPE>TYPE1</EMP_TYPE>
         <EMP_DET>DEP</EMP_DET>
      <ROW>
      <ROW>
         <EMP_ID>7000</EMP_ID>
         <EMP_TYPE>TYPE2</EMP_TYPE>
        <EMP_DET>DEP2</EMP_DET>
    <ROW>
    <ROW>
         <EMP_ID>7000</EMP_ID>
         <EMP_TYPE>TYPE3</EMP_TYPE>
        <EMP_DET>DEP3</EMP_DET>
    <ROW>
    <ROWSET>
    So each row values has to inserted into resp fields in the table.
    Regards
    Mani

    Do you have a similar structure in your stored procedure ?
    In that case you can simply call the procedure from soa using db adapter and do a mapping to assign the values.

  • How to pass an array which in the jsp to a javascript file

    now i have 2 files: jsp and js(javascript)
    i want pass an array which in the jsp to another file--> js file
    how can i do it ???
    can u give me some related links or some source codes as the references???
    thx

    bcos ....my senior has resigned!!! so i take over his job !!!!!
    depend on the talent and the project ....only that way to implement to whole project !!!!
    but , i had settled it already ....
    it is very simple
    in the middle.jsp
    Collection result = menuManager.getUserRoleMenu(webSessionUser.getGnuserId());
    String menuname[]=new String[110];
    int menucounter=0;
    Iterator vi = result.iterator();
    while(vi.hasNext())
    HashMap hm=(HashMap)vi.next();
    menuname[menucounter]=hm.toString();
    menucounter++;
    int i;
    String tempstr="";
    for(i=0;i<menuname.length;i++)
    tempstr+=menuname[i]+",";
    session.setAttribute("menuname",tempstr);
    %>
    <script language="javascript">
    menu123("<%=tempstr %>");
    </script>
    in the body,js
    function menu123(string123)
    //doing
    so ....through the script --menu123
    i can get the string from jsp to the js!!!!!
    is it very simple, but it spends my 2 days!!!
    i just learn javascript ....about 1 month !!!

  • How to pass an array in Oracle Procedure

    If I have to pass an array as an argument in Oracle Procedure/function. How to do that ??
    For example, I have to pass the names of employess and then for these employess I have to do something in Oracle Procedure.
    Thanks & Regards,
    Vinay

    Hi!
    Here is an example:
    create or replace procedure test
    is
    type v2_itt is table of varchar2(2000) index by binary_integer;
    l_v2 v2_itt;
    procedure test2( pi_v2 v2_itt ) is
    begin
    for i in 1 .. pi_v2.count loop
    dbms_output.put_line( pi_v2(i) );
    end loop;
    end;
    begin
    l_v2(1) := 'name1';
    l_v2(2) := 'name2';
    test2( l_v2 );
    end;
    Regards,
    Andrew Velitchko
    BrainBench MVP for Developer/2000
    http://www.brainbench.com

  • How to pass an array to a subroutine in FXscript?

    Hi,
    I am having problems trying to pass an array to a subroutine in FXscript.  Code segment:
    on TestSub(value x)
    // do stuff
    end
    float i, testarray[256];
    for i = 0 to 255
              testarray[i] = i;
    next
    TestSub(testarray);
    FXscript returns the error "missing close parenthesis".  If TestSub(testarray) is replaced with TestSub(testarray[0]) no error, i.e. if a single value is passed.
    Trying to define the subroutine differently doesn't help, e.g. "on TestSub(value x[255])" or "on TestSub(float x[255])" yields the same error.
    How do you pass an array to an FXscript subroutine?  Or is it not possible?
    Thanks for any clues...

    You are not being quite clear.  If the next frame expects a pointer to a buffer, it cannot be a vi.  Labview has no pointer types.  You must be referring to a Call Library Node which is set up to call a DLL function.  If this is the case, you need to configure the Call Library Node to accept an array of the data type.  Then you can wire the array into the call library node.
    Is this the case, Call Library Node?
    - tbob
    Inventor of the WORM Global

  • How to pass an array to a function from a SELECT statement

    Hi all. I have a problem with passing an array to a function directly from a SELECT statement.
    Here is what I want. If I have a function
    function AAA(arrayVar <ArrayType>) return number;
    I want to be able to call this function this way
    select AAA((2,3,4))
    from dual
    or this way
    select AAA((10,12))
    from dual
    In other words I want to be able to pass an arbitrary number of numbers to the function. And I want this to work in a SELECT statement.
    Does anyone have any ideas how to implement this? What <ArrayType> should I use?(I've read about VARRAY, nested tables in the Oracle documentation but as far as I've understood these array types are meant to be used within PL/SQL blocks).
    I found only this http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:208012348074 through Google but it didn't help me.
    Thank you in advance.

    > What <ArrayType> should I use?
    SQL data types - as 3360 showed above. You cannot use PL/SQL structures and user types in the SQL Engine.
    You can however use all SQL structures and types in PL/SQL.
    Arrays in SQL is created as collection type - basic o-o. The collection type (or class) serve as a container for instantiated objects or scalar type.
    This is covered in detail in [url http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14260/toc.htm]
    Oracle® Database Application Developer's Guide - Object-Relational Features

  • How to pass an array to a procedure & how to use array in IN clause in SQL

    Hi all,
    how do i pass an array of varchar2[10] in an procedure and i want to use this array in the IN caluse of the SQL statement inside the procedure. Can anyone please help me on this.
    Thanks & regards
    shyam~

    There are multiple ways. For example:
    SQL> create or replace
      2    type str10_tbl_type is table of varchar2(10)
      3  /
    Type created.
    SQL> -- Using TABLE operator
    SQL> create or replace
      2    procedure p1(
      3                 p_str10_tbl str10_tbl_type
      4                )
      5      is
      6      begin
      7          for rec in (
      8                      select  ename,
      9                              sal
    10                        from  emp,
    11                              table(p_str10_tbl)
    12                        where ename = column_value
    13                     ) loop
    14            dbms_output.put_line(rpad(rec.ename,10) || rec.sal);
    15          end loop;
    16  end;
    17  /
    Procedure created.
    SQL> set serveroutput on format wrapped
    SQL> exec p1(str10_tbl_type('KING','ALLEN','SMITH'));
    KING      5000
    ALLEN     1600
    SMITH     800
    PL/SQL procedure successfully completed.
    SQL> -- Using MEMBER OF method
    SQL> create or replace
      2    procedure p1(
      3                 p_str10_tbl str10_tbl_type
      4                )
      5      is
      6      begin
      7          for rec in (
      8                      select  ename,
      9                              sal
    10                        from  emp
    11                        where ename member of p_str10_tbl
    12                     ) loop
    13            dbms_output.put_line(rpad(rec.ename,10) || rec.sal);
    14          end loop;
    15  end;
    16  /
    Procedure created.
    SQL> set serveroutput on format wrapped
    SQL> exec p1(str10_tbl_type('KING','ALLEN','SMITH'));
    SMITH     800
    ALLEN     1600
    KING      5000
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Passing int arrays to strings

    I'm having trouble passing an array of integers to a string and vice versa i.e. the array has
    element[0] =1
    element[1] =0
    element[2] =0 but it can hold up to 16 elements
    what I want is for this array which holds a binary number represented by ints to be represented as the string "001". Im passing the method an array then I want it to loop the length of the array and store each element as a part of the string. I then want to add the number to another number put it back in an array and return it. If anyone has any help I would appreciate it.
    Thanks.

    public class YourClass {
         public static String arrayToString(int[] theArray) {
              int lim = theArray.length;
              StringBuffer sb = new StringBuffer();
              for (int i = 0; i < lim; i++) {
                   sb.append(String.valueOf(theArray));
              return sb.toString();
         public static int[] stringToArray(String theString) {
              int lim = theString.length();
              int[] theArray = new int[lim];
              for (int i = 0; i < lim; i++) {
                   theArray[i] = Integer.parseInt(theString.substring(i, i+1));
              return theArray;
         public static void main(String[] args) {
              int[] theArray = {1,0,0,1,1};
              String theString = arrayToString(theArray);
              System.out.println(theString);
              int[] theArray2 = stringToArray(theString);
              System.out.println(arrayToString(theArray2));

  • How to pass an array of values to  a view criteria

    Hi all,
    How to pass mutiple values as array into a view criteria.I want to search
    based on mutiple values.
    Please help.
    Thanks

    Swapna wrote:
    I have a search panel with mutilselect combobox for attributes "a","b", & "c".
    Based on selction"a" ,I need to filter the comboboxes "b" and "c".
    This's the requirement.I'm not sure that I understand your question. Are you saying that you have three different controls in your UI? Or one control that has three possible values?
    Assuming that you have one control with three possible values, if "a" is selected, does that mean that you want all rows where some column has a value of "a"? Or does that mean that you want all rows where that column does not have a value of "a"? Or does that mean that you want all rows where that column has a value of "b" or "c" (note that the last two may be different if the column allows NULL values).
    What language is your application written in? What framework/ library are you using to access the database? Are you passing a PL/SQL collection of selected values?
    Justin

Maybe you are looking for

  • 4265 Audit Failure: NTLM Authentication Issue from constant Outlook Login Prompts

    Hello Technet! Last week I started running into a domain-wide issue where users could authenticate while connected to the domain, but would receive prompts to log in to our external host. The first prompt is for mail.domain.local, which works fine in

  • IPhoto importing RAW, then converting to jpg--losing RAW file completely

    Okay, I've read through some of the posts on similar issues, but I still have some questions. I've always used iPhoto to import my RAW files (since it supported it anyway) and never had problems. I bought a new G5 and it seems like this problem has s

  • MSS: Cost Center in Team Viewer

    I'm trying to add Cost Centres to the Team Viewer.  I put 'ORG_COSTC' with Function Module HRWPC_GEN_COL_COSTCENTER into V_TWPC_ACOL_C and assigned the column group to my view.  I managed to get the Cost Centre column to show up on the Team Viewer bu

  • Satellite L755 - USB Flash Memory is not recognized properly

    Hi Sirs I have (ScanDsik 32GB flash memory) it was working before correctly, but in the last week it was delay to work when I connect it to the laptop Toshiba Satellite L755 and now when I connect it I cannot open it I see it in device manager but ca

  • Finally under contract!!

    After months of credit repair, scores finally at approval for house. Was getting discouraged due to couldn't find house and when did got out bid. Than finally a house we love came back on market, quickly but offer and was accepted. Now I am so scared