After select stmt. why the count value of variable column, nested table is zero.

CREATE OR REPLACE TYPE numbers_type
ARRAY OF INTEGER
/
CREATE OR REPLACE PROCEDURE p(i) in FULL IS
numbers1 numbers_type: = numbers_type (1,2,3,4,5);
BEGIN
DBMS_OUTPUT. Put_line ("exposed before SELECTING");
DBMS_OUTPUT. Put_line('numbers1.) COUNT() = ' | numbers1. COUNT());
FOR j IN 1.numbers1. COUNT() LOOP
DBMS_OUTPUT. Put_line ('numbers1 (' | j |)) ') = ' || numbers1 (j));
END LOOP;
-Auto selection clause to COLLECT LOOSE:
SELECT a.COLUMN_VALUE
LOOSE COLLECTION numbers1
TABLE (numbers1) one
WHERE a.COLUMN_VALUE > p.i
ORDER BY a.COLUMN_VALUE;
DBMS_OUTPUT. Put_line ("presentation and SELECT '");
DBMS_OUTPUT. Put_line('numbers1.) COUNT() = ' | numbers1. COUNT());
END p;
/
Call p:
BEGIN
p (2);
END;
/

Hello

Before taking in the collection variable, the values of the variables are fushed. So in this case the numbers1 is empty so it becomes zero and trying to read values from this collection which is already empty.

That's why you get the number zero

PRABHU

Tags: Database

