Need to detect undefined array elements

Hi:
How does one detect unassigned elements of an array. Consider...
type myarrtyp is table of char(1) index by binary_integer;
myarr myarrtyp;
myarr(1) := 'X';
myarr(3) := 'X';
for x in 0..3 loop
dbms_output.put_line(x || ': ' || myarr(x));
end loop;
This fails when it hits myarr(2). Message is "no data found"
If I try to detect a NULL in the loop...
for x in 0..3 loop
if myarr(x) is null
then
dbms_output.put_line(x || ': NULL');
else
dbms_output.put_line(x || ': ' || myarr(x));
end if;
end loop;
... it still fails, same reason.
Q: How can one sense that myarr(2) has not been assigned?
I'm thinking that behind the scenes, Oracle is just creating a table with two columns, one with the char(1) and the other with a NUMBER. When I do something like myarr(3) := 'X', it loads one record in the array table (values (3,'X')). When I try to get myarr(2), I get a "no data found" in the same sense that I would get a "no records found" in a more familiar SQL query. If true, then how can one sense "no data found" when refering to a PL/SQL table array indexed by a binary_integer?
One work around is to init the array with something like '-', then selectively overwrite with 'X'. You will be able to sense the '-'. But, since I don't know how big the array will need to be, and I don't want to spend the cycles initializing a ridiculously large array, I'd prefere a more elegant solution.
Thanks in Advance
-dave

Just add an exception handler in the loop to trap for the no_data_found condition:
for x in 0..3 loop
  begin
    dbms_output.put_line(x || ': ' || myarr(x));
  exception
    when no_data_found then
      null;  -- do nothing, handle the exception silently
      -- dbms_output.put_line('element ' || x || ' not initialized');
  end;  
end loop;

