Initialization of the collection

When and why do we need to initialize the collections?

To put it simple, there are 3 types of collections in PL/SQL

1. associative array
2. nested table
3. VARRAY

Associative array requires no initialization explicit while the other two doesn't work.

Here is an example

Associative array

SQL> declare
  2    type tbl is table of integer index by pls_integer;
  3    var tbl;
  4  begin
  5    var(1) := 1;
  6  end;
  7  /

PL/SQL procedure successfully completed.

Nested table

SQL> declare
  2    type tbl is table of integer;
  3    var tbl;
  4  begin
  5    var(1) := 1;
  6  end;
  7  /
declare
*
ERROR at line 1:
ORA-06531: Reference to uninitialized collection
ORA-06512: at line 5

SQL> declare
  2    type tbl is table of integer;
  3    var tbl;
  4  begin
  5    var := new tbl();
  6    var.extend;
  7    var(1) := 1;
  8  end;
  9  /

PL/SQL procedure successfully completed.

VARRAY

SQL> declare
  2    type tbl is varray(10) of integer;
  3    var tbl;
  4  begin
  5    var(1) := 1;
  6  end;
  7  /
declare
*
ERROR at line 1:
ORA-06531: Reference to uninitialized collection
ORA-06512: at line 5

SQL> declare
  2    type tbl is varray(10) of integer;
  3    var tbl;
  4  begin
  5    var := new tbl();
  6    var.extend;
  7    var(1) := 1;
  8  end;
  9  /

PL/SQL procedure successfully completed.

SQL>

Tags: Database