Similar Questions

  • Select the distinct value of a column in the collection in bulk.

    Hi all

    Collecting the data of a query to a variable of type table. I need to select a separate of a perticular column value in the collection.

    Collection has followiing values inside.
    Col(c).articleid,
    Col(c).userkey,
    Col(c).origin,
    Col(c).addnlorigindata,
    Col(c).avdest,
    Col(c).dispfmt,
    Col(c).sourcecode,
    Col(c).success_ind,
    Col(c).error_code,
    Col(c).entry_createddate,
    Col(c).createdby,
    Col(c).filenumber,
    Col(c).linenumber,
    Col(c).acctnum,
    Col(c).assetkey,
    Col(c).autocompletedterm,
    Col(c).accessionnumber,
    Col(c).requestdatetime,
    Col(c).requestorip,
    Col(c).articleordinal,
    Col(c).userinitiatedind,
    Col(c).captchastatus
    I need to select distinct column values (for example: Col (c) .sourcecode) collection and the need to insert in the table if the value in this column does not exist in the table.

    Say, Col (c) .sourcecode has the value XYZ, ABC. If the "XYZ" value does not exist in the table, so I need to insert in the table and if "ABC" exists in the tables then don't insert it. (something like fusion) after seecting to the distinct values in a column in the collection.

    Thanks n regards
    Nana Akkivalli.

    The collection must be inserted before you can use this topic.

    In the Begin block, you have to collect a loose and insert inside: something like

    SELECT *
    BULK COLLECT INTO l_array
    FROM ALL_USER
    ...CONDITIONS...
    
  • I have a column with two values, separated by a space, in each line. How to create 2 new columns with the first value in a column, and the second value in another column?

    I have a column with two values, separated by a space, in each line. How do I create 2 new columns with the first value in one column and the second value in another column?

    Add two new columns after than the original with space separated values column.

    Select cell B1 and type (or copy and paste it here) the formula:

    = IF (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    shortcut for this is:

    B1 = if (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    C1 = if (Len (a1) > 0, Member SUBSTITUTE (A1, B1 & "", ""), "")

    or

    the formula of the C1 could also be:

    = IF (Len (a1) > 0, RIGHT (A1, LEN (A1) −FIND ("", A1)), "")

    Select cells B1 and C1, copy

    Select cells B1 at the end of the C column, paste

  • How to highlight the minimum value in a column?

    I need to highlight the lowest value in each column in my spreadsheet. I try to use the conditional nail, but I can't find a function to work as I need.

    One way would be to calculate the minutes in a cell of a footer row, select the cells in the body of the column and apply conditional highlighting like this:

    You must click on the chip address first, and then select the comparison cell, A8 here, then be sure to keep the row and column.

    The A8 from the example formula is = MIN (A).

    The result is a bold 2 (not shown in the screenshots).

    SG

  • How to set the default value of a column from the value of the 2 columns given

    Is it possible to set the default value for a column A, as the concatenated values of columns B and C of the create table statement itself without using the trigger.

    for example, in a line, if column B is 'James' and column C is "smith" then the column has must be "james Smith".
    in another line if column B is 'Bob' and column C is "Taylor" then column should be "Bob Taylor"

    Thank you
    YG

    Yes, it is possible. But what is your version of the database? Try to use "virtual column. Search for a virtual column in the following link.
    http://www.Oracle.com/technology/pub/articles/Oracle-database-11g-top-features/11g-schemamanagement.html
    http://download.Oracle.com/docs/CD/B28359_01/server.111/b28286/statements_7002.htm

  • What is the difference between associative arrays and nested tables?

    Hello
    What is the difference between associative arrays and nested tables?

    nested tables cannot be indexed by other than pls_integer and unlike nested tables table associative cananot be declared at the schema level.

    is there any other difference set apart from the diff above 2?

    user13710379 wrote:
    What is the difference between associative arrays and nested tables?

    Name-value pairs (associative) against a list of values (table standard/nested table).

    nested tables cannot be indexed by other than pls_integer

    They are not "indexed" the way in which an associative array is indexed. A standard table is referenced by the position of the cell in the table. This position is essentially the offset of the memory of the cell from the start address of the table.

    Can not solve a cell in an associative array directly via a memory offset index. You place a cell reference value it by his 'name' (a search in the linked list/hash table).

    The following example shows the difference between the pairs of name / value and a list of core values.

    SQL> declare
      2          --// associative arrays are NAME-VALUE pairs
      3          type TArr1 is table of varchar2(10) index by pls_integer;
      4          type TArr2 is table of varchar2(10) index by varchar2(10);
      5
      6          arr1    TArr1;
      7          arr2    TArr2;
      8  begin
      9          arr1(100) := '1st entry';
     10          arr1(1) := '2nd entry';
     11          arr1(5) := '3rd entry';
     12
     13          arr2('john') := 'New York';
     14          arr2('jane') := 'Paris';
     15          arr2('jack') := 'London';
     16
     17  end;
     18  /
    
    PL/SQL procedure successfully completed.
    
    SQL>
    SQL>
    SQL> declare
      2          --// standard arrays are lists
      3          type TArr3 is table of varchar2(10);
      4          type TArr4 is table of number;
      5
      6          arr3    TArr3;
      7          arr4    TArr4;
      8  begin
      9          arr3 := new TArr3( '1st entry', '2nd entry', '3rd entry' );
     10
     11          arr4 := new TArr4( 100, 1, 5 );
     12  end;
     13  /
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    
  • Why the relative values of RGB and CMYK will not change when switching between Photoshop and InDesign?

    I'm trying to put together a Guide to color for my company's brand guidelines.

    Initially, I worked for InDesign and copied all H, RGB and CMYK values that I had when I went in an eye my original color palette.

    However when I put the same values of RGB in Photoshop I gives me a (somewhat) a different set of CMYK numbers than I had initially documented in InDesign.

    Why is this?

    JamieCurtis5 wrote:

    It makes me feel a bit nervous leaving aside CMYK all together...

    CMYK is essential for a company's brand guide. The printer ask again, it's a simple and direct question. If they cannot answer this fundamental question, that speaks well of their professional standards. It is a common practice and highly standard procedure. I do it all the time (and get answers directly in the world).

    That said, if this guide in general and not necessarily related to this particular printer, it might be preferable, specify a profile which is commonly used as a general practitioner in your area. It depends on where you are. Here in Europe, it would be either Coated FOGRA39, ISO Coated v2 300% (eci).

    In the United States, I guess us Web Coated (SWOP) v2 would be on a list, not because it's necessarily just for the purpose, but simply done to be the default Photoshop. Printers must get loads of the present. Same here in Europe, where this profile is never used any where, a lot of people use it just because it is the default value of the PS and it never gets turned into something more appropriate.

  • Why the initial value of the text box disappear?

    I applied javascript to the text box on this page to make the initial value disappear when the user clicks on the box, but it doesn't seem to work. Can someone please tell me why?

    http://clockdoctors.co.UK/contact_me.html

    You have not included the framework jQuery:

  • Why the color values do not change when you use proof colors?

    Hello

    I am very interested in getting accurate replicas of the image on the screen (in ProPhoto) and the image (using a suitable printer profile). However when I choose test colors on the display menu, changes in appearance, but the colors RGBV or laboratory remain the same. It is against intuitive and goes against the well known for color recommendation to correct using numbers instead of your eyes.

    What is going on? Is there a way to accomplish what I want?

    Thank you

    Juan

    Not quite what you want, but the info panel can be configured to read the evidence values.

  • Change the default value of some columns in an oracle 11g table

    I have a table called cust_file, its table consists of a large number of columns (one of these columns called cus_tax) and have a lot of data.

    I use oracle 11g, I want to change the default value of the column cus_tax is equal 1.

    I wrote

    ALTER TABLE cust_file MODIFY (1 by DEFAULT cus_tax).


    Table changed


    but after I inserted new data to test the operation, I found that the new record has a value = null for the column cus_tax


    then I tested it using the following query


    Select data_default in the all_tab_columns where table_name = 'CUST_FILE' and column_name = 'CUS_TAX ';

    no selected line


    so please help me to change the default value of the cus_tax column.



    Thanks for any help.



    > but after I inserted new data to test the operation, I found that the new record has a value = null for the column cus_tax

    If the INSERT included a NULL value for the column, the GET of a NULL inserted by default substitution.

    SQL > create table hkc_test_10 (id_column number, data_col_1 varchar2 (5), data_col_2 varchar (5));

    Table created.

    SQL > insert into hkc_test_10 values (1, 'First', 'F');

    1 line of creation.

    SQL > select * from hkc_test_10 by 1.

    ID_COLUMN DATA_ DATA_
    ---------- ----- -----
    1 first F

    1 selected line.

    SQL > alter table hkc_test_10 change (data_col_2 default 'TRUE');

    Modified table.

    SQL > insert into hkc_test_10 values (2, 'Second', NULL);

    1 line of creation.

    SQL > select * from hkc_test_10 by 1.

    ID_COLUMN DATA_ DATA_
    ---------- ----- -----
    1 first F
    2 second

    2 selected lines.

    SQL > insert into hkc_test_10 (id_column, data_col_1) values (3, 'Third');

    1 line of creation.

    SQL > select * from hkc_test_10 by 1.

    ID_COLUMN DATA_ DATA_
    ---------- ----- -----
    1 first F
    2 second
    3 third TRUE

    3 selected lines.

    SQL >

    Hemant K Collette

  • How to map the entered value of attribute column to another attribute in the table for each row.

    Hi Experts ADF,

    JDev 12 c.

    I create a button and a table below. If the user clicks on the button create, I invoke CreateInsert. The new line now appears as an editable fields.

    So I suppose I have a column that is displayed in editable mode. If the user enters values in that. Has another column B whose value is not displayed in the UI must have the same value as the column.

    This occurs for each row added. During the click on save if user entered 2 in column A, then the value in column B must be same 2.

    Thank you

    Roy

    There is more than one way, for example:

    Generate ViewRowImpl Java class (with generate audited accessors) you will get for an attribute setter.

    Change the Set accessor to set the attribute B (IE, calling setAttribute ("B", value)) after setting a value

    OR, write valueChangeListener for inputText representative and set the B attribute to the same value

  • Find the same value in different columns

    Hello

    I'm trying to figure out how I would get the same value in the same row but in different columns. For example, in the table sometimes report the name is the same as the description. I would like to find all the lines where this is the case.

    Thank you

    Name of the report
    Description
    Date
    Time
    Report 1Report 1DelalandeTTTT
    Report 2Billing reportDelalandeTTTT
    Report 3Report 3DelalandeTTTT

    Hello

    Is that what you want?

    SELECT *- or whatever the columns that you want to

    FROM table_x

    WHERE description = report_name

    ;

    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

  • PARTITION OF? Returns an identifier based on the minimum value of another column

    Hi guys

    I want to return the ID column of a line, where 2 other columns = a value set, and a 3rd column has the minimum value corresponding to the other criteria.

    so, indeed:

    with t as (
    select 1 dst_id, 'abc' dst_title, 1 edition_from, 1 media_item from dual 
    union all 
    select 2 dst_id, 'abc' dst_title, 1 edition_from, 2 media_item from dual 
    union all 
    select 3 dst_id, 'abc' dst_title, 2 edition_from, 1 media_item from dual 
    union all 
    select 4 dst_id, 'abc' dst_title, 2 edition_from, 2 media_item from dual 
    union all 
    select 5 dst_id, 'def' dst_title, 1 edition_from, 1 media_item from dual 
    union all 
    select 6 dst_id, 'def' dst_title, 1 edition_from, 2 media_item from dual 
    )
      select dst_id
      from t
      where dst_title = 'abc' 
      and edition_from = 1
      and media_item = minimum value of media item using above where clause
    Return dst_id = 1 because it has the value point minimum media 1 where dst_title = abc and edition_from = 1

    Is this possible in 1 query? I tried using partition and on dst_title, edition_from, but it does not work.

    I am currently using a query sub or 2 queries, but think that there must be a way to do it in a?

    Thank you all

    Scott

    pus

    with t as (
      select 1 dst_id, 'abc' dst_title, 1 edition_from, 1 media_item from dual union all
      select 2 dst_id, 'abc' dst_title, 1 edition_from, 2 media_item from dual union all
      select 3 dst_id, 'abc' dst_title, 2 edition_from, 1 media_item from dual union all
      select 4 dst_id, 'abc' dst_title, 2 edition_from, 2 media_item from dual union all
      select 5 dst_id, 'def' dst_title, 1 edition_from, 1 media_item from dual union all
      select 6 dst_id, 'def' dst_title, 1 edition_from, 2 media_item from dual
    )
    select min(dst_id) keep (dense_rank first order by media_item) as dst_id
    from t
    where dst_title = 'abc'
    and edition_from = 1
    ;
    
  • get the value of the maximum value of a column for a particular type

    Hello.
    I have a query which returns the output something like

    Type of VersionNo ID ProductID VersionID category unusual
    1130 16650 16650 1193 5 Category1
    1130 16650 16650 1205 5 Category2
    1130 16650 16650 1242 5 category3
    1130 16650 1130 1001 1 Category1
    1130 16650 1130 1081 1 category3
    1131 16656 16656 1193 4 Category1
    1131 16656 16656 1205 4 Category2
    1131 16656 16656 1240 4 category3
    1131 16656 1131 1001 1 Category1
    1131 16656 1131 1081 1 category3

    I want to see the result that all the VersionId for the same ID values should have the same value for the category and it should be the value that is there for the maximum versionNo for a particular Type of «» Something like


    Type of VersionNo ID ProductID VersionID category unusual
    1130 16650 16650 1193 5 Category1
    1130 16650 16650 1205 5 Category2
    1130 16650 16650 1242 5 category3
    1130 16650 1130 1193 1 Category1
    1130 16650 16650 1205 1 Category2
    1130 16650 1130 1242 1 category3
    1131 16656 16656 1193 4 Category1
    1131 16656 16656 1205 4 Category2
    1131 16656 16656 1240 4 category3
    1131 16656 1131 1193 1 Category1
    1131 16656 16656 1205 1 Category2
    1131 16656 1131 1240 1 category3

    Does anyone know how to do this?

    Ok
    Try:

    WITH test_data AS (
    SELECT 1130 RecID, 16650 ProductID,  16650 VersionID, 1193  Category,  5 VersionNo, 'Category1' Type FROM DUAL UNION ALL
    SELECT 1130, 16650, 16650, 1205, 5, 'Category2' FROM DUAL UNION ALL
    SELECT 1130, 16650, 16650, 1242, 5, 'Category3' FROM DUAL UNION ALL
    SELECT 1130, 16650, 1130, 1193, 1, 'Category1' FROM DUAL UNION ALL
    SELECT 1130, 16650, 1130, 1205, 1, 'Category2' FROM DUAL UNION ALL
    SELECT 1130, 16650, 1130, 1242, 1, 'Category3' FROM DUAL),
    -- end test data
    max_data AS (
    SELECT RecID, ProductID, VersionID, Category, VersionNO, Type
      FROM test_data td1
     WHERE VersionNo = (
      SELECT MAX(VersionNo)
        FROM test_data td2
      WHERE td1.RecID = td2.RecID
         AND td1.ProductId = td2.ProductID))
    SELECT RecID, ProductID, VersionID, Category, VersionNO, Type
      FROM max_data
      UNION
    SELECT md1.RecID, md1.ProductID, td1.VersionID, md1.Category, td1.VersionNO, md1.Type
      FROM max_data md1
      JOIN test_data td1
     ON (md1.RecID = td1.RecID AND md1.ProductID = td1.ProductID)
    ORDER BY 1,2,3,5, 6
    
         RECID  PRODUCTID  VERSIONID   CATEGORY  VERSIONNO TYPE
    ---------- ---------- ---------- ---------- ---------- ---------
          1130      16650       1130       1193          1 Category1
          1130      16650       1130       1205          1 Category2
          1130      16650       1130       1242          1 Category3
          1130      16650      16650       1193          5 Category1
          1130      16650      16650       1205          5 Category2
          1130      16650      16650       1242          5 Category3
    

    And you simply:

    WITH max_data AS (
    SELECT RecID, ProductID, VersionID, Category, VersionNO, Type
      FROM test_data td1
     WHERE VersionNo = (
      SELECT MAX(VersionNo)
        FROM test_data td2
      WHERE td1.RecID = td2.RecID
         AND td1.ProductId = td2.ProductID))
    SELECT RecID, ProductID, VersionID, Category, VersionNO, Type
      FROM max_data
      UNION
    SELECT md1.RecID, md1.ProductID, td1.VersionID, md1.Category, td1.VersionNO, md1.Type
      FROM max_data md1
      JOIN test_data td1
     ON (md1.RecID = td1.RecID AND md1.ProductID = td1.ProductID)
    ORDER BY 1,2,3,5, 6
    
  • How to use the default value of a column in a table in insert or upda

    Hello

    I try to use the values by default so that the user should not have to enter data, but when I select default type and a default, I see an error message if I try to add a new line.

    How can I use a default value to a column in a tabular presentation?

    Gouri

    Published by: user1046395 on April 3, 2009 09:58

    Gouri,

    You can change simply to attribute each report column. For example,.

    To set the default date.
    Default type: PL/SQL Expression of function
    Default: sysdate

    To set the default text,
    Default type: PL/SQL Expression of function
    Default: * "CLERK."

    If you still get an error, what is the error message?
    Tarraf

Maybe you are looking for