Similar Messages

  • How to save the array elements

    hi,every body
    I need to save the array elements,for later use,can you tell me how?

    here you go.
    Message Edited by Root Canal on 10-21-2008 02:50 PM
    global variables make robots angry
    Attachments:
    write some stuff and read some stuff.vi ‏47 KB
    write some stuff and read some stuff.PNG ‏19 KB

  • A basic question/problem with array element as undefined

    Hello everybody,
    thank you for looking at my problem. I'm very new to scripting and javaScript and I've encountered a strange problem. I'm always trying to solve all my problem myself, with documentation (it help to learn) or in the last instance with help of google. But in this case I am stuck. I'm sure its something very simple and elementary.
    Here I have a code which simply loads a text file (txt), loads the content of the file in to a "var content". This text file contents a font family name, each name on a separate line, like:
    Albertus
    Antenna
    Antique
    Arial
    Arimo
    Avant
    Barber1
    Barber2
    Barber3
    Barber4
    Birch
    Blackoak ...etc
    Now, I loop trough the content variable, extract each letter and add it to the "fontList[i]" array. If the character is a line break the fontList[i] array adds another element (i = i + 1); That's how I separate every single name into its own array element;
    The problem which I am having is, when I loop trough the fontList array and $.writeln(fontList[i]) the result in the console is:
    undefinedAlbertus
    undefinedAntenna
    undefinedAntique
    undefinedArial ...etc.
    I seriously don't get it, where the undefined is coming from? As far as I have tested each digit being added into the array element, I can't see anything out of ordinary.
    Here is my code:
    #target illustrator
    var doc = app.documents.add();
    //open file
    var myFile = new File ("c:/ScriptFiles/installedFonts-Families.txt");
    var openFile = myFile.open("r");
    //check if open
    if(openFile == true){
        $.writeln("The file has loaded")}
    else {$.writeln("The file did not load, check the name or the path");}
    //load the file content into a variable
    var content = myFile.read();
    myFile.close();
    var ch;
    var x = 0;
    var fontList = [];
    for (var i = 0; i < content.length; i++) {
        ch = content.charAt (i);
            if((ch) !== (String.fromCharCode(10))) {
                fontList[x] += ch;
            else {
                x ++;
    for ( i = 0; i < fontList.length; i++) {
       $.writeln(fontList[i]);
    doc.close (SaveOptions.DONOTSAVECHANGES);
    Thank you for any help or explanation. If you have any advice on how to improve my practices or any hint, please feel free to say. Thank you

    CarlosCantos wrote an amazing script a while back (2013) that may help you in your endeavor. Below is his code, I had nothing to do with this other then give him praise and I hope it doesn't offend him since it was pasted on the forums here.
    This has helped me do something similar to what your doing.
    Thanks again CarlosCanto
    // script.name = fontList.jsx;
    // script.description = creates a document and makes a list of all fonts seen by Illustrator;
    // script.requirements = none; // runs on CS4 and newer;
    // script.parent = CarlosCanto // 02/17/2013;
    // script.elegant = false;
    #target illustrator
    var edgeSpacing = 10;
    var columnSpacing = 195;
    var docPreset = new DocumentPreset;
    docPreset.width = 800;
    docPreset.height = 600;
    var idoc = documents.addDocument(DocumentColorSpace.CMYK, docPreset);
    var x = edgeSpacing;
    var yyy = (idoc.height - edgeSpacing);
    var fontCount = textFonts.length;
    var col = 1;
    var ABcount = 1;
    for(var i=0; i<fontCount; i++) {
        sFontName = textFonts[i].name;
        var itext = idoc.textFrames.add();
        itext.textRange.characterAttributes.size = 12;
        itext.contents = sFontName;
        //$.writeln(yyy);
        itext.top = yyy;
        itext.left = x;
        itext.textRange.characterAttributes.textFont = textFonts.getByName(textFonts[i].name);
        // check wether the text frame will go off the bottom edge of the document
        if( (yyy-=(itext.height)) <= 20 ) {
            yyy = (idoc.height - edgeSpacing);
            x += columnSpacing;
            col++;
            if (col>4) {
                var ab = idoc.artboards[ABcount-1].artboardRect;
                var abtop = ab[1];
                var ableft = ab[0];
                var abright = ab[2];
                var abbottom = ab[3];
                var ntop = abtop;
                var nleft = abright+edgeSpacing;
                var nbottom = abbottom;
                var nright = abright-ableft+nleft;
                var abRect = [nleft, ntop, nright, nbottom];
                var newAb = idoc.artboards.add(abRect);
                x = nleft+edgeSpacing;
                ABcount++;
                col=1;
        //else yyy-=(itext.height);

  • I need sorting VI that returns the sorted array element's positions in the unsorted array

    I need a VI that will very quickly (n log n) sort a 1D array of doubles.  This VI should not only output the sorted array, but for each of the sorted array elements, it should also output that sorted array element's position in the unsorted array.  So for example if the input array were:
    unsorted_array
    4.1
    2.3
    7.0
    5.6
    10.2
    Then the output arrays would be:
    sorted_array
    2.3
    4.1
    5.6
    7.0
    10.2
    indices_array
    1 (the value 2.3 is located at position 1 in the unsorted_array)
    0 (the value 4.1 is located at position 0 in the unsorted_array)
    3 (the value 5.6 is located at position 3 in the unsorted_array)
    2 (the value 7.0 is located at position 2 in the unsorted_array)
    4 (the value 10.2 is located at position 4 in the unsorted_array)
    This way I could generate the sorted_array using just the indices_array and the unsorted_array.  Has anyone written a nifty piece of code to do this?  I did some research on (n log n) sorting algorithms but most of them use recursion which I don't know how to do in LabVIEW.  It would also be nice to have an algorithm like this that could sort an array of strings.
    cheers,
    Richard

    Try something like the attached example (LabVIEW 7.0). I think it does what you need.
    (To understand the code, it is important to know that arrays of clusters are sorted by the first element in the cluster).
    Sort array itself sorts also array of strings, so you could just substitute, keeping the rest of the code the same.
    Sort array uses a variation of quicksort, so it should have about NlogN complexity.
    (If you think you only need the array of indices to later generate the sorted array, it does not make much sense to even do it. To get the indices, you need to sort the array anyway. You should just sort the plain array directly.
    Message Edited by altenbach on 07-13-2005 03:47 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    SortAndIndex.vi ‏26 KB

  • How to use XSLT for mapping feild names one by one to array element

    I have a XSLT case to map all the attributes feild name(not value) which has no child to the target, which is array loop.
    I give an sample below.
    source:
    <Items xmlns="http://www.example.org/sample">
    <SourceSystem>SourceSystem2573</SourceSystem>
    <TimeStamp>2010-01-17T20:54:08.234</TimeStamp>
    <Item>
    <ID>2574</ID>
    <Type>2575</Type>
    <Name>2576</Name>
    </Item>
    </Items>
    source XSD like:
         <element name="Items" type="tns:ItemsType"></element>
         <complexType name="ItemsType">
              <sequence>
                   <element name="SourceSystem" type="string" maxOccurs="1"
                        minOccurs="1">
                   </element>
                   <element name="TimeStamp" type="dateTime" maxOccurs="1"
                        minOccurs="1">
                   </element>
                   <element name="Item" type="tns:ItemType"
                        maxOccurs="unbounded" minOccurs="1">
                   </element>
    </sequence>
         </complexType>
    <complexType name="ItemType">
              <sequence>
                   <element name="ID" type="string" maxOccurs="1"
                        minOccurs="1">
                   </element>
                   <element name="Type" type="string" maxOccurs="1"
                        minOccurs="1">
                   </element>
    <element name="Name" type="string" maxOccurs="1"
                        minOccurs="1">
                   </element>
    </sequence>
         </complexType>
    target need to be like:
    <ns1:AttributesCollection>
    <ns1:Attributes>
    <ns1:fieldname>SourceSystem</ns1:fieldname>
    </ns1:Attributes>
    <ns1:Attributes>
    <ns1:fieldname>TimeStamp</ns1:fieldname>
    </ns1:Attributes>
    <ns1:Attributes>
    <ns1:fieldname>ID</ns1:fieldname>
    </ns1:Attributes>
    <ns1:Attributes>
    <ns1:fieldname>Type</ns1:fieldname>
    </ns1:Attributes>
    <ns1:Attributes>
    <ns1:fieldname>Name</ns1:fieldname>
    </ns1:Attributes>
    </ns1:AttributesCollection>
    target XSD:
    <xs:element name="AttributesCollection" type="AttributesCollection"/>
    <xs:complexType name="AttributesCollection">
    <xs:sequence>
    <xs:element name="Attributes" type="Attributes" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="Attributes">
    <xs:sequence>
    <xs:element name="fieldname" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="100"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    I know we can use local-name() to get the tag/field name,
    but I have not idea how to get these leaf field names one by one and then mapping to every array elements.
    I tried whole day but no successful
    Does anyone have some idea?
    Thanks very much!
    Keith
    Edited by: user1065212 on 17-Jan-2010 22:50
    Edited by: user1065212 on 17-Jan-2010 22:53
    Edited by: user1065212 on 17-Jan-2010 22:59

    can you paste source xsd and the correct xml output, the current one isn't really valid
    <ID>2574</TotalNumOfItems>

  • Best way to iniitialize a queue with array elements

    Hi Guys
    I'm looking for a bit of performance optimization..  
    I'm developing a noise measurement application using LV8.6 and Win Xp /Win 7.
    To put it very simple I have a loop that samples, and a loop that does the math. data is shipped in a queue, producer / consumer style.
    So far so good.. Question is - is there a specific and more optimized way to declare this queue?
    I was wondering if declaring the queue with an initialized array element of a fixed size (the number of samples pr. read from the sound card will be known at runtime) would produce a queue that would be less heavy on dynamic allocation of memory compared to a queue obtained using a simple control no values.
    I've attached a screen dump to maybe make the question more obvious..
    I've been thru the "clear as mud" thread, as recommended in other threads that covers this topic - but i gets very high tech, and I kind of lost my way in it.. So looking for a more simple "you should use solution #x, because..."
    Thank you in advance. 
    Solved!
    Go to Solution.

    I believe (but am not sure) RT FIFOs will allocate this memory for you ahead of time. But, remember they are not deterministic on windows. You need to wire an array constant of the correct size into the FIFO read function also to avoid memory allocation, which is easy to overlook. It's worth looking into, if nothing else, assuming you have RT functions available. WIth this method, the queue size needs to be set, and you run the risk of overflowing and losing elements if not handled correctly. 
    Just throwing other options out there.
    CLA, LabVIEW Versions 2010-2013

  • Convert 1D array element to integer

    Does anyone know how I can extract the value (element) from a 1D array so that the output value is an integer ?  I'm having signal incompatibility problems (again).  I need to use the particular element from an array in various math blocks i.e. Add
    Solved!
    Go to Solution.

    The following is the error message that I'm receiving:
    These cannot be wired together because their data types (numeric, string, array, cluster, etc.) do not match. Show the Context Help window to see what data type is required.
    The type of the source is 1-D array of
        double [64-bit real (~15 digit precision)].
    The type of the sink is double [64-bit real (~15 digit precision)].
    I'm puzzled why LabVIEW is telling me that the data types do not match when the Source & Sink are the same (double 64-bit real) ? 
    Attachments:
    Plant_Simulator (01-05-2013).vi ‏116 KB

  • Type defined array of clusters for holding configuration data - setting default values for each array element

    Hi,
    I was wondering if I could get some information and opinions about using a type defined array of clusters to hold configuration data.  I am creating a program to test multiple DUTs and wanted to have a type defined control for each DUT containing the information needed to create the DAQmx tasks for all of the signals for that DUT.  I am wanting to do this so that the data is hard-coded and not in a file that the user could mess up.
    The type def controls are then put in a subVI that chooses the appropriate one based on the DUT Type enumeration wired to a case structure.  
    I am having problems with the type defined control.  I am seeing issues when attempting to save a unique configuration to each array element in the array of clusters.  Somehow it worked to begin with, but now clicking "Data Operations --> Make Current value default" on individual elements of the cluster or the entire cluster (array element) is not saving the data when I re-open the type def control.  What am I doing wrong?  Am I trying to do something with arrays of clusters that I should not be doing?
    I have attached one of the type defined controls for reference.  I tried changing it to Strict to see if that helped, but no luck.
    To reproduce, change the resource string for array element 0 and make the new value the default value.  Then close the type def, and re-open it.  The old value is still present in that element.  The VI is saved in LabVIEW 2012.
    Solved!
    Go to Solution.
    Attachments:
    CM_AnalogInputs.ctl ‏11 KB

    Values of a typedef are not proprigated to instances of the control. THey will pick it up if created AFTER the data values have been changed. THey will not get updated with future changes. You should either create a VI specifically for hardcoding your values or implement a file based initialization. The file based would be much better and more flexible. If you don't want users to modify the data simply encrypt it. There is a noce blowfish library you can download.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Problem is detected with Array : 01

    I was backing up my server when it suddenly turned off. When it restarted it showed a critical error message saying "Problem is detected with Array : 01".
    Windows tried starting and kept rebooting so I just turned it off.
    When I launch the RAID utility I clearly see that the drive 02:01 seems ok but the other one is marked as "failed orisconnected" (it is connected ans spinning).
    This is the spec: On the server I have windows 2012R2 installed on two HD 1TB on RAID1.
    I habe an unused NAS, so I decided to create an iSCSI drive as a Target, and run the windows backup utility to do a Full Backup on it.hat may I have done wrong and how could I resolve this issue?
    This clearly is related to the windows backup utility since this server was working fine until then.
    Thanks.

    Hi,
    The issue could be due to that one of the two drive is failed in the RAID 1. You need to replace the failed drive and rebuild the array automatically.
    Best Regards,
    Mandy 
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Deleting array elements

    Hi!
    I have a problem with my program. i have an array and in this array a several numbers. With the "In Range and Coerce" function i want to prove if the the array element is inside or outside of my limitations. If my array element is in the outside of my limitation, the code in the case structure should delete this element.
    I need this program, because the array is displayed on a graph and i want only display the date, which is in the limitations.
    I hope somebody could help me!
    Best regards,
    Peter
    Labview 7.1 on Windows 2000
    Attachments:
    array.jpg ‏54 KB

    Hallo Peter
    Das Problem tritt auf, weil du immer wieder das selbe Array liest.
    Die Knoten am Loop sollten Shift-Register sein, damit das Array, bei dem das Element gelöscht wurde, bei der nächsten Iteration gelesen wird. Allerdings musst du dann auf einen While-Loop umstellen, da du ansonsten Elemente lesen willst, die es im Array nicht mehr gibt.
    Anbei eine mögliche Lösung.
    Hoffe es hilft weiter.
    Thomas
    Using LV8.0
    Don't be afraid to rate a good answer...
    Attachments:
    RemoveElements.vi ‏32 KB

  • Change a property of a specifc array element (array of type defs)

    If I have an array of elements, and I want to change aproperty of one specific element, at position X, is there a way to do this?
    Basically, I have an array of string indicators indicating certain tests attached to certain ports, and I want to change the text to bold on certain indicators, and i want to color certain indicators green or red.  Any chance in an array or clusters only? 
    Thanks Guys.

    While you can't change the properties for a single array element, there are solutions.
    For the background color, you can turn the array element into a cluster of your string (which would be transparent) and a color box which will be the background. You can then change the value of the color box and the color will change.
    For the bold text, I think your only option will be to get rid of the string control and make the array element a picture control instead. Using the picture VIs, you can draw a colored rectangle and then place text inside it (and each element can have different text properties). That way, you won't even need the color box.
    Try to take over the world!

  • Combining two StringBuffer array elements into a single array element

    I just need to know how to combine two stringBuffer array elements into one
    StringBuffer ciphertext [] = new StringBuffer[2];
              StringBuffer s0 = new StringBuffer("11011111111110001001101110110101");
              StringBuffer s1 = new StringBuffer("00010011001101000101011101111001");
              ciphertext[0] = s0;
              ciphertext[1] = s1;
              ciphertext[2] = ciphertext[0].append(ciphertext[1]);I get an array index out of bounds exception:2
    Thanks

    StringBuffer ciphertext [] = new StringBuffer[3];  // legal index values are: 0,1,2

  • Label TS array elements from LV

    Hi,
    How can I change the Label of a TS array element from my LabVIEW code??? Se picture added.
    It is done when you insert at ”Multiple Numeric Limit Test” step in a test sequence and select “Edit Limits…” you get the “Edit Multiple Numeric Limit Test” dialog box. When this is closed with OK the Names of the Measurement Set is applied to the elements in Step.Result.Measurement. How can I do this from LabVIEW???
    I am looking forward to hear from you.
    Best Regards,
    Morten Pedersen
    CIM Industrial Systems A/S
    Attachments:
    ArrayElementsNames.jpg ‏98 KB

    You can access the name of an object by using ActiveX to get to the step's Property Object. Once there, you can use a property node for the name and change it to write.
    Let me know if you need more information about this.
    Regards
    Anders M.
    National Instruments DK

  • Sum array elements not working

    I am trying to output the average % standard deviation per point for a series of data sets.  To do this I want to use the sum array elements function.  The program I have written should work I am pretty sure, but when I watch data flow through it, 1000 points get input into the sum function and NaN comes out.  What could cause an error like this?  I have tried inverting my array, etc.  Is there a limit to the number of points the function can take?  Or to the precision of the points being input?  Thanks, this is driving me crazy! 
    [I renamed the file and attached it again so you can open it - Molly K]
    Message Edited by Support on 07-06-2005 08:23 AM
    Attachments:
    Average % Std Dev.vi ‏23 KB
    Average.vi ‏23 KB

    Any arithmetic operation on a NaN value is invalid and must result in NaN as
    well. You probably need to make sure first that your array doesn't
    contain NaN, Inf, and -Inf.
    Rolf Kalbermatter
    Message Edited by rolfk on 07-05-2005 11:37 AM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • RSS Feed not validating "Undefined item element: itunes:order"

    I've been trying to submit my RSS feed to iTunes but it won't validate. I hosted the podcast on Podomatic and used Feedburner to create the RSS feed. When I checked the link on FeedValidator it gives me the error Undefined item element: itunes:order. My feed is http://feeds.feedburner.com/mscmngrlpodcast. Anyone have any idea how to fix this? I'm kind of a novice so I appreciate your help.

    Your feed is fine [ the 'itunes:order' tag was introduced recently and Feedburner doesn't recognize it. Subscribing to your feed manually in iTunes works OK.
    However you may have a problem with the media file. The Feedproxy URL redirects to
    http://musicmongrelent.podomatic.com/enclosure/2014-04-03T22_02_00-07_00.mp3
    Testing this for 'byte range requests' in Terminal suggests that the server does not accept this: it's the method iPhones use to download files, consisting of requesting part of the file at a time, rather than the whole thing, and as iPhones won't download properly if the server doesn't handle it Apple have made it mandatory. If the server indeede doesn't handle this your podcast will be rejected - you can try submitting and see what happens. If it's rejected you would need to find another server. If you are rejected and re-submit later you will have to change the title slightly, otherwise you will be told the feed has already been submitted (this is a bug in the process).

Maybe you are looking for

  • How do I format "icons", etc. so that I can replace folder with picture????

    Hi, Wonder if someone can help me. I already know how to go through the process, once the "picture" or "icon" or "clip-art" or clipart or ??? is ready to click on. Then get info, copy/paste, etc. My question is when I look for categories of icons, et

  • MacBook Pro screen won't turn on

    Yesterday my MacBook Pro unexpectadly shut off.  It then would not turn back on and it became warm.  You could also hear the fans blowing beneath, at one point it got so loud at night that I took the battery out so I could sleep.  Today around 2:30 I

  • Unknown file type - help

    Please help me identify this file, "IOAHCIBlockStorage.original".  What is it? What does it do?  Do I leave it alone/delete it? It is located at the root of my boot volume.  I've never noticed it before.  Only since updating to Yosemite. Thanks for y

  • Import images into Visual Edge Detector

    I am new to this tool, infact very new. I am working on the image analysis of cancer CT images. I would like to know if it is possible to import the DICOM (or any other image format) images into this tool and get the edges detected? If not what other

  • Switch statement in Indicator field

    Switch(([Baseline Cost] - [Actual Cost])/[Baseline Cost] *100 >, "1",  ([Baseline Cost]  - [Actual Cost])/[Baseline Cost] *100 >10 and ([Baseline Cost]  - [Actual Cost])/[Baseline Cost] *100 <20,"2")) I have set indicator 1 as green and 2 as red noth