Gahering Data for Random Array

I've searched the boards for help on this and doing so has
taught me SOME of what I need to do, but not all.
I think I can construct an array now, but what I need to know
how to do is GATHER the data for the array from user-inputted text,
then have Flash return a # of those inputs at random.
It's for drug screening. I need to be able to input Employee
names (collected by the array) and then enter the # of employees I
want to have tested (say 6 out of 20 names entered). Then I want
Flash to give me 6 of those names at random without duplicating.
Like I said, from searching here, I think I learned how to
build the array using the dynamic text boxes. What I haven't seen
is how to return X # of that data to the user at random.
Any ideas?

Once you have an array, you can shuffle it and then just
count off however many elements you need.
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid =1170742&highlight_key=y&keyword1=shuffle
Obviously I am partial to the one that I have posted about
halfway down. :)
And it looks like blemmo has improved it at the end of this
thread.
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid =1039424&highlight_key=y&keyword1=shuffle
But I would still recommend including the ASSetPropFlag line
from my post.

Similar Messages

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

  • Transposing data in an array using a For Loop

    I am trying to transpose some data in an array using a  for loop starting from the size of the array then decrement down to 0. Can someone please help if you have an example?
    Solved!
    Go to Solution.

    I feel as if reverse 1D array may help
    Edit: misunderstood what your second post meant.
    CLA, LabVIEW Versions 2010-2013

  • Tables's data scrambled (randomized) for testing purposes

    Dear Oracle People,
    I need to scramble (randomize) the date for testing purposes
    How I can do that within Oracle
    Source:
    CODE          FIRST_NAME     LAST_NAME
    1          FN_1               LN_1
    2          FN_2               LN_2
    3          FN_3               LN_3
    Target after scrambling:
    CODE          FIRST_NAME     LAST_NAME
    1          FN_2               LN_3
    2          FN_3               LN_1
    3          FN_1               LN_2

    Source table: t1
    Target table: t2 (create table t2 as select * from t1)
    Something like this would do:
    DECLARE
    rc NUMBER;
    BEGIN
    SELECT COUNT (*) INTO rc FROM t1;
    FOR i IN (SELECT last_name FROM t1)
    LOOP
    UPDATE t2
    SET last_name = i.last_name
    WHERE code = ROUND (DBMS_RANDOM.VALUE (1, rc));
    END LOOP;
    END;

  • Identical random sort for 2 arrays

    Hi,
    I got this function, which is sorting my array in a random way.
    private function randomSort(objA:Object, objB:Object):int {
           return Math.round(Math.random() * 2) - 1
    arr.sort(randomSort);
    I need to shuffle another array, but I need it to have exactly the same random order as the first one. If I use the same funcition:
    arr2.sort(randomSort);
    I will get different order in both arrays.
    Is there a possiblility to randomize two arrays in the same order?

    you're not randomizing array elements because:
    1.  you probably don't want a uniform distribution of -1,0,1.  you probably only want to return 0, if the array elements are the same.
    2.  if you do want a uniform distribution of -1,0,1:
    n = Math.round(Math.random() * 2) - 1
    won't give it to you:  n=0 (1/2 the time), n=-1 (1/4 the time), n=1 (1/4 the time)

  • Fpga Simulation from Custom VI'a. Problem with reading TDMS data for simulation.

    Hi there. I am havin a small no Big problem trying to use certein data for simulation purpose. All I/O are set up in custom Via. Everything works fine when it is set up like on a pic.1 Unfortunatly I would like to use certein data writtent to TDMS file. I tried to do it like in PIC2. It works on normal VI'a. It reads the file to array. Unfortunatly I don't know how to make it works in custom via set up for FPGA simulation. I am getting 0.
    PIC.1 Random data...
    PIC.2 Data from a file format.

    oki I managed my self. For some reason I had to skip first number in the array.

  • 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 import Data (For Dummies) into a table

    I have a excel spreadsheet that is an export of an oracle database table. I want to now import that data into another Oracle Database (same table and format). What is the best way to do that. Someone told me t ouse SQL*Loader, but that is not as straightforward as I had hoped. I tried to use access, but I got an invalid argument on one attempt, and a Reserved Error (-2007) on another attempt.
    Any help would be appreciated.

    Now it seemed to run w/o the INSERT error this time, but now when I look at the log, i see the following errors:
    SQL*Loader: Release 9.2.0.1.0 - Production on Tue Jun 27 10:29:01 2006
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Control File: sqlloader-ctrl.ctl
    Data File: import.txt
    Bad File: import.bad
    Discard File: none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 50
    Bind array: 64 rows, maximum of 256000 bytes
    Continuation: none specified
    Path used: Conventional
    Table INQUIRIES, loaded from every logical record.
    Insert option in effect for this table: APPEND
    Column Name Position Len Term Encl Datatype
    INQUIRYID FIRST * WHT O(") CHARACTER
    PERSONID NEXT * WHT O(") CHARACTER
    FIRSTNAME NEXT * WHT O(") CHARACTER
    LASTNAME NEXT * WHT O(") CHARACTER
    ADDRESS1 NEXT * WHT O(") CHARACTER
    ADDRESS2 NEXT * WHT O(") CHARACTER
    ADDRESS3 NEXT * WHT O(") CHARACTER
    CITY NEXT * WHT O(") CHARACTER
    STATE NEXT * WHT O(") CHARACTER
    ZIPCODE NEXT * WHT O(") CHARACTER
    COUNTRY NEXT * WHT O(") CHARACTER
    SEX NEXT * WHT O(") CHARACTER
    MATRICDATE NEXT * WHT O(") CHARACTER
    DEGREEPROGRAM NEXT * WHT O(") CHARACTER
    PACKETCODE NEXT * WHT O(") CHARACTER
    SOURCECODE NEXT * WHT O(") CHARACTER
    NONUS NEXT * WHT O(") CHARACTER
    DUPLICATE NEXT * WHT O(") CHARACTER
    EMAIL NEXT * WHT O(") CHARACTER
    INQUIRYDATE NEXT * WHT O(") CHARACTER
    NOTES NEXT * WHT O(") CHARACTER
    GOODCANDIDATE NEXT * WHT O(") CHARACTER
    POSTED NEXT * WHT O(") CHARACTER
    LABELPRINTED NEXT * WHT O(") CHARACTER
    PHONE NEXT * WHT O(") CHARACTER
    PERMANENTRESIDENCE NEXT * WHT O(") CHARACTER
    LABELPRINTDATE NEXT * WHT O(") CHARACTER
    LASTMODIFIED NEXT * WHT O(") CHARACTER
    MODIFYINGUSER NEXT * WHT O(") CHARACTER
    APPRECEIVED NEXT * WHT O(") CHARACTER
    INTERVIEWED NEXT * WHT O(") CHARACTER
    INTERVIEWEDDATESCHEDULED NEXT * WHT O(") CHARACTER
    INTERVIEWEDDATE NEXT * WHT O(") CHARACTER
    INTERVIEWEDBY NEXT * WHT O(") CHARACTER
    INTERVIEWEDRATING NEXT * WHT O(") CHARACTER
    DUALDEGREE NEXT * WHT O(") CHARACTER
    Record 1: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 2: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 3: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 4: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 5: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 6: Rejected - Error on table INQUIRIES, column MODIFYINGUSER.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 7: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 8: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 9: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 10: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 11: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 12: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 13: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 14: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 15: Rejected - Error on table INQUIRIES, column PERMANENTRESIDENCE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 16: Rejected - Error on table INQUIRIES, column PHONE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 17: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 18: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 19: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 20: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 21: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 22: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 23: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 24: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 25: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 26: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 27: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 28: Rejected - Error on table INQUIRIES, column MODIFYINGUSER.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 29: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 30: Rejected - Error on table INQUIRIES, column MODIFYINGUSER.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 31: Rejected - Error on table INQUIRIES, column MODIFYINGUSER.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 32: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 33: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 34: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 35: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 36: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 37: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 38: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 39: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 40: Rejected - Error on table INQUIRIES, column MODIFYINGUSER.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 41: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 42: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 43: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 44: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 45: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 46: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 47: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 48: Rejected - Error on table INQUIRIES, column LASTMODIFIED.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 49: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 50: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    Record 51: Rejected - Error on table INQUIRIES, column LABELPRINTDATE.
    Column not found before end of logical record (use TRAILING NULLCOLS)
    MAXIMUM ERROR COUNT EXCEEDED - Above statistics reflect partial run.
    Table INQUIRIES:
    0 Rows successfully loaded.
    51 Rows not loaded due to data errors.
    0 Rows not loaded because all WHEN clauses were failed.
    0 Rows not loaded because all fields were null.
    Space allocated for bind array: 250776 bytes(27 rows)
    Read buffer bytes: 1048576
    Total logical records skipped: 0
    Total logical records read: 51
    Total logical records rejected: 51
    Total logical records discarded: 0
    Run began on Tue Jun 27 10:29:01 2006
    Run ended on Tue Jun 27 10:29:01 2006
    Elapsed time was: 00:00:00.21
    CPU time was: 00:00:00.05
    So now i need to do some google searching to see what those erros mean...... ahh the life of IT... ya gotta love it

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

  • (Urgent help needed) how to read txt file and store the data into 2D-array?

    Hi, I have a GUI which allow to choose file from the file chooser, and when "Read file" button is pressed, I want to show the array data into the textarea.
    The sample data is like this followed:
    -0.0007     -0.0061     0.0006
    -0.0002     0.0203     0.0066
    0     0.2317     0.008
    0.0017     0.5957     0.0008
    0.0024     1.071     0.0029
    0.0439     1.4873     -0.0003
    I want my program to scan through and store these data into 2D array.
    However for some reason, my source code issues errors, and I don't know what's wrong with it, seems to have a problem in StringTokenizer though. Can anybody help me?
    Thanks in advance.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.StringTokenizer;
    public class FileReduction1 extends JFrame implements ActionListener{
    // GUI features
    private BufferedReader fileInput;
    private JTextArea textArea;
    private JButton openButton, readButton,processButton,saveButton;
    private JTextField textfield;
    private JPanel pnlfile;
    private JPanel buttonpnl;
    private JPanel buttonbar;
    // Other fields
    private File fileName;
    private String[][] data;
    private int numLines;
    public FileReduction1(String s) {
    super(s);
    // Content pane
         Container cp = getContentPane();
         cp.setLayout(new BorderLayout());     
    // Open button Panel
    pnlfile=new JPanel(new BorderLayout());
         textfield=new JTextField();
         openButton = new JButton("Open File");
    openButton.addActionListener(this);
    pnlfile.add(openButton,BorderLayout.WEST);
         pnlfile.add(textfield,BorderLayout.CENTER);
         readButton = new JButton("Read File");
    readButton.addActionListener(this);
         readButton.setEnabled(false);
    pnlfile.add(readButton,BorderLayout.EAST);
         cp.add(pnlfile, BorderLayout.NORTH);
         // Text area     
         textArea = new JTextArea(10, 100);
    cp.add(new JScrollPane(textArea),BorderLayout.CENTER);
    processButton = new JButton("Process");
    //processButton.addActionListener(this);
    saveButton=new JButton("Save into");
    //saveButton.addActionListener(this);
    buttonbar=new JPanel(new FlowLayout(FlowLayout.RIGHT));
    buttonpnl=new JPanel(new GridLayout(1,0));
    buttonpnl.add(processButton);
    buttonpnl.add(saveButton);
    buttonbar.add(buttonpnl);
    cp.add(buttonbar,BorderLayout.SOUTH);
    /* ACTION PERFORMED */
    public void actionPerformed(ActionEvent event) {
    if (event.getActionCommand().equals("Open File")) getFileName();
         if (event.getActionCommand().equals("Read File")) readFile();
    /* OPEN THE FILE */
    private void getFileName() {
    // Display file dialog so user can select file to open
         JFileChooser fileChooser = new JFileChooser();
         fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
         int result = fileChooser.showOpenDialog(this);
         // If cancel button selected return
         if (result == JFileChooser.CANCEL_OPTION) return;
    if (result == JFileChooser.APPROVE_OPTION)
         fileName = fileChooser.getSelectedFile();
    textfield.setText(fileName.getName());
         if (checkFileName()) {
         openButton.setEnabled(false);
         readButton.setEnabled(true);
         // Obtain selected file
    /* READ FILE */
    private void readFile() {
    // Disable read button
    readButton.setEnabled(false);
    // Dimension data structure
         getNumberOfLines();
         data = new String[numLines][];
         // Read file
         readTheFile();
         // Output to text area     
         textArea.setText(data[0][0] + "\n");
         for(int index=0;index < data.length;index++)
    for(int j=1;j<data[index].length;j++)
    textArea.append(data[index][j] + "\n");
         // Rnable open button
         openButton.setEnabled(true);
    /* GET NUMBER OF LINES */
    /* Get number of lines in file and prepare data structure. */
    private void getNumberOfLines() {
    int counter = 0;
         // Open the file
         openFile();
         // Loop through file incrementing counter
         try {
         String line = fileInput.readLine();
         while (line != null) {
         counter++;
              System.out.println("(" + counter + ") " + line);
    line = fileInput.readLine();
         numLines = counter;
    closeFile();
         catch(IOException ioException) {
         JOptionPane.showMessageDialog(this,"Error reading File",
                   "Error 5: ",JOptionPane.ERROR_MESSAGE);
         closeFile();
         System.exit(1);
    /* READ FILE */
    private void readTheFile() {
    // Open the file
    int row=0;
    int col=0;
         openFile();
    System.out.println("Read the file");     
         // Loop through file incrementing counter
         try {
    String line = fileInput.readLine();
         while (line != null)
    StringTokenizer st=new StringTokenizer(line);
    while(st.hasMoreTokens())
    data[row][col]=st.nextToken();
    System.out.println(data[row][col]);
    col++;
    row++;
    closeFile();
    catch(IOException ioException) {
         JOptionPane.showMessageDialog(this,"Error reading File",
                   "Error 5: ",JOptionPane.ERROR_MESSAGE);
         closeFile();
         System.exit(1);
    /* CHECK FILE NAME */
    /* Return flase if selected file is a directory, access is denied or is
    not a file name. */
    private boolean checkFileName() {
         if (fileName.exists()) {
         if (fileName.canRead()) {
              if (fileName.isFile()) return(true);
              else JOptionPane.showMessageDialog(null,
                        "ERROR 3: File is a directory");
         else JOptionPane.showMessageDialog(null,
                        "ERROR 2: Access denied");
         else JOptionPane.showMessageDialog(null,
                        "ERROR 1: No such file!");
         // Return
         return(false);
    /* FILE HANDLING UTILITIES */
    /* OPEN FILE */
    private void openFile() {
         try {
         // Open file
         FileReader file = new FileReader(fileName);
         fileInput = new BufferedReader(file);
         catch(IOException ioException) {
         JOptionPane.showMessageDialog(this,"Error Opening File",
                   "Error 4: ",JOptionPane.ERROR_MESSAGE);
    System.out.println("File opened");
    /* CLOSE FILE */
    private void closeFile() {
    if (fileInput != null) {
         try {
              fileInput.close();
         catch (IOException ioException) {
         JOptionPane.showMessageDialog(this,"Error Opening File",
                   "Error 4: ",JOptionPane.ERROR_MESSAGE);
    System.out.println("File closed");
    /* MAIN METHOD */
    /* MAIN METHOD */
    public static void main(String[] args) throws IOException {
         // Create instance of class FileChooser
         FileReduction1 newFile = new FileReduction1("File Reduction Program");
         // Make window vissible
         newFile.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         newFile.setSize(500,400);
    newFile.setVisible(true);
    Java.lang.NullpointException
    at FileReductoin1.readTheFile <FileReduction1.java :172>
    at FileReductoin1.readFile <FileReduction1.java :110>
    at FileReductoin1.actionPerformed <FileReduction1.java :71>
    .

    1) Next time use the CODE tags. this is way too much unreadable crap.
    2) The problem is your String[][] data.... the only place I see you do anything approching initializing it is
    data = new String[numLines][];I think you want to do this..
    data = new String[numLines][3];anyway that's why it's blowing up on the line
    data[row][col]=st.nextToken();

  • How do you store parsed XML data in an array

    Hi, i am trying to complete a small program which implements the SAX parser to parse an XML file. My problem is that i am writing a custom class to store the parsed data into an array, and then make the array available to the main program via a simple method which returns the array. I know this must be very simple to do, but i seem to have developed a mental block with this part of the program. I can parse the data and print all the elements to the screen, but i just cant figure out how to store all the data elements into the array. I will post the class which is supposed to do this, and ask anyone out there if they know what i'm doing wrong, and also, if there is a more effeicient way of achieving this ( i expect there definitely is!! but i have never used the SAX parser before and am getting confused by the API docs on it!!) Any help very much appreciated.
    Here is my attempt at coding the class to handle the parsed XML data
    class Sink extends org.xml.sax.helpers.DefaultHandler
         implements org.xml.sax.ContentHandler{
    Customer[] customers = new Customer[20];
         int count = 1;
         int x = 0;
         int tagCount = 0;
         String name;
    String custID;
         String username;
         String address;
         String phoneNum;
    public void startElement(String uri, String localName, String rawName, final org.xml.sax.Attributes attributes)throws org.xml.sax.SAXException{
    //count the number of <name> tags in the XML file
         if(rawName.equals("name")){
              tagCount++;
    public void characters(char[] ch, int start, int len){
    //get the current string
         String text = new String(ch, start, len);
         String text1 = text.trim();
    //there are 5 elements for each customer found in the XML file so when the count reaches 6
    // i reset this to 1
         if(count == 6){
         count = count - 5;
         if(text1.length()>0 && count == 1){
              name = text1;
              System.out.println(name);
              }else{
         if(text1.length()>0 && count == 2){
              custID = text1;
              System.out.println(custID);
                   }else{
                   if(text1.length()>0 && count == 3){
                   username = text1;
                   System.out.println(username);
                   }else{
                        if(text1.length()>0 && count == 4){
                        address = text1;
                        System.out.println(address);
                        }else{
                        if(text1.length()>0 && count == 5){
                             phoneNum = text1;
                             System.out.println(phoneNum);
                             //add data to the customer array
                             customers[x] = new Customer(name, custID, username, address, phoneNum);
    // increment the array index counter
                        x = x+1;
                        }//end of if
                        }//end else
                        }//end else
                   }//end else
              }//end else
    }//end of characters method
    public void endDocument(){
         System.out.println("There are " + tagCount +
         " <name> elements.");
    }//end of class Sink
    Before the end of this class i also need to make the array available to the calling program!!
    Any help would be much appreciated
    Thanks
    Iain

    Ok, yer going about this all the wrong way. You shouldn't have to maintain a count of all the elements. Basically you are locking yourself into the XML tags not only all being there but are assuming they are all in the same order. What you should do is in your characters() method, put all of the characters into a string buffer. Then, in endElement() (which you dont use btw, you should) you grab the information that is in the string buffer and store it into your Customer object depending on what the tagName is.
    Also, you should probably use a List to store all the Customer objects and not an single array, it's more dynamic and you arent locked into a set number of Customers.
    I wont do it all for you, but I'll give you a good outline to use.
    public class CustomerHandler extends DefaultHandler {
        private java.util.List customerList;  // List of Customer objects
        private java.util.StringBuffer buf;   // StringBuffer to store the string of characters between the start and end tags
        private Customer customer;  // Customer object that is initialized with each entry.
        public CustomerHandler() {
            customerList = new java.util.ArrayList();   // Initialize the List
            buf = new java.util.StringBuffer();   // Initialize the string buffer
        //  Make your customer list available to other classes
        public java.util.List getCustomerList() {
            return customerList;
        public void startElement(String nsURI, String sName, String tagName, Attributes attributes) throws SAXException {
            // Clear the String Buffer
            //  If the tagName is "Customer" then create a new Customer object
        public void characters(char[] ch, int start, int length) {
            //  append the characters into the string buffer
        public void endElement(String nsURI, String sName, String tagName) throws SAXException {
            // If the tagName is "Customer" add your customer object to the List
            // Place the data from the String Buffer into a String
            //  Depending on the tagName, call the appropriate set method on your customer object
    }

Maybe you are looking for