Similar Questions

  • Difference between the initialization of the collection (with NEW, without NEW)--11 GR 2

    Hi all

    Is there a difference between the underside of the initializations of collection?
    -- Initialization 1
    declare
       <declare something>
       v_collect varray_test_collect; -- varray_test_collect is a varray of varchar2
    
    begin
    
       <do something>
    
       v_collect  := varray_test_collect();
    
       <do something>
    
    end;
    
    
    -- Initialization 2
    
    declare
       <declare something>
       v_collect varray_test_collect; -- varray_test_collect is a varray of varchar2
    
    begin
    
       <do something>
    
       v_collect  := NEW varray_test_collect();
    
       <do something>
    
    end;

    Hello

    The 'new' keyword is optional.

    See:
    http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/expressions014.htm#SQLRF52094

  • The collection of accurate data of visa format read

    Hello

    I'm new in labview. I do a labview software to control and collect data for the ASL F900 Thermo Bridge. But I don't know how to get the correct visa read data format.

    Example:

    The Correct data format is: +0.123456789E\r\n (15 bytes)

    but sometimes the format of the data that I get is 56789E\r\n+0.1234 or .123456789E\r\n0

    I have attached the F900 user guide!

    Hi, VMI,.

    but sometimes the format of the data that I get is 56789E\r\n+0.1234 or .123456789E\r\n0

    During the initialization of the serial port you should leave and enbale the TermChar is the default setting for '0x0A' = LF = "\n". Then just read something like 99 bytes / VISARead: you will receive complete messages (after the first message).

  • It is mandatory to use the manufacturers during the use of the collections?

    Code

    --------------------

    DECLARE

    Int_varray TYPE is VARRAY (3) integer;

    VARRAY_INT INT_VARRAY: = int_VARRAY();

    BEGIN

    DBMS_OUTPUT. Put_line ('VARRAY initialized with null');

    VARRAY_INT: = int_VARRAY (NULL, NULL, NULL);

    I'm in 1.3

    loop

    DBMS_OUTPUT. PUT_LINE ('INT_VARRAY('|| i||'): ' |) VARRAY_INT (i));

    end loop;

    DBMS_OUTPUT. Put_line ('VARRAY initialized as VALUES');

    VARRAY_INT: = int_VARRAY (11,12,13);

    I'm in 1.3

    loop

    DBMS_OUTPUT. PUT_LINE ('INT_VARRAY('|| i||'): ' |) VARRAY_INT (i));

    end loop;

    end;

    OUTPUT

    --------------------

    VARRAY initialized with null

    INT_VARRAY (1):

    INT_VARRAY (2):

    INT_VARRAY (3):

    VARRAY initialized as VALUES

    INT_VARRAY (1): 11

    INT_VARRAY (2): 12

    INT_VARRAY (3): 13

    The sample code above for collections works perfectly well with the help of a constructor method. However, my question is that is it possible to re - write the same code without using Builder methods?

    or is it mandatory to use constructors when the use of the collections?

    But he has not yet answered my question. Is it mandatory to use a constructor method? If 'NO', then how we can treat a VARRAY (not the tables / associative PLSQL) without a constructor method?

    When you have a basic question about the functionality of the Oracle, you should ALWAYS read the documentation.

    The doc of the PL/SQL language answers your question

    With the help of documents and Collections of PL/SQL

    Initializing and referencing Collections

    Until you initialize it, a nested table or varray is atomically null; the collection itself is zero, not its elements. To initialize a nested table or varray, you use a builder, a function defined by the system with the same name as the collection type. This function constructs collections from the elements that is passed.

    You must explicitly call a constructor for each varray and nested table variable. Associative arrays, the third type of collection, use no constructors. The constructor calls are allowed everywhere where function calls are allowed.

    Example 5-10 Initializes a nested table using a constructor, which resembles a function with the same name as the collection type.

  • failed to initialize of the RMAN (Oracle 11 g cloned after only binaries) package

    Hello everyone.

    I cloned a new oracle binary on for multiple oracle on a single server. Operating system AIX 6.1

    All the steps are followed according to the metalink doc that is 558478.1 but I am still unable to connect to oracle new home. The following error was received.

    New password file, all operating system-level permissions are defined. I create with the default group as "oinstall".

    Error as follows:

    RMAN target /.

    Recovery Manager: release 11.2.0.2.0 - Production on Tue Jan 8 15:36:48 2013

    Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

    RMAN-00571: ===========================================================
    RMAN-00569: = ERROR MESSAGE STACK FOLLOWS =.
    RMAN-00571: ===========================================================
    RMAN-00554: initialization of the package manager internal collection failed
    RMAN-04005: target database error:
    ORA-01031: insufficient privileges

    $ sqlplus "virtue sysdba".

    SQL * more: Production of the version 11.2.0.2.0 Mar 8 15:42:59 Jan 2013

    Copyright (c) 1982, 2010, Oracle. All rights reserved.

    ERROR:
    ORA-01031: insufficient privileges


    Although the name of the instance of MSLTEST is registered

    $ ps - ef | grep MSLTEST
    oratest 7274620 1 0 13:28:44 - 0:00 ora_smon_MSLTEST
    oratest 19267754 1 0 13:28:44 - 0:00 ora_ckpt_MSLTEST
    oratest 22479038 1 0 13:28:43 - 0:00 ora_vktm_MSLTEST
    oratest 22675594 1 0 13:28:44 - 0:00 ora_lgwr_MSLTEST
    oratest 23003290 1 0 13:28:44 - 0:00 ora_dbw1_MSLTEST
    oratest 25100494 1 0 13:28:44 - 0:00 ora_dbw0_MSLTEST
    oratest 26214420 1 0 13:28:44 - 0:28-ora_dia0_MSLTEST
    oratest 32178280 1 0 13:28:43 - 0:00 ora_dbrm_MSLTEST
    oratest 35324102 1 0 13:28:42 - 0:00 ora_psp0_MSLTEST
    oratest 38600770 1 0 13:28:44 - 0:00 ora_reco_MSLTEST
    oratest 42663960 1 0 13:28:43 - 0:00 ora_diag_MSLTEST
    oratest 46858382 1 0 13:28:43 - 0:00 ora_gen0_MSLTEST
    oratest 49348674 1 0 13:28:44 - 0:00 ora_mman_MSLTEST
    oratest 56361026 1 0 13:28:44 - 0:00 ora_mmon_MSLTEST
    oratest 56623166 48824512 0 15:43:13 pts/2 0:00 grep MSLTEST
    oratest 58458284 1 0 13:04:03 - 0:00 /oratest/db/tech_st/11.2.0/bin/tnslsnr MSLTEST-inherit
    oratest 59048172 1 0 13:28:44 - 0:06 ora_mmnl_MSLTEST
    oratest 60096732 1 0 13:28:42 - 0:00 ora_pmon_MSLTEST
    $


    Any suggestions would be much appreciated.

    I suggest that you follow the steps in this Doc MOS

    How to clone an existing Installation of RDBMS using YES [ID 300062.1]

    HTH
    Srini

  • Nulls in the Collections of COM

    Please see this code example:

    ***

    <!-initialize Salesforce.com account->
    < cfset sfUserName = "xxx" >
    < cfset sfPassword = "xxx" >

    <!--> initialize Salesforce API
    < cfoutput >
    < cfobject action = "crΘer" type = "COM" class = "SForceOfficeToolkit3.SForceSession3.1" name = "sfdc" / > "
    < cfset x = sfdc. SetServerUrl ("https://www.salesforce.com/services/Soap/c/7.0") / >
    < cfset x = sfdc.login ("#sfUserName #","#sfPassword #") / >
    < / cfoutput >

    <!--> username pass
    < cfset userLastName = "Barr" >

    <!--> query Salesforce for last name
    < cfset soql = "" select ID, FirstName, LastName, accountid, Contact email where lastname = ' "& #userLastName # &" ' "/ >" ""
    < cfset userResult (soql, false) sfdc.query = / >

    <!--> view results
    < cfloop collection = "" #userResult # "item ="rec">"
    < cfoutput >
    #rec.item("ID").value # < br / >
    #rec.item("FirstName").value # < br / >
    #rec.item("LastName").value # < br / >
    #rec.item("accountid").value # < br / >
    #rec.item("email").value # < br / >
    < / cfoutput >
    < / cfloop >

    ***

    When I loop over the collection of COM, the value of the account ID is NULL. It is expected that this record is not
    Account ID.

    When I try to run this code, I get the following exception:

    ***

    Element VALUE is not defined in an object of type Java class coldfusion.runtime.com.ComProxy referenced as


    The error occurred in C:\CFusionMX7\wwwroot\sftest\sfSearch.cfm: line 25

    23: #rec.item("FirstName").value # < br / >
    24: #rec.item("LastName").value # < br / >
    25: #rec.item("accountid").value # < br / >
    26: #rec.item("email").value # < br / >
    27: < / cfoutput >

    ***

    How can I handle NULL values if I don't get an exception?

    Thanks a lot for help.

    RB

    OK change that: If (IsDefined ("th"))
    for this: If (IsDefined ("th") AND IsDefined ("zDat.value")).

    This should work or return nothing else than NULL values.

    BTW, you use COM to access SalesForce?

    It should be easier with CF7 web calls and has already been done.
    See http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=7&threadid=781179, etc.

  • How to export the collected addresses

    I carried on a new machine (win 7). I have properly exported and imported my address book that contains only 7 entries in my opinion.
    It is now only that I realize that Thunderbird uses the addresses of his "collected addresses" for a long time to suggest the person in the address bar, and that all of these hundreds of addresses are not registered in my address book.
    How can I get access to my (what must be hundreds of) "collected addresses" and get them on my new machine?

    Thank you

    Opens the address book, then select Tools-Export. Select the collected book to export.
    http://KB.mozillazine.org/Moving_address_books_between_profiles

  • Suddenly, my Thunderbird does not list the collected addresses and don't 'Always allow remote content' addresses.

    (1) under address book, used for the book of MAC OS X, as well as the collected addresses and a third list, I can't remember.
    Now it lists only MAC OS address book.

    "(2) if I click on"Always allow remote content"it won't let me click on 'OK', I think that it says in the top left corner" adds: "but gives me an empty list.

    Thank you!

    If I'm more mac savy you we're in trouble. The last Mac I used has a black and white screen and used the floppy 3 1/2 "

    See Troubleshooting in the Thunderbird Help menu, and then click the display folder of your profile (Thunderbird knows where he is, even if I'm not) the History.mab file is your collected addresses.

  • Re: Satellite L300 - initialization of the webcam

    Hi all!

    I have installed Windows 7 on my Satellite L300 and the only problem I have, is that the built-in webcam does not work.
    I downloaded the software from Windows 7, but each time after reboot it tells me, that there is a problem with the initialization of the webcam.

    Any ideas to solve the problem?

    Thank you

    Hey,.

    What exactly downloaded Windows 7 software? You need the Camera Assistant Software to get the job of the webcam. You can download it on the Toshiba page.
    Did you do that?

    And what Satellite L300 you use exactly?
    You did an upgrade from Vista?

  • Satellite L300-29V - failed to initialize for the logon process

    Hello

    Trying to upgrade my Satellite L300 - 29V Vista Home Premium to the Toshiba provided Win 7 Home premium with the help of the upgrade DVD Toshiba. I tried this many times now with no success. On each attempt, I get the message "* logon process initialization failed - the Interactive logon process initialization has failed. For more details, please see the event log. "*.

    At this point, the mouse is active, but none of the keyboard keys control apart from the pointer appears only on the area of the event, enter and esc. Pressure on one of them or by clicking on the OK button or Cancel will be empty of the screen. A minute later, the blue screen of death will be appear and disappear quickly, after that, I have the option load Win 7 or return to Win Vista. Do go back to Vista (which I did several times that I care to remember) is not a problem and the laptop runs without problem later. At any time I am able to view the event log.

    I followed the instructions given by the upgrade DVD, IE. removing the drivers and continued on the upgrade to Windows 7. I've updated the mobile site to download drivers/software Toshiba in order to have the machine as much upto date possible - everything to nothing is outside having more drivers to remove using the upgrade DVD.

    The only thing I did is to back up my data and recover Vista to factory settings and load on top of Vista in this way.

    But before that I'm looking for the Forum of Toshiba for any useful advice - someone else has had this problem or does anyone know a way around this - if so I would appreciate your help.

    See you soon

    Dleifynot

    It is really strange. I've updated Qosmio x 300 and Satellite A500 by using Toshiba upgrade kit.
    No problem at all.

    Did you follow instruction as described on http://aps2.toshiba-tro.de/kb0/TSB9902P60000R01.htm?

  • Records of the initialization of the array of strings

    Hello. I posted my project. It's not even close to finished, but I have a problem during the initialization of the table entitled 'values' and 'down of values', '0' for all elements, at the beginning of the Vi run. So, when I'm at the front and execution of the Vi, I would that all fields begin with a '0', the moment that the Vi is started. I tried a few different things, I could think and watched video 1 base on the tables again, however, it does not give the example of a string and nothing I have tried so far, works. Thank you.

    Filling of the indicators with default values is not very useful, because they will be overwritten once the program is running and updated indicators. In general, the default values are much more useful for controls.

    In any case, if you want indicators to reset the defaults, every execution of the VI, go to ' properties VI... execution "and check"of clear indicators when it is called.

    See if that fixes your perceived problem. Good luck!

  • Unable to see the Collections in remote desktop Services in Server Manager

    It doesn't seem to be a category for Windows Server for some reason, so I apologize if this is in the wrong category:

    We recently had an administrator leave our of the it group, and he was the one who had set up our fund services / remote server.  Recently, we wanted to deploy another remote application and found that we were not able to see the "Collections" option in the server in remote desktop services manager.  The only option listed is "servers".  However to reactivate the account administrator and the server like him gave us all permissions to see the option of Collections and to deploy another remote application.

    My question would be, this is a policy of setting Group / somewhere that is limiting the other users of the full access to Office services in Server Manager remotely.  I looked everywhere on the server (and google) to see if I could find where this setting is vain.  Any suggestions/help would be greatly appreciated.

    Thank you!
    Heda

    Hello

    Server forums are in an another Microsoft Community to it.

    This community is mainly for users.

    Post your question in the TechNet Server Forums, as your question kindly is beyond the scope of these Forums.

    http://social.technet.Microsoft.com/forums/WindowsServer/en-us/home?category=WindowsServer

    See you soon.

  • Win2012 Server. Y at - it a shortcut to reach the Collections to the remote desktop Services without going through the Server Manager

    Win2012 Server. Y at - it a shortcut to reach the Collections to the remote desktop Services without going through the Server Manager?

    Hello

    Post your question in the TechNet Server Forums, as your question kindly is beyond the scope of these Forums.

    http://social.technet.Microsoft.com/forums/WindowsServer/en-us/home?category=WindowsServer

    See you soon.

  • How can I change the color of the plots (lines, points) in the collection Scattergraph plot

    For example, I go through a foreach loop and draw two points. How to distinguish this set of plots of the yet to come? How can I change the style, color and have separate lines (instead of on the line connecting everything) for each of my plots? I don't know how to set everything up, but it still does what he wants to do. TIA.

    Hello

    The problem you see occurs because of the following lines of code:

    The _data and _data2 scatterPlot3 value

    _data = scatterPlot3

    _data2 = scatterPlot3

    When you do this, you define _data as _data2 to reference an object of the simple concession - scatterPlot3.  Yes, even if you have (from the code you have posted at least) three slots in your collection, they are all pointing to the same object of point cloud.  So when you change the color for one, it changes the color for them all.  However, I think that you have fallen on the right solution in your last sentence.  If you want to have multiple locations on your ScatterGraph, each with its own color and style, they should each be separate and unique plots in the collection plot of your ScatterGraph.  Based on the code you posted, you'll see this if you comment just the two lines shown above.

    Please let me know if something is still uncertain.

    NickB

    National Instruments

  • Initialization of the DRAM in FPGA

    To test my FPGA (FlexRIO 7966), I tried to test the error trapping.  Generally, the error would be caused by an overflow in the FIFO of DMA process (EX: host VI is not reading fast enough causing the FPGA DMA fifo fill then causing my DRAM FIFOs to fill).  When this happens, simply reload the bitfile does not seem to clear the condition.  The memory is still in the complete state.  Even restart the controller does not seem to clear the error.  Electric bike does not work, but it's no possible to retrieve errors.

    It is impossible to probe whose memory is in trouble, so I ask:

    1. when the bitfile is loaded and running, the DMA FIFO is reset?  What of the DRAM (configured as FIFO)?  Or General FPGA FIFO memory (Blockram, registers, etc.)?

    2. it would be of no use to manually clear the DRAM during the initialization of the FPGA (EX: switch from data_available to read in a SCTL initialization until data_available is set to false and ignore the actual data)?

    File guides and aid users are very light on works the initialization of FPGA.

    Thank you

    xl600


Maybe you are looking for

  • How to pin a website to my Windows XP startup page

    Some Web sites automatically get made the fallen on my start page (new tab); but some I feel like I can't get there. I CN can't find the pin code function.

  • How can I retrieve e-mails deleted from the Inbox today instead of deleted folder

    I want to retrieve emails that were in my Inbox. I deleted them by mistake instead of my deleted folder. Is this possible? I have emails before June 20 that I still have. It is each after that I am concerned

  • HP 10 more 2201na

    The Audio connector on the left side of the Tablet - this is for the speakers and microphone. 1. is the stereo speakers? 2 are there compatible helmets? 3. what kind of plug 3.5 mm does and how it is wired. I can't find anything in the manual. It say

  • Properties of component of Windows 7

    Can anyone confirm that Windows 7 transmitter lets me only to use the dialing properties recognizes 9 to get an outside line only if the rest of the number to dial begins by + (bounding). I have over 20 k records in my database and you won't have to

  • Photos with scheduled tasks

    Hi allI'm trying to find a script that will create a scheduled task to take snapshots of a text file at a specific time. The file of text being the names of the virtual machines.Any help will be be created.