Bindind data to multidimensional Array

I have a multidimensional Array (3D). I have some fields which I want to bind to some TextInputs:
model.creditosConsumoModel.literaturaCredito[i][j][k]
And here's a example of the data binding:
text="{(model.creditosConsumoModel.literaturaCredito[4][12][0] as Apartado).texto}"
The problem is: When I do a: model.creditosConsumoModel.literaturaCredito = new Array and I define the Array again with new data everything gets blank (all the text Inputs) and I loss the information.
Resume: It only works the first time, but not the rest of the times.
Thanks and regards!!!

@Pauland
That's what I was thinking as it was an array of arrays.
@quebequiano
Generally, for something like this, I make a wrapper object and set the values on that so I don't have to deal with issues like this.  I'm not sure how architecturally sound it is, but it sounds like you are trying to take small pieces of data and prepare them for your view, in which case a wrapper/adapter would provide you with the benefits of databinding.
P.S Does your name mean "Quebecian" in spanish ?

Similar Messages

  • Problems manipulating multidimensional arrays

    hello, I am new to java programming. I would like to know some techniques in which i can change the data within multidimensional arrays. For example, with a 2d array, (int [row][column] a), the index of the rows are the columns, and each column contains an element. I would like to know how to, for example, switch the order of the indexes of the rows and columns. So for row 1, the columns (the indexes) are 0,1,2,3. after switching the order, it would be 3,2,1,0. Is there any possible way to do this? a reply would be appreciated. Thank you.

    Carefully read the following: given a two dimensional array, we can
    define a simple wrapper:public interface ArrayWrapper {
       public int rowDim();
       public int colDim();
       public int get(int row, int col);
       public void set(int row, int col, int value);
    }... here's a very simply 'real' ArrayWrapper:public class RealArrayWrapper implements ArrayWrapper {
       private int[][] array; // what it's all about
       public RealArrayWrapper(int[][] array) { this.array= array; }
       public int rowDim() { return array.length; }
       public int colDim() { return array[0].length; } // assume a non-ragged array
       public int get(int row, int col) { return array[row][col]; }
       public void set(int row, int col, int value) { array[row][col]= value; }
    }... here's a wrapper that does nothing, given another wrapper:public class NilWrapper implements ArrayWrapper {
       private ArrayWrapper wrap;
       public NilWrapper(ArrayWrapper wrap) { this.wrap= wrap; }
       public int rowDim() { return wrap.rowDim(); }
       public int colDim() { return wrap.colDim(); }
       public int get(int row, int col) { return wrap.get(row, col); }
       public void set(int row, int col, int value) { wrap.set(row, col, value); }
    } ... and here's one that reverses all rows:public class RevRowWrapper extends NilWrapper implements ArrayWrapper {
       public RevRowWrapper(ArrayWrapper wrap) { super(wrap); }
       public int get(int row, int col) { return super.get(rowDim()-row-1, col); }
       public int set(int row, int col, int value) { super(rowDim()-row-1, col, value; }
    }... do you get the picture?
    kind regards,
    Jos

  • MultiDimensional Array or what????

    Hi Guys
    I have created an xml document that has this structure for
    each child:
    <work>
    <client>Telstar Records</client>
    <titled>Stargate Music.co.uk</titled>
    <thumb>images/thumbs/stargate_sm.jpg</thumb>
    <description>They were an up and coming band, i was a
    designer with a passion for 3d, they met fell in love and a new
    site was born. All it took was four press shots, one promo and a
    lot of imagination</description>
    <images>
    <image>images/large/telstar_sg_01.jpg</image>
    <image>images/large/telstar_sg_02.jpg</image>
    <image>images/large/telstar_sg_03.jpg</image>
    </images>
    <link>
    http://www.4zero1.co.uk/backupsites/stargate/index.html</link>
    </work>
    I have succesfully created buttons and used an associative
    array to compile the info for each button, woooooo aren't i
    clever!!!! I have set up a path to the <images> node, but I
    am stumped as to how i can pull the information from the
    'workImages' variable in my getworkData() function below .
    I need your help, as i would like to create buttons of the
    childnodes named <image> in the xml, above you can see that
    if i was successful i would have three buttons. My problem is
    relating the information to the buttons and making the buttons
    appear. I am not using a for loop as i would like to animate each
    button using a scripted tween. as in the makeButtons() function.
    Do I need to create a multidimensional array? I have included
    my code below, please don't get too lost in it, i hope someone can
    fathom it for me and give me an answer. My associative array is in
    the function getworkData(); My function to create the 'image'
    buttons is called portfolioImageCreator();
    Many thanks
    Jim

    You could use a table of records or a record group. They both achieve similar results but with very different syntax. I am not sure if there is any difference in performance.
    Record groups are good for certain things like lists populated from the database because built-ins are provided for manipulating them. If you are going to do the manipulation programatically, I personally find the syntax for tables of records less cumbersome than record groups. Learning the syntax for tables of records is also likely to be more universally useful to you as they have various uses such as passing data between procedures.
    In your situation the table of records needs to exist throughout the forms session rather than just during the execution of a single pl/sql block. The way to do that is create a program unit which is a package header without a body. Declare the table in there and it can be used throughout the form.
    However, if you only ever want to keep 5 records, it would probably be easier just to have 5 ordinary items in a control block on the null canvas (or global variables). When you want to record your new action just do:
    :item5 := :item4;
    :item4 := :item3;
    :item3 := :item2;
    :item2 := :item1;
    :item1 := :new_stuff;
    You could even construct the above in a loop using
    copy(name_in('item'||i),'item'i+i)
    but with only 5 items to manipulate, is it worth the bother ?
    Whatever method you decide to use, you are not going to get anything simpler than 5 little assignment statements.

  • Multidimensional array and chars

    Hi again,
    My apologies in advance if i can't word my question that well, i will try and be as clear and succinct as possible and hopefully for this newbie you can apprehend what i'm trying to figure out if i come up short.
    I'm trying to write a rather large control statement with a while loop and several nested ifs inside it that ultimately returns a single character after all is said and done, and then continually concatenates that character to a string which will eventually be output to a file. The part i'm stuck at is after i've changed the two letter characters into their ASCII values. I need to make the program take those two ASCII values and use them as a reference to a character in a multidimensional array of alphabetic characters, and then that character will be what is returned at the end.
    Here's the method, thanks in advance for your time.
    public String encode( String cipherKey )
            String textToEncode = input.next();
            String encodedText = " ";
            cipherKey = cipherKey.toUpperCase();
            textToEncode = textToEncode.toUpperCase();
            openFiles();
            int numberOfChars = textToEncode.length();
            int cipherPos = 0;
            int cipherLength = cipherKey.length();
            while (input.hasNext())
                for ( int count = 0; count < numberOfChars; count++ )
                    if (Character.isLetter(textToEncode.charAt(count)))
                        cipherPos %= cipherLength;
                        int xChar = (int) textToEncode.charAt(cipherPos);
                        int yChar = (int) textToEncode.charAt(count);
                        xChar -= 65;
                        yChar -= 65;
                        if ((xChar >= 0) && (xChar <= 25))
                            if ((yChar >= 0) && (yChar <= 25))
                        return ' ';
                     encodedText = encodedText +
        return encodedText; 
        }As you can see towards the end there are some incomplete statements where i became lost.

    its there, i couldnt c&p the whole program because it went over my character limit. Yeah it did compile but couldn't invoke my encode method without a NullPointerException.
    Here are the other methods in the class....
        public String setSource( String in )
            source = in;
            return source;
         Sets the value of the output file
         * @param out A <code>String</code> value representng name of output file.
         * @see #setSource
        public String setDestination( String out )
            destination = out;
            return destination;
         * Method to open both input and output files, and to test for exceptions
         * @see #encode
         * @see #decode
        private void openFiles()
        File inputFile = new File(source);  //Creates new file object from source file
        File outputFile = new File(destination);  //Creates new file object from destination file
            /* Tests whether input file exists and if so enables the Scanner
             * to read the data in from the source file. Catches SecurityException and
             * FileNotFoundException amd prints appropriate messages to user.
            if (inputFile.exists())
                try
                    input = new Scanner( new File( source ) );
                    FileReader reader = new FileReader(inputFile);
                    BufferedReader BufferIn = new BufferedReader(reader);
                catch ( SecurityException securityException )
                    System.err.println("You do not have read access to this file.");
                    System.exit( 1 );
                catch ( FileNotFoundException filesNotFoundException )
                    System.err.println("Error: File does not exist.");
                    System.exit( 1 );         
            /* Tests whether output file exists and if it does enables Formatter
             * to write encoded output to file. Catches SecurityException and
             * FileNotFoundException and prints appropriate message to user.
            if (outputFile.exists())
                try
                    output = new Formatter( new File( destination ) );
                catch ( SecurityException securityException )
                    System.err.println("You do not have write access to this file.");
                    System.exit( 1 );
                catch ( FileNotFoundException filesNotFoundException )
                    System.err.println("Error: File does not exist.");
                    System.exit( 1 );
         * Closes both input and output files after output file has been written
         * to.
         * @see #openFiles
        private void closeFiles()
            if ( output != null )
                input.close();
                output.close();
        }Edited by: fearofsoftware on Apr 17, 2009 8:35 PM

  • JNI multidimensional Array and OpenCV

    Hello everybody,
    my first post, so lets go..
    At the moment I am writing my thesis in the filed of automatic image classification. The project is written in Java, but I wanna use the OpenCV library from Intel (http://sourceforge.net/projects/opencvlibrary/) for facedetection.
    So far I managed to call the native method from Java. What I do I parse the path of the image to be analyzed as a string to my C++ programm. The faces are being detected and written into a so called CvSeq (http://www.comp.leeds.ac.uk/vision/opencv/opencvref_cxcore.htm#cxcore_ds_sequences) which holds the coordinates of the rectangles surrounding the found faces. Until now I can only call cvSeq->total which gives me the total number of faces as ints. That integer I return to my java api.
    What I don't know is, how to return a multidimensional array (2 dimensions) where the first dim contains the path as a string to the file and the second dimension 3 integers for x,y coordinates and the lenght of each rectangle.
    Or better, I might know how to return that Array, but not how to create it.
    I know this is somewht OpenCV specific, but maybe someone knows anything. Any little help would be greatly appreciated. Thanks a lot!!!!
    Regards
    Carsten
    attached: JNI source code
    /////////////////////////////////////////// source code ///////////////////////////////////////////////
    #include "cv.h"
    #include "highgui.h"
    #include "cxcore.h"
    #include "cxtypes.h"
    #include "cvaux.h"
    #include "org_kimm_media_image_data_JNIOpenCV.h"
    #include <stdio.h>
    JNIEXPORT jint JNICALL
    Java_org_kimm_media_image_data_JNIOpenCV_getFaces(JNIEnv *env, jobject object, jstring path)
    //declarations
    CvHaarClassifierCascade *pCascade = 0;
    CvMemStorage *pStorage = 0;
    CvSeq *pFaceRectSeq;
    int scale=1;
    jobjectArray recPoints;
    const char *str = env->GetStringUTFChars(path, 0);
    //initializations
    IplImage* pInpImg = cvLoadImage(str, CV_LOAD_IMAGE_COLOR);
    IplImage* small_image = pInpImg;
    pStorage = cvCreateMemStorage(0);
    pCascade = (CvHaarClassifierCascade *)cvLoad
         (("C:/OpenCV/data/haarcascades/haarcascade_frontalface_default.xml"),0, 0, 0 );
    //validaste that everything initilized properly
    if( !pInpImg || !pStorage || !pCascade)
         printf("Initialization failed: %s \n",
              (!pInpImg) ? "didn't load image file" :
              (!pCascade) ? "didn't load Haar Cascade --"
                   "make sure Path is correct" :
              "failed to allocate memory for data storage");
         exit(-1);
    //performance boost through reducing image size by factor 2          
              small_image = cvCreateImage( cvSize(pInpImg->width/2,pInpImg->height/2), IPL_DEPTH_8U, 3 );
    cvPyrDown( pInpImg, small_image, CV_GAUSSIAN_5x5 );
    scale = 2;
    //detect faces in image
    pFaceRectSeq = cvHaarDetectObjects(small_image, pCascade, pStorage,
                                            1.1,                                        //increase search scale by 10% each pass
                                            6,                                        //drop group of fewer than three detections
                                            CV_HAAR_DO_CANNY_PRUNING,          //skip regions unlikely to contain faces
                                                 cvSize(50,50));                         //use XML default for smallest search scale
    //initialize array for location of the faces (HERE IS WHERE I GET INTO TROUBLE!!!!!)
    int x = pFaceRectSeq->total;
    jclass intArrCls = env->FindClass ( "[I" ) ;
    recPoints = env->NewObjectArray ( x, intArrCls, NULL ) ;
    //for(int j = 0; j <= x; j++) {
    //   recPoints[j] = (jintArray)env->NewIntArray(3);
    for(int i=0;i<(pFaceRectSeq ? pFaceRectSeq->total:0); i++)
                                       CvRect* r = (CvRect*)cvGetSeqElem(pFaceRectSeq, i);
                                       CvPoint pt1 = {(r->x)*scale, (r->y)*scale};
                                       CvPoint pt2 = {(r->x + r->width)*scale, (r->y + r->height)*scale};
    //env->SetObjectArrayElement(recPoints,i, pt1.x);
    return pFaceRectSeq->total;
    }

    Any Java array you can consider like one-dimensional array of arrays n-1 dimension. For example, you have a 3 dim. array of objects:
    Object[][][] arr = new Object[1][2][6]; It can be considered as a set of one-dimensional arrays:
    ==========================================
    |  dim   |           Type
    ==========================================
      0          1 element, an array of type �[[Ljava/lang/Object;�
      1          1 x 2 elements , an arrays of type �[Ljava/lang/Object;�
    So you can convert three-dimensional array to one-dimensional array like in C++:
    |�[Ljava/lang/Object;� | �[Ljava/lang/Object;� | �[Ljava/lang/Object;�
         6 objects                 6 objects                 6 objects

  • Memory Consumption in Multidimensional Arrays

    Hi,
    I've noticed that the memory consumption of multidimensional arrays in Java is sometimes far above one could expect for the amount of data that is being stored. For example, here is a simple program which stores a table containing only integers and reports the memory consumption after it is filled:
    public static void main(String[] args) {     
    int tableSize = 1000000;
    int noFields = 10;
    Random rnd3 = new Random();          
    int arr[][] = new int[tableSize][noFields];
    for (int i = 0; i < tableSize; i++) {
    for (int j = 0; j < noFields; j++) {
         arr[i][j] = rnd3.nextInt(100);
    Runtime.getRuntime().gc();
    Runtime.getRuntime().gc();
    Runtime.getRuntime().gc();                    
    // Ensures table's data is still referenced
    System.out.println(arr[rnd3.nextInt(arr.length)]);
    long totalMemory = Runtime.getRuntime().totalMemory();
    long usedMemory = totalMemory-Runtime.getRuntime().freeMemory();
    System.out.println("Total Memory: " + totalMemory/(1024.0*1024) + " MB.");
    System.out.println("Used Memory: " + usedMemory/(1024.0*1024) + " MB.");          
    Output:
    Total Memory: 866.1875 MB.
    Used Memory: 62.124053955078125 MB.
    In this case the memory consumption was around 20MB above the expected 38MB required for storing 10M integers. The interesting thing is that the memory consumption varies when the numbers of rows and columns are changed, even though the total amount of items is kept fixed (see below):
    Rows:100; Cols:100000 -> Used Memory: 43,05 MB
    Rows:1000; Cols:10000 -> Used Memory: 43,07 MB
    Rows:10000; Cols:1000 -> Used Memory: 43,24 MB
    Rows:100000; Cols:100 -> Used Memory: 44,96 MB
    Rows:1000000; Cols:10 -> Used Memory: 62,15 MB
    Rows:10000000; Cols:1 -> Used Memory: 192,15 MB
    Any ideas about the reasons for that behavior?
    Thanks,
    Marcelo

    mrnm wrote:
    In this case the memory consumption was around 20MB above the expected 38MB required for storing 10M integers.That's only the expected value if you assume that a 2D array of ints is nothing more than a bunch of ints lined up end to end. This is not the case. A "2D" array in java is really just a plain ol' array whose component type is "reference to array".
    The interesting thing is that the memory consumption varies when the numbers of rows and columns are changed, even though the total amount of items is kept fixed (see below):That's because, e.g., new int[200][100] creates 200 array objects (and references to each of them), each of which holds 100 ints, while new int[100][200] creates 100 array objects (and references to each of them), each of which holds 200 ints.
    Edited by: jverd on Feb 24, 2010 11:17 AM

  • Drawing multidimensional array values

    Hi all,
    Need a bit of advice about turning a multidimensional 64x64 array (consisting of doubles) into a picture(!). The array contains a large number of 0.0 values (also known as a sparse matrix). For each value in the array i want to plot a little Rectangle whose colour varies as a function of its value (the values in the array are normalised and range between 0.0 and +1.0). The location of each rectangle on the screen (or Frame/ Panel or whatever) should reflect the position of the value in the array i.e. a value at index myArray[0, 0] should appear in the top left hand corner of the screen (or whatever).
    I am not sure which way is the best to achieve this and am eager to hear some suggestions.
    Thx in advance

    I started going mental last time I thought about picturing multdimensional arrays. I got thinking along the lines that a 2D array looks like a grid, a 3D would look kinda like a cube... but then you hit 4D, and so on, and .... well, my mind just doesn't look like that.
    I think maybe the best way to visualize a massive multidimensional array would be almost like a directory structure. ie. One item can expand to have a bunch more items, which would in turn have more items. This is basically what a MD array is. And if you're talking about having to display the data, this might not be a bad arrangement, since you could actually expand/collapse single elements of the array, like a directory tree, and thus have less data cluttering your screen at one time.

  • Multidimensional Arrays + Me + OOP = Fear

    node.java
    class node {
         int[][] grid = new int[0][0];
         void detect(){
              System.out.println(grid);
    game.java
    class game {
         public static void main(String args[]) {
              node a = new node();
              a.detect();
    The output of this code is:
    http://img237.imageshack.us/img237/6556/outputxy7.png
    I am trying to create an imaginary grid so I can implement A* algorithm into my game which will later be an applet.
    Why did the output of this come out so weird? I do not understand multidimensional arrays and I struggle to understand object oriented programming.
    I have known Java since Nov 2006, but I have always dodge some of this difficult stuff. I am totally self taught and I have been learning through the Internet and a very old Java 2 book. So please speak "dumb" to me.
    Thank you,
    Andrew.

    Oh, grow up. If you get insulted this easily, you'll be inconsolable when you have to get a real job. I'm so sick of these children who want help but also want their genius to remain unquestioned.
    Anyway my point wasn't that you altered the image, but rather that you were careless in what you presented as data. Some of the stuff on that image couldn't possibly have worked with the code you posted. (In particular "java node" would not have even run. It wouldn't produce any output at all other than an error message.)
    Part of debugging is gathering real, useful, accurate information. And if you want help debugging you have to share real, useful, and accurate information. If you gather output and then change your code, you should at the very least make this clear.

  • Adding data to an array

    hi need help.. i need to add missing data for the array
    YY-Year
    MM-Month
    DD-Date
    mm-minutes
    ss-seconds
    Data  1YYMMDD mmss0 
    20.8 1090828 05050
    1.2   1090829 10150
    7.2   1090901 08400
    the above array is the data where i need to insert data for data til 090831
    as below
    Data  1YYMMDD mmss0 
    20.8 1090828 05050
    1.2   1090829 10150
    0      1090830 0
    0      1090831 0
    7.2   1090901 08400
    how to do this? and i need to check for every month is there data missing inbetween? Plz help
    Solved!
    Go to Solution.

    Yes.  You will need to iterate through your array.  Index out the current index and the index +1.  Translate the text into dates and use the date functions to determine if a date is missing.  If not, increase the index by 1 and repeat.  If a date is missing, insert a row and set the date to be the last date +1.  Repeat increasing your index which should make it the row you just added.

  • Without loops how can i read data from associative Array??

    Hi all,
    I am facing scenario like...
    i need to read data from associative array  without using loops is it possible,
    CREATE OR REPLACE PACKAGE BODY test_pkg IS
        TYPE t1 IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
       -- in array we can expect more than one row or sometimes no data also.
      FUNCTION test1(vt1 T1 DEFAULT CAST(NULL AS t1)) RETURN NUMBER IS
      BEGIN
        -- basically in array we'll get data of column2
        -- this loop should satisfies table1.colum2 = nvl(NULL, table2.colum2 )if array is null.
        -- if array is not null then only compare with array values
        FOR i IN (SELECT t1.colum1,t1.column2
                         FROM table1 t1, table1 t2
                              WHERE t1.colum1 = t2.column1
                                AND t1.colum2 = nvl(vt1, t2.colum2)
          LOOP
            generateTEXT(i.colum1, i.colum2);
         END LOOP;
      END test1;
    END test_pkg;
    in table1 we have date like...
    colum1          column2
    Jan                  1
    Feb                  2
    Mar                  3
    if i call select test_pkg.test1(1) from dual then output should
    be Jan..
    and
    select test_pkg.test1(null) from dual then it should display all elements from table1.
    Jan                  1
    Feb                  2
    Mar                  3,
    Thanks for your quick replay..

    i need to read data from associative array  without using loops is it possible,
    No - you would need to create a SQL type and then use the TABLE operator to unnest the collection.
    create or replace TYPE my_nums IS TABLE OF INTEGER;
    DECLARE
    --  TYPE my_nums IS TABLE OF PLS_INTEGER INDEX BY PLS_INTEGER;
      v_nums my_nums := my_nums(1, 2, 3);
      v_total number;
    BEGIN
      select sum(column_value) into v_total from table(v_nums);
      DBMS_OUTPUT.PUT_LINE
        ('Sum of the numbers is ' || TO_CHAR(v_total));
    END;
    Sum of the numbers is 6

  • How can I put data in an array which will be used in SPC plotting

    In my program, it will generate data continuously and I would like to store these data time to time in an array. Could you suggest me a method?
    For example, 1.77,1.67,1.56,1.89,1.99... (these data generated continuously)
    1st second: 1.77 1.67,1.56,1.89,1.99( store in array)
    After 1 second: 1.67,1.56,1.89,1.99,1.33 (remove the first one data in the array and replace it with the following generated data)
    How can I remove the data in the array and replace it with the other data?
    Could you give me some examples?
    Thanks

    Check the attached VI. It includes two methods. You can choose the one you like. I prefer the bottom one because only one extra memory for the subarray is created. The top one makes two copies because of the resize.
    Joe
    Attachments:
    Simple_Numerical_Que.vi ‏26 KB

  • How to put data into a array element in the BPEL

    Hi,
    I have a element in the WSDL which is of type Array. (i.e accepts unlimited data for the same element). How should i put a data into a array in the BPEL.
    Example:
    The below Example gives u an idea about wht iam asking:pasting a piece of my requirement:
    <s:element minOccurs="0" maxOccurs="1" name="parameters" type="tns:ArrayOfCSParameters" />
    <s:complexType name="ArrayOfCSParameters">
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="unbounded"
    name="CSParameters" nillable="true" type="tns:CSParameters" />
    </s:sequence>
    </s:complexType>
    <s:complexType name="CSParameters">
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="RevenueItem" type="tns:RevenueItem" />
    <s:element minOccurs="0" maxOccurs="1" name="AccountURIs" type="tns:ArrayOfString" />
    <s:element minOccurs="0" maxOccurs="1" name="GroupURIs" type="tns:ArrayOfString" />
    <s:element minOccurs="1" maxOccurs="1" name="Percentage" nillable="true" type="s:decimal" />
    </s:sequence>
    <s:attribute name="Version" type="s:decimal" use="required" />
    <s:attribute name="URI" type="s:string" />
    </s:complexType>
    Any suggestion is appreciated.
    Regards
    pavan

    You have 2 options i guess.
    Use the transformation and the for-each to construct the array-list
    or like Richard said, use a loop in bpel, assign in the loop an variable of element type="CSParameters" and append this variable to your variable with accepts the arraylist.

  • Error while assigning dates to associative array of date type

    Hi All,
    I am facing the issue while assigning dates to associative array of date type:
    Oracle Version:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Stored procedure i am trying to write is as following
    create or replace procedure jp1 (
    p_start_date date default trunc(sysdate,'MM')
    , p_end_date date default trunc(sysdate)
    is
    l_no_of_days number;
    type t_date_id is table of date
    index by pls_integer;
    l_date_id_arr t_date_id;
    begin
    l_no_of_days := p_end_date - p_start_date;
    for i in 0
    .. l_no_of_days - 1
    loop
        l_date_id_arr := p_start_date + i;
        dbms_output.put_line(p_start_date + i);
    end loop;
    end;
    I am getting error at line 14 while compiling this. and the error message is as following:
    Errors for PROCEDURE JP1:
    LINE/COL ERROR
    14/5     PL/SQL: Statement ignored
    14/22    PLS-00382: expression is of wrong type
    So while investigating this i tried to output the value of (p_start_date + i) using dbms_output.put_line and the output is date itself.
    create or replace procedure jp1 (
    p_start_date date default trunc(sysdate,'MM')
    , p_end_date date default trunc(sysdate)
    is
    l_no_of_days number;
    type t_date_id is table of date
    index by pls_integer;
    l_date_id_arr t_date_id;
    begin
    l_no_of_days := p_end_date - p_start_date;
    for i in 0 .. l_no_of_days-1
    loop
        --l_date_id_arr := p_start_date + i;
        dbms_output.put_line(p_start_date + i);
    end loop;
    end;
    output of the
    exec jp1
    is as following:
    01-DEC-13
    02-DEC-13
    03-DEC-13
    04-DEC-13
    05-DEC-13
    06-DEC-13
    07-DEC-13
    08-DEC-13
    09-DEC-13
    10-DEC-13
    11-DEC-13
    12-DEC-13
    13-DEC-13
    14-DEC-13
    15-DEC-13
    16-DEC-13
    17-DEC-13
    18-DEC-13
    I see the output as date itself. so why it is throwing error while assigning the same to associative array of date type.
    I tried to google also for the same but to no avail.
    Any help in this regard is appreciated or any pointer some other thread on internet or in this forum.
    Thanks in advance
    Jagdeep Sangwan

    Read about associative arrays :
    create or replace procedure jp1 (
    p_start_date date default trunc(sysdate,'MM')
    , p_end_date date default trunc(sysdate)
    ) is
    l_no_of_days number;
    type t_date_id is table of date
    index by pls_integer;
    l_date_id_arr t_date_id;
    begin
    l_no_of_days := p_end_date - p_start_date;
    for i in 0..l_no_of_days - 1
    loop
        l_date_id_arr(i) := p_start_date + i;
        dbms_output.put_line(p_start_date + i);
    end loop;
    end;
    Ramin Hashimzade

  • Error while retrieving data from an ARRAY resultset

    We hava an Oracle stroed procedure which has a table type as its OUT parameter and where the data is being entered into. This data requries to be returned to the Java client through a JDBC connection. We have used the OracleTypes' ARRAY object for this. We are facing errors when retieving data from the ARRAY resultset
    The Oracle Package
    ----I created a table type called "PlSqlTable":
    CREATE OR REPLACE TYPE PlSqlTable IS TABLE OF VARCHAR2(20);
    ----I defined this as the out parameter for my procedure :
    PROCEDURE testSQL
    arrayOutID OUT PlSqlTable
    Then populated the object :
    arrayOutID := PlSqlTable();
    arrayOutID.extend(4);
    arrayOutID(1):= 'Hello';
    arrayOutID(2) := 'Test';
    arrayOutID(3) := 'Ora';
    ----The procedure executes fine - all debug statements are printed ----right till the end of execution.
    The Java class
    ----Here is how I have defined the parameters :
    OracleCallableStatement stmnt = (OracleCallableStatement)connection.prepareCall("begin testSQL(?);end;");
    stmnt.registerOutParameter(2,OracleTypes.ARRAY,"PLSQLTABLE");
    System.out.println("Executing..");
    stmnt.execute();
    System.out.println("Executed..");
    ARRAY outArray = stmnt.getARRAY(1);
    System.out.println("Got array");
    ResultSet rset = outArray.getResultSet();
    System.out.println("Got Resultset..");
    int i = 1;
    while(rset.next()){
    System.out.println("VALUE : " + rset.getString(i));
    i = i+1;
    ----On execution, the debug messages display :
    Executing..
    Executed..
    Got array
    Got Resultset..
    VALUE : 1
    VALUE : Test
    ERROR : java.sql.SQLException: Invalid column index
    ----But I have populated upto 3 values in th e procedure. Then why this error ?
    PLLLEEEASE help me out on this.
    Thanks, Sathya

    haven't worked with db arrays but I think your problem is here:int i = 1;
    while(rset.next()){
         System.out.println("VALUE : " + rset.getString(i));
         i = i+1;
    }In the first loop you are retrieving the value from column 1(rs.getString(1)), which is OK, but in the second loop, you are trying to retrieve a value from the second column(rs.getString(2)) which doesn't exist. Try this code which only reads from column1:
    while(rset.next()){
         System.out.println("VALUE : " + rset.getString(1));
    }Jamie

  • Need help in putting data into 2d array

    My input file :
    1 , 2 , 1
    2 , 2 , 1
    3 , 3 , 1
    4 , 2 , 2
    2 , 3 , 2I'm stuck at:
    while( reader.readLine() != null){
    String Matrix[] = line.split(",");
    }Means I only can read how many lines there. For 2d array, Matrix[i][j], is that when I count the line, the number of count will be the 'i'? How about 'j'? Am I need to count i and j before put the data into 2d array?
    Do correct me if something wrong in:
    while( reader.readLine() != null){
    String Matrix[] = line.split(",");
    } Thank you.

    gtt0402 wrote:
    while( reader.readLine() != null){
    String Matrix[] = line.split(",");
    How about:
    ArrayList<String[]> rows = new ArrayList<String[]>();
    while((line = reader.readLine()) != null) {
        rows.add(line.split(","));
    }After the loop you have a list full of String arrays and you can convert it to a 2D String array if you wish.

Maybe you are looking for

  • How to Add multiple entry to the group policy security filtering

    How to Add multiple entry to the group policy security filtering Is there any way we can add multiple entry to the Domain group policy Security filtering tab.Currently its not allowing to add more then one entry at a time. Getting Error like "only on

  • What's Going On With Adobe's New Upgrade Policy?

    My old system died today, so I quickly finished the new system I was building to get up and running as quickly as possible. I tried to re-install my 2 year old copy of CS5 on the new machine, and see at the licenseing step that I had to have either C

  • Games not appearing in iTunes library

    So since I updated iTunes to 7.7.1 and the applications section was added (unless it was added in the update before that) I can no longer see the games section. When I sync to my iPod it only has the default games that it originally came with. Also w

  • Error : Summary String length exceeds maximum

    I just got an error while trying to Update a User on my IDM instance. com.waveset.util.InternalError  :  Summary String length (3003) exceeds maximum (2048) I already checked this forum for similar issues, and I found a couple of threads. However, fo

  • ASA DMVPN for Azure Cloud

    Hello, It looks like one of our customers need to buy ISR's to connect to the Azure cloud from Microsoft via DMVPN, since Cisco ASA doesn't support it (yet). Will ASA support this in nearby future release? Anybody has eventually suggestions? (Apart f