Associative Array with subsripts(Index) as Varchar2

Hi All,     
I m using Oracle Version 10.1.0.2.0 - Production     
I have the following requirement:     
The Associative array which holds the value with the subscripts(Index) as database table column.
Create table Period_master
Period_code_c Varchar2(10),
Period_frm_dt Date,
Period_to_dt Date,
Year_code_c     Varchar2(10)
Insert into period_master values ('10',to_date('01/01/2012','dd/mm/rrrr'),to_date('31/01/2012','dd/mm/rrrr'),'2011-2012');
Insert into period_master Values ('11',to_date('01/02/2012','dd/mm/rrrr'),to_date('29/02/2012','dd/mm/rrrr'),'2011-2012');
Insert into period_master Values ('12',to_date('01/03/2012','dd/mm/rrrr'),to_date('31/03/2012','dd/mm/rrrr'),'2011-2012');
Insert into period_master Values ('13',to_date('01/04/2012','dd/mm/rrrr'),to_date('30/04/2012','dd/mm/rrrr'),'2012-2013');
Insert into period_master Values ('14',to_date('01/05/2012','dd/mm/rrrr'),to_date('31/05/2012','dd/mm/rrrr'),'2012-2013');
Commit;
SQL > Select * from Period_Master;
Period_code --- Period_frm_dt --- Period_to_dt ---- Year_code_c
10     ---     01/01/2012 ---     31/01/2012     --- 2011-2012
11     ---     01/02/2012 ---     29/02/2012     --- 2011-2012
12     ---     01/03/2012 ---     31/03/2012     --- 2011-2012
13     ---     01/04/2012 ---     30/04/2012     --- 2012-2013
14     ---     01/05/2012 ---     31/05/2012     --- 2012-2013     
My Requirement is get the Period_frm_dt,period_end_dt and yearcode based on period_code (which is input parameters from my procedure) by using Collections.
I have to create one PLSQL table type which having the subscripts(Index) as period_code which is Varchar2 type;
I have written follwing code ,but it's not giving the desired output:
Declare
iv_period Varchar2(10);
Cursor cur_prd(cp_period Varchar2) is select * from Period_Master Where Period_code_c = cp_period;
TYPE PRD_REC_TY IS TABLE OF cur_prd%ROWTYPE INDEX BY PLS_INTEGER;
lv_prd_data prd_rec_ty;
lv_prd PERIOD_MASTER.period_code_c%TYPE ;
lv_frm_dt PERIOD_MASTER.Period_frm_dt%TYPE ;
lv_to_dt PERIOD_MASTER.Period_to_dt%TYPE ;
lv_yr_code PERIOD_MASTER.Year_code_c%TYPE ;
Begin
iv_period := :period;
Open Cur_prd(iv_period);
Loop
Fetch cur_prd BULK COLLECT into lv_prd_data;
EXIT WHEN cur_prd%NOTFOUND;
End Loop;
Close Cur_Prd;
If lv_prd_data.COUNT > 0 THEN
For i IN lv_prd_data.FIRST .. lv_prd_data.LAST
LOOP
lv_prd := lv_prd_data(i).pERIOD_cODE_C;
lv_frm_dt := lv_prd_data(i).Period_frm_dt;
lv_to_dt := lv_prd_data(i).Period_to_dt;
lv_yr_code := lv_prd_data(i).Year_Code_c;
Dbms_output.Put_line('For Period code : '||lv_prd||' the Year code is : '||lv_yr_code);
Dbms_output.Put_line('For Period code : '||lv_prd||' the Period_from_dt is : '||lv_frm_dt);
Dbms_output.Put_line('For Period code : '||lv_prd||' the Period_to_dt is : '||lv_to_dt);
END LOOP;
End if;
Exception
When Others Then
Dbms_output.Put_line('Here Error Found: '||SQLERRM);
End;
But My requirement is to get the FRM_DT,TO_DT and YEAR CODE as per the following:
For Period Code :*11* -- the YearCode is --- *2011-2012*
For Period Code :*11* -- the From Dt is --- *01/02/2012*
For Period Code :*11* -- the To Dt is --- *29/02/2012*
for Period Code : *14* -- the Yearcode is --- *2012-2013*
For Period Code : *14* -- the From Dt is --- *01/05/2012*
For Period Code : *14* -- the To Dt is --- *31/05/2012*
So on...
Like:
lv_yr_code := lv_period_data(iv_period).Year_code_c;
lv_frm_dt := lv_period_data(iv_period).Period_frm_dt;
lv_to_dt := lv_period_data(iv_period).Period_to_dt;
Dbms_output.Put_line('For Period code : '||iv_period||' the Year code is : '||lv_yr_code);
Dbms_output.Put_line('For Period code : '||iv_period||' the Period_from_dt is : '||lv_frm_dt);
Dbms_output.Put_line('For Period code : '||iv_period||' the Period_to_dt is : '||lv_to_dt);
How do i resolve the above scenario.Please help me to resove the above scenario.
Regards,
Prasanta

