Insert values in an array (within a function)

Hello,
I can't seem to get values insert in an array. I know it
works outsite the function but
when using variables in a function and trying to insert this
in an array it does not work.
The values are empty.
But if you uncomment the line someArray.push(a0,a1,a2) and
uncommend the for loop it works.
In actionscript 2.0 i could use eval ..but in actionscript
3.0 you have to use this to convert a string to a value.
Does anyone see, what i am doing wrong?
function doSomething() {
var a0:String = "hello";
var a1:String = "why doesn't it";
var a2:String = "work!";
var someArray:Array = new Array();
//someArray.push(a0,a1,a2);
for (var i:uint =0; i<=3; i++) {
someArray.push(this["a"+i]);
trace(someArray);
doSomething();

In this case, the problem arises from a scope issue. The vars
are defined within the function so they are visible only within the
function. When you use "this" you are referencing the object that
contains the function, which cannot see those vars (they do not
exist for "this", only for the function). It works if you go this
way...
var a0:String = "hello";
var a1:String = "why doesn't it";
var a2:String = "work!";
function doSomething() {
var someArray:Array = new Array();
for (var i:uint=0; i<3; i++) {
someArray.push(this["a"+i]);
trace(someArray);
doSomething();
The other line: someArray.push(a0,a1,a2);
does work because it is within the function and can see the
vars.

Similar Messages

  • How to insert values into an array of class

    Hello everyone,
    I need help in inserting values into an array of class, which i have read from a file.
    Length of the array is 5. I should insert values one by one into that array.
    If the array is full (if count = 5), then I should split the array into 2 arrays
    and adjust the values to left and right with median.
    I'm getting an ArrayBoundException .. can anybody help me out ?
    Thanks in advance
    Here is my code..........
    import java.util.*;
    import java.io.*;
    public class Tree
         static String second;
         static String first;
         static int count = 5;
         public void insert(int f1,int s1, int c)
              if(c!=0)
                   Record[] rec = new Record[4];
                   for (int i = 0; i < 5; i++)
                          rec[i] = new Record(); 
                   for(int i = 0; i<=4;i++)
                        rec.x = f1;
                        rec[i].y = s1;
              else
                   System.out.println("yes");
         public static void main(String[] args)
              Tree t = new Tree();
              try
                   FileReader fr = new FileReader("output.txt");           // open file
                   BufferedReader br = new BufferedReader(fr);
                   String s;
                   while((s = br.readLine()) != null)
                        StringTokenizer st = new StringTokenizer(s);
                        while(st.hasMoreTokens())
                             first = st.nextToken();
                             second = st.nextToken();
                        //     System.out.println("First-->"+first+" "+"Second-->"+second);
                        int fir = Integer.parseInt(first);
                        int sec = Integer.parseInt(second);
                        t.insert(fir, sec, count);                    
                   fr.close(); // close file           
              catch (IOException e)
    System.out.println("Can't read file");
    class Record
         public int x,y;

    Hi qwedwe.
    Record[] rec = new Record[4];
                   for (int i = 0; i < 5; i++)
                          rec[i] = new Record(); 
                     }Here is your error: you have an array of 4 Records, but you create and (try to) insert 5 Record-instances.... try:
    Record[] rec = new Record[c];
                   for (int i = 0; i < c; i++)
                          rec[i] = new Record(); 
                     }Regards,
    Norman

  • Getting an Array from a multi-dimentional Array within a Function

    Don't know how to explain it but here, firstly, I can't get past. Also had this problem with another thing I was trying.
    ReferenceError: Error #1056: Cannot create property 0 on Number.
    I googled and found out about automatically declare stage instances, that was fine, I had the box checked.
    Basically, it is failing at even the simplest. I have this function:
    function getInfoOf(i) { // enemy count, info count
        var _info:Array = new Array(3, 6);
        // 0 is you
        _info[0,Const.MAXHP] = 500;
        _info[0,Const.CURRENTHP] = 500;
        _info[0,Const.LEVEL] = 5;
        _info[0,Const.EXP] = 5500;
        _info[0,Const.NAME] = "You";
        _info[0,Const.LINKEDMC] = "NONE";
        // then a few more _info's.
    Then, trying everything to get it to work, I stripped it so no returns. So in the code, in the init() part of the project (only called once), have getInfoOf(0), and tried any other numbers. I recieve that error, and cannot for the life of me figure out whats wrong (I have also tested the "Const"'s. they are integers, and I have tested using numbers in  place of those. Still same error, it only goes away when I don't call the function at all.
    Any help would be greatly appreciated.
    Thanks.
    Message was edited by: brokenhope
    The array is actually (3,6), messed that up.

    I don't know whats wrong here. I tried to get it to work on the project, still same exact error. So, I tried it on a entirely new project, and still get the exact same error. So I also put in a new function to test with no array.
    stop();
    function getInfoOf2():void {
        var blah = "testwat";
        trace(blah);
        return;
    function getInfoOf():void {
        var info:Array=new Array(3);
        for(var i:int=0; i<info.length; i++) {
            info[i]=new Array(6);
        // 0
        info[0,0] = 500;
        info[0,1] = 500;
        info[0,2] = 5;
        info[0,3] = 5500;
        info[0,4] = 0;
        info[0,5] = 0;
        return;
    this.getInfoOf2();
    this.getInfoOf();
    the function still fails, but the first function doesn't.
    testwat
    ReferenceError: Error #1056: Cannot create property 0 on Number.
        at Untitled_fla::MainTimeline/getInfoOf()
        at Untitled_fla::MainTimeline/frame1()
    any ideas, I did a few traces, that message appears at the first info[0][0].
    Thanks.

  • Inserting a literal text string within a function

    This should be an easy function to write but I am plenty rusty and am missing something here:
    I have a list of numbers which total 11 when all numbers are entered. I want to average the numbers once all values are entered - $E$21 will equal 11 when all values are entered ( I used: =COUNTIF(E10:E20,">0")  That function works fine and keeps a running total of how many values have been entered and when all 11 are entered, it gives the average.
    Here's the formula and of course it works, entering 0 until all 11 values are entered:
    =-IF($E$21=11,AVERAGE(E9:E19),0)
    But the secretary wants it to say "Calculating" instead of zero if all numbers are still being entered so I tried to enter the string "Calculating" in place of the zero for condition if false (that is: =-IF($E$21=11,AVERAGE(E9:E19),"Calculating") and the function fails. I thought I could do that but there is something I just don't know here. I apologize in advance since this is probably a simple gap in my understanding but can anyone help me with my formula. Thanks in advance

    Maybe this is what you want?
    E1=IF(COUNTA(A1:D1)>0, IF(COUNTA(A1:D1)<4, "Calculating",AVERAGE(A1:D1) ) ,"")
    this is shorthand for... select cell E1, then type (or copy and paste from here) the formula:
    "=IF(COUNTA(A1:D1)>0, IF(COUNTA(A1:D1)<4, "Calculating",AVERAGE(A1:D1) ) ,"")"

  • Database connection(select ,insert query) within javascript function

    Hi ,
    How to write the database connection(insert,delete or select query) within javascript function.Is it possible.Anyone can you help me
    than you

    Hi ,
    How to write the database connection(insert,delete
    ete or select query) within javascript function.Is it
    possible.No

  • ORA-14551 Call to a proc that performs INSERT from within a FUNCTION

    Anyone,
    I have written a number of functions that serve to convert an old_value to a new_value. But there are some times when the conversion fails. I wish to log those exceptions into a table and move on. I undertand FUNCTIONS are not to insert data but that is why I created a PROC and want to be able to call it from within the FUNCTIONs.
    Is there any way to get around the ORA-14551 error?
    Here is what I have:
    CREATE OR REPLACE FUNCTION MAXIMO.fcn_get_worktype
      ( worktype_IN IN varchar2,
        siteid_IN IN varchar2)
      RETURN  varchar2 IS
      var_worktype varchar2(5);
    BEGIN
         IF siteid_IN IN ('ML','OK','BE') THEN
            BEGIN
                 SELECT NVL(NEW_WTYPE,NULL)
                INTO var_worktype
                 FROM MAXIMO.MAX411_WBK_WORKTYPE$
                 WHERE OLD_WTYPE = worktype_IN;
            EXCEPTION
                WHEN NO_DATA_FOUND THEN
                    MAXIMO.SP_CONVERSION_EXCEPTION('WORKTYPE', 'WORKTYPE', worktype_IN, siteid_IN);
                    var_worktype := 'XX';
                     RETURN var_worktype;
            END;
        END IF;
        RETURN var_worktype ;
    END;And here is my PROC:
    CREATE OR REPLACE PROCEDURE MAXIMO.sp_conversion_exception (table_IN IN VARCHAR2, column_IN IN VARCHAR2, value_IN IN VARCHAR2, tab_ID IN VARCHAR2)
    IS
    BEGIN
        INSERT INTO MAXIMO.MAX411_CONVERSION_EXCEPTIONS
             ( TABLE_NAME,
             COLUMN_NAME,
             VALUE ,
              TAB_ID)
        VALUES
             ( table_IN,
             column_IN,
             value_IN,
              tab_ID );
        EXCEPTION
            /* If value was already recorded then do not record again, Key is on all three columns */
            WHEN DUP_VAL_ON_INDEX
                THEN
                    NULL;
        COMMIT;
    END;Can anyone shed any light on how I can stop getting:
    ERROR at line 1:
    ORA-14551: cannot perform a DML operation inside a query
    ORA-06512: at "MAXIMO.SP_CONVERSION_EXCEPTION", line 5
    ORA-06512: at "MAXIMO.FCN_GET_WORKTYPE", line 16
    ORA-01403: no data found
    ORA-06512: at "MAXIMO.LOAD_PM", line 181
    ORA-06512: at line 1
    Thanks in advance for any help I can get...
    Miller

    You need a PRAGMA AUTONOMOUS_TRANSACTION in your exception procedure, eg:
    CREATE OR REPLACE PROCEDURE MAXIMO.sp_conversion_exception (table_IN IN VARCHAR2, column_IN IN VARCHAR2, value_IN IN VARCHAR2, tab_ID IN VARCHAR2)
    IS
      PRAGMA AUTONOMOUS_TRANSACTION
    BEGIN
      ...

  • Last One I Promise! Inserting A Value In An Array And Shifting TheRest Over

    Last question I have, I need to know the theory behind inserting a value into an array and shifting the rest over.. I have somewhat of an idea and that is this:
    Obviously I need to use a for loop, and a temp value to hold each value until it shifts then move on to the next value? Oh and increase the size of the array by one? I'm having trouble making sense of it..
    lets say we have the same array as from before
              int[] aRay = new int[5];
              aRay[0] = 1;
              aRay[1] = 9;
              aRay[2] = 3;
              aRay[3] = 4;
    aRay[4] = 11;
    and we want to add... lets say the element 5 into the index spot of 2 is and shift 2 to 3 and 3 to 4 and 4 to 5.
    for ( int i = 0; i < aRay.length; i++) // this will move along each element of the array (so I know I need this for sure)
    Am I on the right track? thanks all
    Edited by: Jojobaba on May 13, 2008 11:50 PM
    Edited by: Jojobaba on May 13, 2008 11:54 PM

    Jojobaba wrote:
    I can do all that, the only trouble I'm having right now is what's the correct way to increase the size of the array by one more? if I try to declare 4 as 5 it gives me a runtime error because 5 is out of bounds, and rightly so, because it doesn't exist
    Once I get that, the rest will be cake
    int[] aRay = new int[5];
    ^
    l
    l
    Do I just make this a 6? or is that not the right way.. :/You can't change array sizes dynamically. You will have to make a new array of the appropriate size and copy into it. You could use copyOf: http://java.sun.com/javase/6/docs/api/java/util/Arrays.html#copyOf(int[],%20int)
    I hope this is purely an academic exercise, because there's no reason to do this.

  • Changing Property Values from within a Function

    I'm wondering how I can change a property of an instance from
    within a function inside a method. I have some code here...
    Basically I just need to set _lynn_idle to false when a tween is
    occuring and _lynn_idle to true when the tween is finished.
    Unfortunately I can't seem to simply set it to false or true inside
    these listener functions like I'm able to anywhere else (seems the
    variable is only local to the function when I need it to access the
    variable associated with the instance). Any help is much
    appreciated.

    Inside callback handlers the class members go out of scope.
    To remedy use a local (local to the function) reference to the
    current object.

  • Can't duplicate movieclips as an array within an array

    Hello.
    I have an animation that loads an xml into it and traces back
    an array within an array. I have tried to apply this to duplicated
    movieclips thereby creating a structured set of links. What I am
    trying to do is this:
    Chicken Nuggets
    __Compression
    __Texture
    __Disgust
    Mega Warhead
    __Taste
    __Hardness
    __Pain
    This traces fine but I can't seem to get the duplicated
    movieclips to assemble in this fashion.
    The code for the XML is as follows:
    var controlArray:Array;
    var variable:Array;
    var testTopic = new Array ();
    var test = new Array ();
    var controlsXML:XML = new XML();
    controlsXML.ignoreWhite = true;
    controlsXML.onLoad = function(success:Boolean){
    if (success){
    var mainnode:XMLNode = controlsXML.firstChild;
    var controlNodes:Array =
    controlsXML.firstChild.firstChild.firstChild.firstChild.childNodes;
    var list:Array = new Array();
    for (var i:Number = 0; i < controlNodes.length; i++) {
    var personnode:XMLNode = controlNodes
    .attributes.Name;
    trace(personnode);
    testTopic.push (new struct (personnode));
    var specificNode:Array = controlNodes.childNodes;
    for (var j:Number = 0; j < specificNode.length; j++){
    var itemnode:XMLNode = specificNode[j].attributes.Variable;
    trace(itemnode);
    test.push (new struct2 (itemnode));
    printer ();
    printer2 ();
    } else {
    trace('error reading XML');
    controlsXML.load ("controls3.xml");
    The code for the movieclip duplication is as follows:
    x = 50;
    function printer ()
    for (m = 0; m < testTopic.length; m++)
    duplicateMovieClip ( slotTopic, "slotTopic" + m, m );
    slotTopic = eval ( "slotTopic" + m );
    slotTopic._y += x;
    slotTopic.slotTopicContent.text = testTopic[m].personnode;
    function printer2 ()
    for (k = 0; k < test.length; k++)
    duplicateMovieClip ( slot, "slot" + k, k );
    slot = eval ( "slot" + k );
    slot._y += x;
    slot.slotContent.text = test[k].itemnode;
    function struct (personnode)
    this.personnode = personnode;
    function struct2 (itemnode)
    this.itemnode = itemnode;
    On the stage are two movieclips, titled "slotTopic" and
    "slot". Within those are dynamic text boxes titled respectively
    "slotTopicContent" and "slotContent". When I preview this file it
    only displays the text within the "slot" movieclip and it lists all
    six of the subtopics with no break. So, there are two dilemmas:
    1) The movieclips won't duplicate into the structured set of
    links that I want.
    2) "slotTopic" is not displaying text at all.
    If anyone has any advice, I'd really appreciate it.
    Thx!

    ok, I'm sorry but there are quite a few things wrong here.
    first though, when posting code please use the 'attach code'
    button.
    1) i can't imagine that you have a XML structure as deep as
    your calling to or the need for it with the limited amount of
    infomation your pulling, in addition your storing the info in
    attributes, so I can't see how this would work, it may 'trace' out
    the right text (somehow) but it's not getting into the arrays
    properly.
    2) you do not assign an attribute value to a XMLNode, and
    then try to push it into an array.
    3) you do not call a method (struct or struct2) using the
    'new' operator. this is how you envoke a new 'class' instance.
    4) do not use 'x' as a variable name as it is a reserved var
    in flash, assigned to an Object instance.
    5) the duplicateMovieClip() method needs to be called upon
    the existing clip as in:
    slotTopic.duplicateMovieClip('slotTopic'+m, m);
    additionally you can pass the _y placement within the
    initObject.
    6) you do not need to use eval, it isn't doing anything here,
    you will gain the correct path by calling duplicateMovieClip
    correctly.
    7) the reason why slotTopic is not being displayed at all is
    because of the second loop, you are duplicating the clips
    (incorrectly) into the same depths thereby replacing all of the
    contents of the slotTopic depths previously constructed.
    the solution to this problem is to construct both items with
    the same loop but increament one of the depth assignments by a
    specific number, in other words at depths much higher or at least
    different, than that of the first element, as in:
    slotTopic.duplicateMovieClip('slotTopic'+m, m, {_y:50});
    slot.duplicateMovieClip('slot'+(m+100), m+100, {_y:50});
    again I'm sorry man, but it will take some work to sort this
    out.

  • Passing multidim array to c function

    Hi all,
    I am very new to JNI, so please excuse if asking something stupid. I want to pass amultidimensional array (double[][]) to a c++ function. The array holds a large matrix for a linear equation system, the c++ function is a solver.
    I can run "Hello World" using JNI, and I can pass a 1-dim double[] Array to a c++ function.
    If changing the native method argument from double[] to double[][], javah produces a c++ header file with jobjectArray as argument type. I don't understand, how to access the array within the c++ code.
    Can anyone give me a tip, how to do it? Most helpfull would be a c++ code line, that fetches an array...
    Thanks a lot,
    Clemente
    The generated header file:
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class Solver */
    #ifndef IncludedSolver
    #define IncludedSolver
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: Solver
    * Method: solve
    * Signature: ([[DI)[D
    JNIEXPORT jdoubleArray JNICALL Java_Solver_solve
    (JNIEnv *, jobject, jobjectArray, jint);
    #ifdef __cplusplus
    #endif
    #endif
    Edited by: Clemente on Oct 15, 2007 2:15 AM
    Edited by: Clemente on Oct 15, 2007 3:37 AM
    Edited by: Clemente on Oct 15, 2007 3:42 AM
    Edited by: Clemente on Oct 15, 2007 3:43 AM

    Finally, I figured to access all dimensions. For the archive and anyone with similar problems:
    Assumed, that the provided jobjectArray is called "array", means the method looks something like:
    JNIEXPORT jdoubleArray JNICALL Java_de_vonmusil_vs_wqn_solver_Solver_solve(JNIEnv *env, jobject ob, jstring path, jobjectArray array) { [...] }
    following snippet lists the first two rows of the array of doubles:
         int j;
         jdoubleArray darray = (jdoubleArray) env->GetObjectArrayElement(array, 0);
         jdouble* first_element = env->GetDoubleArrayElements(darray, NULL);
         for (j=0; j<env->GetArrayLength(darray); j++)
              std::cout << "->" << first_element[j] << std::endl;
         darray = (jdoubleArray) env->GetObjectArrayElement(array, 1);
         first_element = env->GetDoubleArrayElements(darray, NULL);
         for (j=0; j<env->GetArrayLength(darray); j++)
              std::cout << "->" << first_element[j] << std::endl;
    Besides all the casting things, it works this way: A double[][] array is an array (a) of arrays (b). One can get a b-array with env->GetObjectArrayEalement(array, 0);.
    env->GetDoubleArrayElements(darray, NULL); fetches a pointer to the first double value and using the pointerarithmetic pointer[], one can iterate over the whole array.
    Thank you for all your help,
    Clemente
    Edited by: Clemente on Oct 15, 2007 1:26 PM

  • Comparison of values in an array

    Hi,
    So, I have an array comprising of 16 values, and I would like to compare the first 14 values (using the Array Subset vi) of the array, and when they are all within a specific distance of each other, start a timer.
    Since we are measuring temperature with each one of these inputs in this array, once, and only once, they elevate past about 100 degrees Celsius, I would like to start comparing them amonst each other. Once they all are within 20 degrees celsius of each other, this timer should start. I already have the timer set-up, but I'm missing this comparison.
    I'm really new to Labview, so the only way I can think of right now, would be extracting every single value, and comparing them with each other inside a while loop, but there has to be a better way, right?
    Thanks in advance!
    Solved!
    Go to Solution.

    Hi Eduardo,
    the timer is not suppposed to run before those two conditions are true, and it should not stop running once they aren't true again
    You have to define your logic carefully! What happens the second time the conditions become true?
    Get rid of the case structure:
    The timer gets resetted when both conditions become TRUE (by help of rising edge detection), else the timer just runs up...
    If you really insist on "timer is not suppposed to run before those two conditions are true" you have to include some more boolean functions like here:
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Arrays within custom Classes - same array for different instances?

    Hello all,
    I have made a very simple custom class for keeping track of groups of offices for a company.  The class has a Number variable to tell it how many different offices there are, and an Array to store the individual offices by name.  It looks like this.
    class officeCluster
        static var _className:String = "officeCluster";
        // variables
        var numOffices:Number;
        var locationArray:Array = new Array();
        // functions
        function officeCluster()
            trace("officeCluster constructor");
    Very simple!
    Now, it is my understand that when I create different instances of the class, they will each have their own version of "numOffices" and their own version of "locationArray".
    When I run traces of "numOffices", this seems to be true.  For example,
    trace(manufacturingOfficeCluster.numOffices);
    trace(servicesOfficeCluster.numOffices);
    yields
    5
    4
    In the output panel, which is correct.  However, there is trouble with the locationArray.  It seems that as I assign different values to it, regardless of what instance I specify, there is only ONE array- NOT one for each instance.
    In other words,
    trace(manufacturingOfficeCluster.locationArray[1].theLocation);   // theLocation is a String.  The locationArray itself holds Objects.
    trace(servicesOfficeCluster.locationArray[1].theLocation);
    yields
    New Haven, CT
    New Haven, CT
    even though I have defined elsewhere that they are different!
    Is anyone aware of any issues partaining to using Arrays within Class instances?  Any help would be appreciated!
    note:  I've been able to work around this by creating multiple arrays within the class and using a different one for each instance, but this seems very sloppy.

    Unfortunately, the code segment you attached results in:
    12
    12
    in the output panel.   So the problem must lie elsewhere!  Let me give some more detail...
    There are several files involved. The "officeCluster" class file looks like this:
    class officeCluster
         static var _className:String = "officeCluster";
         // variables
         var numOffices:Number;
         var locationArray:Array = new Array();
         // functions
         function officeCluster()
            trace("officeCluster constructor");
    I have two actionscript files which contain object data for the individual offices.  They look like this...
    var servicesOfficeCluster = new officeCluster();
    servicesOfficeCluster.numOffices = 4;
    var newHope:Object = new Object();
    newHope.locationName = "New Hope Office";
    newHope.theLocation = "New Hope, NJ";
    //more data
    servicesOfficeCluster.locationArray[0] = newHope; //array index is incremented with each entry
    //more Objects...
    and like this...
    var manufacturingOfficeCluster = new officeCluster();
    manufacturingOfficeCluster.numOffices = 5;
    var hartford:Object = new Object();
    hartford.locationName = "Hartford Office";
    hartford.theLocation = "Hartford, CT";
    //more data
    manufacturingOfficeCluster.locationArray[0] = hartford; //array index is incremented with each entry
    //more Objects...
    As you can see, the only difference is the name of the officeCluster instance, and of course the Object data itself.  Finally, these are all used by the main file, which looks like this- I have commented out all the code except for our little test -
    import officeCluster;
    #include "manufacturingList.as"
    #include "servicesList.as"
    /*lots of commented code*/
    manufacturingOfficeCluster.locationArray[1].theLocation = "l1";
    servicesOfficeCluster.locationArray[1].theLocation = "l2";
    trace(manufacturingOfficeCluster.locationArray[1].theLocation);
    trace(servicesOfficeCluster.locationArray[1].theLocation);
    Which, unfortunately, still yields
    12
    12
    as output :\  Any ideas?  Is there something wrong with the way I have set up the class file?  Something wrong in the two AS files?  I'm really starting to bang my head against the wall with this one.
    Thanks

  • How to get the values of an Array using JSP Tags

    Hey guys,
    I need some help. I've splited a String using
    fn:split(String, delim) where String = "1,2,3,4" and delim is ,
    This method returns an Array of splited Strings. how do i get the values from this array using jsp tags. I don't wanna put java code to achive that.
    Any help would be highly appreciated
    Thanks

    The JSTL forEach tag.
    In fact if all you want to do is iterate over the comma separated list, the forEach tag supports that without having to use the split function.
    <c:set var="list" value="1,2,3,4"/>
    <c:forEach var="num" items="${list}">
      <c:out value="${num}"/>
    </c:forEach>The c:forTokens method will let you do this with delimiters other than a comma, but the forEach tag works well just with the comma-delimited string.

  • Get distinct values from plsql array

    Hi,
    I have declared a variable as below in plsql proc.
    type t_itemid is table of varchar2(10);
    inserted set of items in to this using a program
    now i want distinct values from that array how can i get it.

    I am using 9i so i cannot use set operator and more over my problem is that i am declaring the variable inside the plsql block . when i tried i am getting the below errors:
    SQL> r
    1 declare
    2 type t_type is table of varchar2(10);
    3 v_type t_type;
    4 begin
    5 v_type := t_type('toys','story','good','good','toys','story','dupe','dupe');
    6 for i in (select column_value from table(v_type)) loop
    7 dbms_output.put_line(i.column_value);
    8 end loop;
    9* end;
    for i in (select column_value from table(v_type)) loop
    ERROR at line 6:
    ORA-06550: line 6, column 41:
    PLS-00642: local collection types not allowed in SQL statements
    ORA-06550: line 6, column 35:
    PL/SQL: ORA-22905: cannot access rows from a non-nested table item
    ORA-06550: line 6, column 10:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 7, column 22:
    PLS-00364: loop index variable 'I' use is invalid
    ORA-06550: line 7, column 1:
    PL/SQL: Statement ignored

  • How do I remove NaN values from an array?

    I'm trying to test if the values in an array are less than 0.001. All of them are...BUT the problem is that some of the elements in the array are NaN. I'd like to do one of two things:
    1. Remove the NaN elements from the array and set them to zero to make the test work.
    2. Make the test understand that NaN elements are okay.
    The test results in a boolean array of T/F values. If all of the values of the boolean array are T, it will result in a single boolean value of T. In #2, I am saying that I want it to test if an element of the array is less than 0.001 OR equal to NAN.
    Solved!
    Go to Solution.

    Your statements don't make much sense. It's irrelevant how many NaNs are in the array. A sort will move them all to the bottom. You had said you wanted to find out if all the elements in an array are less than 0.001, and that you've got some NaNs in there. Well, this will do that:
    twolfe13 wrote:
     I did see how to remove NaN once, but couldn't determine a good way to generalize it other than doing a test loop. I thought there might have been a simple function that I overlooked to do this.
    As I noted, there have been several posts in the past about efficient techniques for removing certain elements out of an array. Seek, and ye shall find.
    Joseph Loo wrote:
    Have you look at the coerce function where you can set the lower and upper limit?
    That won't do anything for NaN. Or perhaps I misunderstood what you are suggesting to do?
    Attachments:
    NaN sort.png ‏20 KB
    NaN sort small.png ‏5 KB

Maybe you are looking for