Hi, Pransanta,
Prasanta wrote:
... My Requirement is get the Period_frm_dt,period_end_dt and yearcode based on period_code (which is input parameters from my procedure) by using Collections.Sorry, I don't understand.
What is the porocedure you mentioned? Do you mean the anonymous block that you posted? If not, post the procedure. How is it related to the anonymous block? E.g., does the anonymous block need to call the procedure?
I have to create one PLSQL table type which having the subscripts(Index) as period_code which is Varchar2 type;
I have written follwing code ,but it's not giving the desired output:
Declare
iv_period Varchar2(10);Please format your code, and use \ tags to keep the formatting when you post it on this site.
See the forum FAQ {message:id=9360002}
Cursor cur_prd(cp_period Varchar2) is select * from Period_Master Where Period_code_c = cp_period;You're only looking for a single given period_code_c.  If you want to get all rows, lose the WHERE clause.  If you want to multiple rows, but not all rows, then use an appropriate WHERE clause.
TYPE PRD_REC_TY IS TABLE OF cur_prd%ROWTYPE INDEX BY PLS_INTEGER;
lv_prd_data prd_rec_ty;
lv_prd PERIOD_MASTER.period_code_c%TYPE ;
lv_frm_dt PERIOD_MASTER.Period_frm_dt%TYPE ;
lv_to_dt PERIOD_MASTER.Period_to_dt%TYPE ;
lv_yr_code PERIOD_MASTER.Year_code_c%TYPE ;
Begin
iv_period := :period;Post the code that declares and sets :period.
Open Cur_prd(iv_period);
Loop
Fetch cur_prd BULK COLLECT into lv_prd_data;
EXIT WHEN cur_prd%NOTFOUND;
End Loop;
Close Cur_Prd;
If lv_prd_data.COUNT > 0 THEN
For i IN lv_prd_data.FIRST .. lv_prd_data.LAST
LOOP
lv_prd := lv_prd_data(i).pERIOD_cODE_C;
lv_frm_dt := lv_prd_data(i).Period_frm_dt;
lv_to_dt := lv_prd_data(i).Period_to_dt;
lv_yr_code := lv_prd_data(i).Year_Code_c;If the block is just supposed to do what it's doing now; then you don't need all these local variables.  It's simpler just to teference lv_prd_data.
If you're planning to add some other code to the block later, then the local variables could be useful.
Dbms_output.Put_line('For Period code : '||lv_prd||' the Year code is : '||lv_yr_code);
Dbms_output.Put_line('For Period code : '||lv_prd||' the Period_from_dt is : '||lv_frm_dt);
Dbms_output.Put_line('For Period code : '||lv_prd||' the Period_to_dt is : '||lv_to_dt);
END LOOP;
End if;
Exception
When Others Then
Dbms_output.Put_line('Here Error Found: '||SQLERRM);Only use an EXCEPTION section when you need to.  The EXCEPTION section above is only hiding some information about the error.
End;
But My requirement is to get the FRM_DT,TO_DT and YEAR CODE as per the following:
For Period Code :*11* -- the YearCode is --- *2011-2012*
For Period Code :*11* -- the From Dt is --- *01/02/2012*
For Period Code :*11* -- the To Dt is --- *29/02/2012*
for Period Code : *14* -- the Yearcode is --- *2012-2013*
For Period Code : *14* -- the From Dt is --- *01/05/2012*
For Period Code : *14* -- the To Dt is --- *31/05/2012*
So on...
Like:
lv_yr_code := lv_period_data(iv_period).Year_code_c;
lv_frm_dt := lv_period_data(iv_period).Period_frm_dt;
lv_to_dt := lv_period_data(iv_period).Period_to_dt;
Dbms_output.Put_line('For Period code : '||iv_period||' the Year code is : '||lv_yr_code);
Dbms_output.Put_line('For Period code : '||iv_period||' the Period_from_dt is : '||lv_frm_dt);
Dbms_output.Put_line('For Period code : '||iv_period||' the Period_to_dt is : '||lv_to_dt);
How do i resolve the above scenario.Please help me to resove the above scenario.
Regards,
PrasantaIf the problem is that you need to show all period_code_cs, not just one, then you can do this:DECLARE
CURSOR cur_prd
IS SELECT *
     FROM     period_master
     ORDER BY period_code_c;
TYPE prd_rec_ty IS TABLE OF cur_prd%ROWTYPE INDEX BY PLS_INTEGER;
lv_prd_data prd_rec_ty;
BEGIN
OPEN cur_prd;
FETCH cur_prd BULK COLLECT into lv_prd_data;
CLOSE cur_prd;
IF lv_prd_data.COUNT > 0
THEN
FOR i IN lv_prd_data.FIRST .. lv_prd_data.LAST
     LOOP
     dbms_output.put_line ( 'For Period code : '
                    || lv_prd_data(i).period_code_c
                    || ' the Year code is : '
                    || lv_prd_data(i).year_code_c
     dbms_output.Put_line ( 'For Period code : '
                    || lv_prd_data(i).period_code_c
                    || ' the Period_from_dt is : '
                    || lv_prd_data(i).period_frm_dt
     dbms_output.put_line ( 'For Period code : '
                    || lv_prd_data(i).period_code_c
                    || ' the Period_to_dt is : '
                    || lv_prd_data(i).period_to_dt
     END LOOP;
END IF;
END;

Similar Messages

  • Associative Array with more than one field - retrieving as output parameter

    Hello,
    I'm developing an C# Application that is showing a datagrid with results from a PL/SQL procedure inside a Package.
    The .net project is in .net 4 and the DB is an oracle 10g.
    I have read the odp.net sample about the associative array. I could successfully pass as an input parameter a string[] and dealing with it inside my PL/SQL procedure.
    Now it become more complex to me because I would like to return an associative array defined like this :
    TYPE r_FinalExtract IS RECORD
    RecordmyTable myTable%ROWTYPE,
    Tel1 varchar2(25),
    Tel1Libelle varchar2(50),
    Tel2 varchar2(25),
    Tel2Libelle varchar2(50),
    Tel3 varchar2(25),
    Tel3Libelle varchar2(50),
    Tel4 varchar2(25),
    Tel4Libelle varchar2(50),
    Tel5 varchar2(25),
    Tel5Libelle varchar2(50),
    Email1 varchar2(50),
    Email1Libelle varchar2(50),
    Email2 varchar2(50),
    Email2Libelle varchar2(50)
    TYPE t_FinalExtract IS TABLE OF r_FinalExtract INDEX BY BINARY_INTEGER;
    You can guess my PL/SQL stored procedure is filling this collection.
    The spec of my procedure :
    PROCEDURE P_SELECTDATA( ptab_ListRef IN t_AssocArrayVarchar2, ptab_Result OUT t_FinalExtract );
    Unfortunately, in my .net project, I don't know how to deal with that.
    I tryed to add p_Result as an output parameter but you have to define the OracleCollectionType for that parameter and the array type is not the good one because my t_FinalExtract is not a simple array...
    I searched over the internet and the only one thread I could find is someone who was doing like me... and finally reply to his own thread 3 months later and said that he had to create CSV lines and return a table of varchar2...
    This is what I will do because I'm loosing time for finding the way to do it with my associative array, but if someone has the solution I would be glad to read it.
    Thanks in advance.

    For PL/SQL records, I would recommend using User-Defined Types (UDTs), rather than associative arrays.
    You can read more on how to use ODP.NET UDTs here:
    http://docs.oracle.com/cd/E20434_01/doc/win.112/e23174/featUDTs.htm#CJAGCAID
    Strictly speaking, ODP.NET doesn't support PL/SQL Records per se. Instead, ODP.NET supports building any generic UDT in the Oracle DB, which covers the effective functionality of a Record.
    If you want to walk through the process of taking a sample DB UDT, generating a .NET custom class, then passing an instance between DB and application, here's a tutorial that shows you how to do that:
    http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/userdefinedtypes/userDefinedTypes.htm

  • Arrays with a string index

    Hi, I am looking for the best way to map a value to a string in an array.
    In PHP this is easy because it supports arrays with string Indexes. For example:
    $array['Canada'] = 5;
    $array['USA'] = 3;
    In Java I can't do this because I can only use an integer to index an array.
    My current solution is to create a two dimensional array:
    array[0][0] = "Canada";
    array[0][1] = 5;
    array[0][0] = "USA";
    array[0][1] = 3;
    I am wondering if there is something better.

    It creates 20 slots for reference variables that can point to Date objects. The references variables are all initialized to null.
    If you do dates[0] = new Date();, that creates a new Date object and points the reference variable in slot 0 at it.
    Date[] dates = new Date[3]; creates 3 slots--0, 1, 2.
    Edited by: jverd on Nov 8, 2007 7:39 PM

  • Associative Array Question

    Hi All,
    I've searched through this forum trying to find information I'm needing on associative arrays with a varchar2 index without luck. What I'm looking for is a way to get the index or "key" values of the array without knowing what they are. Meaning, I wouldn't have to know the index value when designing the array but would be able to utilize them values at runtime. For those familiar with Java it would be like calling the keySet() method from a Map object.
    So, if I have an array of TYPE COLUMN_ARRAY IS TABLE OF VARCHAR2(4000) INDEX BY VARCHAR2(100) is there any way to dynamically get the index values without knowing what they are?
    Any help is appreciated.
    Thanks

    Thanks for the response.
    I am aware of using FIRST and NEXT for iterating the array but can I extract the index value of the current element into a variable when I don't know what the index value is at runtime ?
    Thanks

  • How to share an associative array throughout the entire instance?

    Hi all,
    I have an associative array with much data, and it would barely change, I want to keep it in the memory and share it throughout the entire instance, and make sure all sessions of all users get the same associative array, is it possible?
    Thanks in advanced.

    >
    I want to keep it in the memory and share it throughout the entire instance, and make sure all sessions of all users get the same associative array, is it possible?
    Why do you want to keep it in memory?
    Will using a table for that, which being accessed frequently, will practically always be in the buffer cache, cause performance problems for you?
    The only other way to keep data in memory globally accesable to all database sessions is to use the global application context feature. With that you can store [name;value] pairs in memory and easily access (read) them using the SYS_CONTEXT built-in.
    Toon

  • Associative Arrays, Indexes vs. Full Table Scans

    Hello,
    I just started using ODP.Net to connect my .Net Web Service to our Oracle Database. The reason why I switched to ODP.Net is support for arrays. If I wanted to pass in arrays to the procedure I had to pass it in through a varchar2 in a CSV formatted string.
    ex. "123,456,789"
    So now I'm using ODP.net, passing in PL/SQL Associative Arrays then converting those arrays to nested tables to use within queries.
    ex.
    OPEN OUT_CURSOR FOR
    SELECT COLUMN1, COLUMN2
    WHERE COLUMN_ID IN (SELECT ID FROM TABLE(CAST(ASSOC_ARR_TO_NESTED(IN_ASSOC_ARR) AS NESTED_TBL_TYPE)))
    It uses the array successfully however what it doesn't do is use the index on the table. Running the same query without arrays uses the index.
    My colleague who works more on the Oracle side has posted this issue in the database general section (link below). I'm posting here because it does seem that it is tied to ODP.Net.
    performance - index not used when call from service
    Has anyone ever experienced this before?

    You have to use a cardinality hint to force Oracle to use the index:
    /*+ cardinality(tab 10) */See How to use OracleParameter whith the IN Operator of select statement

  • Submiting a form with variables packed into an associative array

    I have a complex form created in flash that submits to a
    shopping cart. I was having trouble getting the variables in the
    right format for the shopping cart to accept.
    So I created a bridging script in php that fills in the
    hidden fields of a form then uses javascript to submit it to the
    cart. This works but I would like to submit the variables directly
    to the cart and eliminate the need for a bridge.
    At the moment I am simply using
    getURL("bridge.php", "_self", "POST");
    to POST the variables to the bridge.
    The bridge code is
    <?php
    $id[txt_1] = "$colortext";
    $id[txt_2] = "$xheight";
    $id[txt_3] = "$xwidth";
    $id[txt_4] = "$nopanels";
    $id[txt_5] = "$shutterstyle";
    $id[txt_6] = "$squarearea";
    $id[txt_7] = "$finish";
    $id[txt_8] = "$bifoldoption";
    $id[txt_9] = "$slidingoption";
    $id[txt_10] = "$hingedoption";
    $id[txt_11] = "$totalprice";
    $id[txt_12] = "$colorcode";
    $products_id = "28";
    ?>
    <form
    action="product_info.php?products_id=28&action=add_product"
    method="post" name="MyForm" target="_self">
    <input type="submit" name="Submit" value="Submit">
    <input name="id[txt_1]" type="hidden" value="<?php
    print($id[txt_1]); ?>">
    <input name="id[txt_2]" type="hidden" value="<?php
    print($id[txt_2]); ?>">
    <input name="id[txt_3]" type="hidden" value="<?php
    print($id[txt_3]); ?>">
    <input name="id[txt_4]" type="hidden" value="<?php
    print($id[txt_4]); ?>">
    <input name="id[txt_5]" type="hidden" value="<?php
    print($id[txt_5]); ?>">
    <input name="id[txt_7]" type="hidden" value="<?php
    print($id[txt_7]); ?>">
    <input name="id[txt_6]" type="hidden" value="<?php
    print($id[txt_6]); ?>">
    <input name="id[txt_8]" type="hidden" value="<?php
    print($id[txt_8]); ?>">
    <input name="id[txt_9]" type="hidden" value="<?php
    print($id[txt_9]); ?>">
    <input name="id[txt_10]" type="hidden" value="<?php
    print($id[txt_10]); ?>">
    <input name="id[txt_11]" type="hidden" value="<?php
    print($id[txt_11]); ?>">
    <input name="id[txt_12]" type="hidden" value="<?php
    print($id[txt_12]); ?>">
    <input name="products_id" type="hidden" value="28">
    </form>
    <script type="text/javascript"
    language="JavaScript"><!--
    document.MyForm.submit();
    //--></script>
    I am trying to create in flash 8 the equivalent of the above
    form using the function below.
    function submitvars() {
    var id: Array = new Array();
    id.txt_1 = colortext;
    id.txt_2 = xheight;
    id.txt_3 = xwidth;
    id.txt_4 = nopanels;
    id.txt_5 = shutterstyle;
    id.txt_6 = squarearea;
    id.txt_7 = finish;
    id.txt_8 = bifoldoption;
    id.txt_9 = slidingoption;
    id.txt_10 = hingedoption;
    id.txt_11 = totalprice;
    id.txt_12 = colorcode;
    var myvar:LoadVars = new LoadVars();
    myvar.id = id;
    myvar.products_id = '28';
    myvar.send("product_info.php?products_id=28&action=add_product",
    "_self", "POST");
    So far the variable products_id = ‘28’ transfers
    over to the cart fine but not the variables in the ‘id’
    array

    You're welcome.
    I've never used register globals, couldn't figure that out,
    thanks for explaining.
    The other way to do it if you want to send an array of simple
    data (usually all of one data type like string or number) is to use
    array.join("delimiter_sequence"); in flash. You can then assign it
    to a single property of your loadvars (e.g. 'id') and use explode
    in php with the same delimiter to recreate an array. This does not
    give you an associative array though, just a regular numeric
    indexed one.
    To send complex data like arrays and objects, you can use
    other encoding techniques. You can even use json: json.org has a
    json class(es) for flash and php 5 has json encoding/decoding
    support for example.
    Another way is to use amfphp and remoting, which does all the
    work for you. And of course, you have XML support as well at both
    ends, so you can always represent complex data in XML if you
    prefer. You may want to investigate these or other methods on
    future occasions.

  • Auto-indexing is slow for arrays with 1 dimensions

    Hi,
    I was looking at the performance of operations on all individual elements in 3D arrays, especially the difference between auto-indexing (left image) and manual-indexing (right image, calling "Index array" and "Replace array subset" in the innermost loop). I'm a bit puzzled by the results and post it here for discussion and hopefully somebody's benefit in the future.
    Left: auto-indexing; right: manual-indexing
    In the tests I added a different random number to all individual elements in a 3D array. I found that auto-indexing is 1.2 to 1.5 times slower than manual-indexing. I also found that the performance of auto-indexing is much more dependent on the size the dimensions: an array with 1000x200x40 elements is 20% slower than an array with 1000x40x200 elements. For manual-indexing there is hardly any difference. The detailed results can be found at the end of this post.
    I was under the impression that auto-indexing was the preferred method for this kind of operation: it achieves exactly the same result and it is much clearer in the block diagram. I also expected that auto-indexing would have been optimized in LabView, but the the tests show this is clearly not the case.
    What is auto-indexing doing?
    With two tests I looked at how auto-index works.
    First, I looked if auto-indexing reorganizes the data in an inefficient way. To do this I made a method "fake-auto-indexing" which calls "Array subset" and "Reshape array" (or "Index array" for a 1D-array) when it enters _every_ loop and calls "Replace array subset" when exiting _every_ loop (as opposed to manual-indexing, where I do this only in the inner loop). I replicated this in a test (calling it fake-auto-indexing) and found that the performance is very similar to auto-indexing, especially looking at the trend for the different array lengths.
    Fake-auto-indexing
    Second, I looked if Locality of reference (how the 3D array is stored in memory and how efficiently you can iterate over that) may be an issue. Auto-indexing loops over pages-rows-columns (i.e. pages in the outer for-loop, rows in the middle for-loop, columns in the inner for-loop). This can't be changed for auto-indexing, but I did change it for manual and fake-indexing. The performance of manual-indexing is now similar to auto-indexing, except for two cases that I can't explain. Fake-auto-indexing performs way worse in all cases.
    It seems that the performance problem with auto-indexing is due to inefficient data organization.
    Other tests
    I did the same tests for 1D and 2D arrays. For 1D arrays the three methods perform identical. For 2D arrays auto-indexing is 15% slower than manual-indexing, while fake-auto-indexing is 8% slower than manual-indexing. I find it interesting that auto-indexing is the slowest of the three methods.
    Finally, I tested the performance of operating on entire columns (instead of every single element) of a 3D array. In all cases it is a lot faster than iterating over individual elements. Auto-indexing is more than 1.8 to 3.4 times slower than manual-indexing, while fake-auto-indexing is about 1.5 to 2.7 times slower. Because of the number of iterations that has to be done, the effect of the size of the column is important: an array with 1000x200x40 elements is in all cases much slower than an array with 1000x40x200 elements.
    Discussion & conclusions
    In all the cases I tested, auto-indexing is significantly slower than manual-indexing. Because auto-indexing is the standard way of indexing arrays in LabView I expected the method to be highly optimized. Judging by the tests I did, that is not the case. I find this puzzling.
    Does anybody know any best practices when it comes to working with >1D arrays? It seems there is a lack of documentation about the performance, surprising given the significant differences I found.
    It is of course possible that I made mistakes. I tried to keep the code as straightforward as possible to minimize that risk. Still, I hope somebody can double-check the work I did.
    Results
    I ran the tests on a computer with a i5-4570 @ 3.20 GHz processor (4 cores, but only 1 is used), 8 GB RAM running Windows 7 64-bit and LabView 2013 32-bit. The tests were averaged 10 times. The results are in milliseconds.
    3D-arrays, iterate pages-rows-columns
    pages x rows x cols : auto    manual  fake
       40 x  200 x 1000 : 268.9   202.0   268.8
       40 x 1000 x  200 : 276.9   204.1   263.8
      200 x   40 x 1000 : 264.6   202.8   260.6
      200 x 1000 x   40 : 306.9   205.0   300.0
     1000 x   40 x  200 : 253.7   203.1   259.3
     1000 x  200 x   40 : 307.2   206.2   288.5
      100 x  100 x  100 :  36.2    25.7    33.9
    3D-arrays, iterate columns-rows-pages
    pages x rows x cols : manual  fake
       40 x  200 x 1000 : 277.6   457       
       40 x 1000 x  200 : 291.6   461.5
      200 x   40 x 1000 : 277.4   431.9
      200 x 1000 x   40 : 452.5   572.1
     1000 x   40 x  200 : 298.1   460.4     
     1000 x  200 x   40 : 460.5   583.8
      100 x  100 x  100 :  31.7    51.9
    2D-arrays, iterate rows-columns
    rows  x cols  : auto     manual   fake
      200 x 20000 :  123.5    106.1    113.2    
    20000 x   200 :  119.5    106.1    115.0    
    10000 x 10000 : 3080.25  2659.65  2835.1
    1D-arrays, iterate over columns
    cols   : auto  manual  fake
    500000 : 11.5  11.8    11.6
    3D-arrays, iterate pages-rows, operate on columns
    pages x rows x cols : auto    manual  fake
       40 x  200 x 1000 :  83.9   23.3     62.9
       40 x 1000 x  200 :  89.6   31.9     69.0     
      200 x   40 x 1000 :  74.3   27.6     62.2
      200 x 1000 x   40 : 135.6   76.2    107.1
     1000 x   40 x  200 :  75.3   31.2     68.6
     1000 x  200 x   40 : 133.6   71.7    108.7     
      100 x  100 x  100 :  13.0    5.4      9.9
    VI's
    I attached the VI's I used for testing. "ND_add_random_number.vi" (where N is 1, 2 or 3) is where all the action happens, taking a selector with a method and an array with the N dimensions as input. It returns the result and time in milliseconds. Using "ND_add_random_number_automated_test.vi" I run this for a few different situations (auto/manual/fake-indexing, interchanging the dimensions). The VI's starting with "3D_locality_" are used for the locality tests. The VI's starting with "3D_norows_" are used for the iterations over pages and columns only.
    Attachments:
    3D_arrays_2.zip ‏222 KB

    Robert,
    the copy-thing is not specific for auto-indexing. It is common for all tunnels. A tunnel is first of all a unique data space.
    This sounds hard, but there is an optimization in the compiler trying to reduce the number of copies the VI will create. This optimization is called "in-placeness".
    The in-placeness algorithm checks, if the wire passing data to the is connected to anything else ("branch"). If there is no other connection then the tunnel, chance is high that the tunnel won't create an additional copy.
    Speaking of loops, tunnels always copies. The in-placeness algorithm cannot opt that out.
    You can do a small test to elaborate on this: Simply wire "0" (or anything less than the array sizy of the input array) to the 'N' terminal.......
    Norbert
    PS: Auto-indexing is perfect for a "by element" operation of analysis without modification of the element in the array. If you want to modify values, use shift registers and Replace Array Subset.
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Crash when use indexe array with in place element structure

    Hello !
    I have a problem with in place element structure. I want index a waveform array (16 elements) and when i execute or save that labview close....
    I dont have problem with waveform array 15 elements or less, but i need index 16 elements...
    Thanks for your help !!!
    Solved!
    Go to Solution.
    Attachments:
    Test.PNG ‏8 KB

    I give you my code but it work because i used a waveform array with only 15 elements. I can't save or execute with 16 elements...
    So add it (like picture Test.png) and you will see.
    Thank you
    Attachments:
    Test.vi ‏25 KB

  • Show biggest index in array with value "True"

    Hello,
    Is it possible to show the maximum index number with value "true", like shown underneath?
    I can show the value on what index the series of "true" ends with the "Array Max & Min" function, but when there is
    one False between those True's, it will show the index of the True left of the False.
    I don't need to know the size of the array, because it has to stay 8
    File is attached
    Solved!
    Go to Solution.
    Attachments:
    Biggest index of array with value 1.vi ‏8 KB

    Hi Stef,
    here you go:
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • [svn:osmf:] 13754: Restore ability for HTTP streaming index handler to send /receive arbitrary context associated with an index, per Matthew's feedback .

    Revision: 13754
    Revision: 13754
    Author:   [email protected]
    Date:     2010-01-25 10:56:31 -0800 (Mon, 25 Jan 2010)
    Log Message:
    Restore ability for HTTP streaming index handler to send/receive arbitrary context associated with an index, per Matthew's feedback.
    Modified Paths:
        osmf/trunk/framework/OSMF/.flexLibProperties
        osmf/trunk/framework/OSMF/org/osmf/events/HTTPStreamingIndexHandlerEvent.as
        osmf/trunk/framework/OSMF/org/osmf/net/httpstreaming/HTTPNetStream.as
        osmf/trunk/framework/OSMF/org/osmf/net/httpstreaming/HTTPStreamingIndexHandlerBase.as
        osmf/trunk/framework/OSMF/org/osmf/net/httpstreaming/f4f/HTTPStreamingF4FIndexHandler.as
    Removed Paths:
        osmf/trunk/framework/OSMF/org/osmf/net/httpstreaming/URLLoaderWithContext.as

    Remember that Arch Arm is a different distribution, but we try to bend the rules and provide limited support for them.  This may or may not be unique to Arch Arm, so you might try asking on their forums as well.

  • There should be a way to index an array with an array of indexes or booleans (without a loop)

    Hi, often I would love to index an array with an array of indexes or an array of booleans without having to loop it.  I.e: let the IndexArray function accept an array of indexes instead of discrete indexes.  The output should then be an array of indexes values.  
    Another use case is to index with an array of booleans, so each TRUE element would index the input array and FALSE elements are not indexed.
    arrResult = arrInput[ arrIndexes ];  or
    arrResult = arrInput[ arrVal > 20 ];
    Would this be useful? Possibly it could be implemented in future versions?

    You forgot the link.

  • Correct syntax with associative arrays??

    Hi All,
    I'm doing something wrong with my syntax. I'm trying to grab
    data out of an associative array, but I'd like to be able to
    dynamically pass that array name on a button press. Can someone
    help me out with the correct syntax. I can easily setup a switch
    statement and copy the code and hard code each associative array
    name three times...but I have that whole block below 3 times. It
    works...but it's very ugly. I'd like to just pass the 'phase'
    dynamically since they all use the same code setup, just different
    array names. Any help would be greatly appreciated. - Grant

    Maybe you should start learning AS3, its much more easier to
    use an xml file.

  • Associative array related problem

    Hi All,
    When I am trying to use assotiative array in a select statement I recieve the following error:
    ORA-06550: line 9, column 22:
    PLS-00201: identifier 'COL1' must be declared
    ORA-06550: line 9, column 22:
    PLS-00201: identifier 'COL1' must be declared
    ORA-06550: line 9, column 10:
    PL/SQL: ORA-00904: : invalid identifier
    ORA-06550: line 9, column 3:
    PL/SQL: SQL Statement ignored
    Here is the example
    --create table MyTable (col1 varchar2(255), col2 varchar2(255))
    declare
      type m_ttMyTable
        is table of MyTable%rowtype index by MyTable.col1%type;
      m_tMyTable                   m_ttMyTable;
      m_sCol2 varchar2(255);
    begin
      select m_tMyTable (col1).col2  /* works with ocntant: select m_tMyTable */('col1').col2
        into m_sCol2
      from MyTable
      where rownum = 1;
    end;
    --drop table MyTableAny ideas how to workaround this?
    Thanks

    The only collection types SQL can query are ones defined in SQL using CREATE TYPE. That excludes associative arrays, as they are PL/SQL-only constructs. I'd recommend a nested table collection.
    Some more suggestions:
    www.williamrobertson.net/documents/collection-types.html

  • Associative Array and Blob

    I’m currently working on a system that allows the users to upload an Excel spreadsheet (.xls) in the system. The upload page is a PL/SQL cartridge. Then I’ve written a Java servlet (using Oracle Clean Content) to convert the XLS into a CSV and store it back in the database. (it is stored in the “uploaded_files” table as a blob). I’m trying to create another procedure to read the contents of the blob and display a preview of the data on the screen (using an html table (will be done using cartridge)). After the preview, the user can choose to submit the data into the database into the “detail_records” table or simply discard everything.
    I've been trying to use an associative array to grab all the data from the blob but I’m getting confused about how to implement it in my situation.
    Can someone provide any examples of this nature?
    Any help is greatly appreciated.

    I decided to create a "record" type with all the columns from my excel spreadsheet. Then I will create a table type of records
    I am doing something like this:
    declare
    type s_record is record
                            (l_name varchar2(100),
                             f_code varchar2(4) ,
                             l_code varchar2(6),
                             d_date varchar2(5),
                             d_type varchar2(5),
                             price number,
                             volume number,
                             tax number,
                             amount_paid number
    type s_data_tab is table of s_record index by binary_integer;
    v_s_data s_data_tab;
    v_indx binary_integer :=0;
    begin
    end; I am getting confused about parsing an entire row of values separated by commas into a row in the temporary table created above.
    I know I need a loop, but from what I understand, the way to populate data needs to be something like this, for example:
    for v_indx in 0..data_size loop
       v_s_data(v_indx).l_name:= 'Company A';
       v_s_data(v_indx).f_code := '2700';
    end loop; But I'm not sure how this approach should be used to parse an entire row at once.
    Any help appreciated.

Maybe you are looking for

  • If I use an app to remove duplicate pix does the app  read content  or only  the file name such as IMG

    If I use an app to remove duplicate pix does the app  read content  or only  the file name such as IMG. I have some 2500 pix  and the thought of trawling thru  them  toremove duplicates is mind numbing. If the apps  read the content then I am ok abou

  • Changin gateway hostname in SMGW

    Dear all, This is an issue with SM51 TCODE. While accessing the central instance, it displays value of the application server in the display tab at the bottom right IE the value of the current instance. does not shift. So in our work around analysis,

  • PSE 11 on a Mac questions

    I've been using PSE 6 and 10 without problems. I just upgraded to 11, and there are two things that don't work anymore. I use PSE for making scrapbooking layouts (if that makes a difference). I have a MacBook Pro running Mountain Lion, iPhoto '11, an

  • Data Warehouse - Synchronization Performance view not available/working

    Hi! How can I populate this view. I have no Performance counters to choose from. see attached picture. Come to think of it, I have a lot of empty views and reports - why is that? Best regards Rune Haugen

  • ORA-27300: on oracle version 10.2.0.3

    Hi All, I am getting this error ORA-27300: OS system dependent operation:CreateThread failed with status: 8 ORA-27301: OS failure message: Not enough storage is available to process this command. ORA-27302: failure occurred at: ssthrddcr in my alert