How do choices about Collection types

I am trying to recover data using its giving collection objects
ORA-01427: einreihig subquery returns more than one line, but if I use slider nested its working fine.


(Patient) CREATE TABLE
number of patid
fname varchar2 (25).
name varchar2 (25)
);


INSERT INTO patient
(
patid, fname lastname
)
VALUES (1, 'Pat1_FirstName', 'Pat1_Lastname');

INSERT INTO patient
(
patid, fname lastname
)
VALUES (2, 'Pat2_FirstName', 'Pat2_Lastname');


CREATE TABLE patient_add)
number of patid
address1 varchar2 (50).
address2 varchar2 (50).
State varchar2 (2),
zip of varchar2 (5)
);



INSERT INTO patient_add
(
Address1, Address2, State, patid, zip
)
VALUES (1, 'first Add1', 'Add2', 'NJ', ' 08817');

INSERT INTO patient_add
(
Address1, Address2, State, patid, zip
)
VALUES (1, 'second Add1', 'Add2', 'CT', ' 04461');



SELECT a.*, cursor (SELECT b.patid, b.address1, b.address2, b.state, zip
OF patient_add b
WHERE a.patid = b.patid
)
address
OF THE patient;

PATID FNAME LASTNAME ADDRESS
1 Pat1_FirstName Pat1_Lastname (CURSOR)
2 Pat2_FirstName Pat2_Lastname (CURSOR)

Its working fine

CREATE TYPE pat_obj
AS
OBJECT (patid number, varchar2 fname (25), name varchar2 (25))


CREATE TYPE pat_add_obj
AS
OBJECT)
number of patid
address1 varchar2 (50).
address2 varchar2 (50).
State varchar2 (2),
zip of varchar2 (5)
)


CREATE or REPLACE TYPE pat_add_col IS TABLE OF THE pat_add_obj


CREATE TYPE pat_det_obj AS OBJECT (pat pat_obj, pat_add_list pat_add_col)


CREATE or REPLACE TYPE pat_det_obj_col IS TABLE OF THE pat_det_obj


SELECT pat_det_obj_col (pat_det_obj (pat_obj (patid, fname, lastname),
(SELECT pat_add_col (pat_add_obj (b.patid,
b.Address1,
b.address2,
b.State,
zip
))
OF patient_add b
WHERE a.patid = b.patid)
)
)
PATIENT one

-ORA-01427: einreihig subquery returns multiple rows

Anyway, is that we can make selection with PL/SQL

Thank you
Alen
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

Try

select pat_det_obj_col (
          pat_det_obj (
             pat_obj (patid, fname, lastname),
             cast (
                multiset (
                   select b.patid, b.address1, b.address2, b.state, zip
                     from patient_add b
                    where a.patid = b.patid) as pat_add_col)))
  from patient a

Tags: Database

Similar Questions

  • How to use a collection type of variable binding to execute dynamic statement

    Hello

    We have a case where we copy selective data from A to B schema of schema in an oracle database. The copy is obtained using
    run immediately 'insert'. target_schema |'. TableA select * from '. from_schema |'. where a.id table (select test_id of ' | from_schema |'.) Table c); " ;

    It works very well it takes an average of 10 seconds to copy around 14 paintings. We have an obligation to bring this time to 2 seconds. An observation was the clause
    "Select test_id of ' | '. from_schema |'. Table c"in the statement sql preceding repeats for many inserts. So, we thought bulk get this set of codes of practice and use a vatiable bind to collection for the immediate run clause type. Any suggestions on how to achieve this?

    Thank you
    Chauvin

    >
    in fact, you cannot use native liaison as table_names in dynamic sql variable.
    >
    True - but OP uses a query string and can factor that string to do what was wanted
    >
    So we thought bulk get this set of codes of practice and use a collection type bind vatiable
    >
    It works

    CREATE OR REPLACE Package PK_BULK as
        Type code_tab_type is table of varchar2(25) index by varchar2(25);
        Type code_list_type is table of varchar2(25);
        FUNCTION  SF_LOAD_CODE_TAB (TAB_NAME IN VARCHAR2, COL_NAME IN VARCHAR2) RETURN CODE_TAB_TYPE;
    End PK_BULK;
    /
    
    CREATE OR REPLACE Package BODY PK_BULK as
        FUNCTION  SF_LOAD_CODE_TAB (TAB_NAME IN VARCHAR2, COL_NAME IN VARCHAR2) RETURN CODE_TAB_TYPE is
        query VARCHAR2(100);
        code_tab CODE_TAB_TYPE;
        code_list code_list_type;
    Begin
        query := 'SELECT ' || COL_NAME || ' FROM ' || TAB_NAME;
        EXECUTE IMMEDIATE query BULK COLLECT INTO code_list;
        FOR i IN code_list.FIRST .. code_list.LAST LOOP
           code_tab(code_list(i))  := code_list(i);
        END LOOP;
        RETURN code_tab;
    End;
    End PK_BULK;
    /
    
    -- test it
    declare
      i VARCHAR2(25);
      code_tab PK_BULK.CODE_TAB_TYPE;
      BEGIN
        CODE_TAB := pk_bulk.sf_load_code_tab ('emp', 'ename');
        i := code_tab.first;
        while i is not null loop
          DBMS_OUTPUT.PUT_LINE (code_tab(i));
           i := code_tab.next(i);
        end loop;
      END;
     
    
  • How to get information about the types within a user defined package

    Hi all
    Have a package with some types (user-defined) defined in the package specification. How to get information about the types and
    information about the columns of this type.

    for example:
    Create package mp is

    type t is record (no number is varchar2 (30));

    procedure a (m t out...

    Thanks in advance.

    userg

    G_user wrote:
    the req's, want to build a script dynamically using data dictionary
    so if possible, I take the name of the type within the package specification.

    Let me rephrase - is there a data dictionary to get information on the type defined by the user within a package specification

    Best approach will be to have a standard in the definition of data types.

    Have a process to follow the object definitions in the package if it is mandatory.

  • Data Modeler: how to create and use the collection type

    Hello
    essentially of departure I don't understand how (for example) create and use the data based on the type of data varray type.

    Please notify.
    Thank you
    Andrew

    Hi André,.

    You can create new types of collection (varray/table) in two ways:
    (1) in the browser - find 'Types of data' > 'Types of Collection' node menu dropdown - there just 'create new collection type' it
    (2) in the types of data model diagram - you can create collection "some type structured" or collection of references to the it - use 'new Collection... '. "tool and click first on sight structured type and after the structured type that will contain the collection - new attribute is added to the latter and if there is none this type of collection already didn't set the new collection type are created and you can change it later.

    Philippe

  • Question about the Type of SQL equivalent Collection Oracle

    (1) I read documentation collections oracle, can I know why the 'STORE AS' clause is used only when creating the table, but not when the object creation?

    Table:

    CREATE TYPE CourseList AS TABLE OF VARCHAR2(64);
    CREATE TABLE department (
      name     VARCHAR2(20),
      director VARCHAR2(20),
      office   VARCHAR2(20),
      courses  CourseList)
      NESTED TABLE courses STORE AS courses_tab;
    

    Object:

    CREATE TYPE CourseList AS TABLE OF VARCHAR2(10)  -- define type
    CREATE TYPE Student AS OBJECT ( -- create object
       id_num  INTEGER(4),
       name    VARCHAR2(25),
       address VARCHAR2(35),
       status CHAR(2),
       courses CourseList)  -- declare nested table as attribute
    

    (2) also can I know what is the difference between OBJECT & RECORD?

    My understanding is that the OBJECT is entity sql where you create and store data in this document, while the RECORDING is PLSQL entity where you group different types of data elements in one?, hope you can give me an example to better understand.

    Thank you.

    Ariean wrote:

    (1) I read documentation collections oracle, can I know why the 'STORE AS' clause is used only when creating the table, but not when the object creation?

    Fix. The column of the course are (similar to an array) collection type. This requires a "nested table" for this column store the list of the values in this column.

    This approach however is an exception to the rule - as it flies in the face of robust and sound design mathematically, relational.

    (2) also can I know what is the difference between OBJECT & RECORD?

    A record is similar to a struct in C/C++. A record contains one or more fields/variables. It's a basic structure for the creation of a 'container of variables' and by the way this container between code units, as oppose to pass individual variables. It is also the basis for the creation of intelligent data structures in structured programming. For example an IP socket structure is a unique smart container consisting of items/variables such as socket, protocol family and type, flags address and so on.

    It is a standard feature in most (if not all) of the structured programming languages - C / C++ and Pascal, Cobol and Visual Basic. PL/SQL is based on the Ada language - and like other members of language (including Pascal), PL/SQL uses the word registration reserve to set a record structure.

    Objects are created in Oracle using the "create or replace type... as object'clause. The correct term is an object oriented class. This differs from a record as a class has data and code. Unlike a record that counts only data.

    Given in a class are called properties. The code of a class is called methods. There are different types of member methods and methods such as the static class constructors, destructive methods.

    Oracle class object is defined using SQL. (Methods) code of this class is set using PL/SQL.

    The classes also supports features like inheritance. Allowing a child class extend the implementation of the parent class. This is not supported by a record structure, beyond a structure that contains another structure as a field attribute. Classes supports the substitution in a child class, the methods of the parent class. As records are composed only of data and not code, there is nothing like ito feature for structures Records.

  • Variable declaration of liaison for the collection type.

    Hello

    I have a procedue with collection (type) as output parameter.
    How can I run the procedure of the SQL prompt.

    Can I declare a variable binding in the form of a parameter that stores the type of collection.

    Thanks and greetings
    Rambeau

    Monica wrote:
    Yes, it's a typo. I also tried with "STOP_STAT_RES", but the result is the same.

    What are you talking about? Without doubt, one of the two generates a compile exception because the data type is incorrect...

    Monica wrote:
    STOP_STAT_RES is a collection of number abd the data types Date.

    Do you mean that you have created a user-defined type (e.g. CREATE TYPE >) which has attributes NUMBER and DATE? And that STOP_STAT_RES is a collection of such user-defined? Can you post the this user-defined type declaration?

    Justin

  • How to fill a collection?

    Hello

    I need to know how to fill a collection which I will later use to insert into the database. The following is an excerpt from the code I'm writing and please assume that all variables are correct except for the part in question.

    declare

    R_ipm_ip_addr RECORD TYPE IS
    (ip_addr_id, ipm_ip_addr.ip_addr_id%TYPE,
    ip_dec ipm_ip_addr.ip_decimal%TYPE,
    ip_addrr ipm_ip_addr.ip_address%TYPE,
    Comments ipm_ip_addr.comments%TYPE,
    own_orgid ipm_ip_addr.owner_organization_id%TYPE,
    sharing of ipm_ip_addr.sharing%TYPE,
    block_id ipm_ip_addr.block_id%TYPE);

    TYPE t_ipm_ip_addr IS TABLE OF THE r_ipm_ip_addr;
    l_ipm_ip_addr t_ipm_ip_addr: = t_ipm_ip_addr (r_ipm_ip_addr);

    BEGIN

    .......

    FOR indx IN 1... l_ipm_stat_host. Count

    LOOP

    ipm_net_index: = l_ipm_net. FIRST;

    While (ipm_net_index IS NOT NULL)

    LOOP

    IF l_ipm_stat_host (indx) .ip_addr_int .start_ip_int l_ipm_net (ipm_net_index) and l_ipm_net (ipm_net_index) .end_ip_int

    THEN

    dbms_output.put_line (l_ipm_stat_host (indx) .ip_addr |) » --> ' || l_ipm_net (ipm_net_index) .start_ipadd | » /'|| l_ipm_net (ipm_net_index) .cidr_size);

    v_ipnet_ipadd: = l_ipm_net (ipm_net_index) .start_ipadd;

    v_ipnet_cidr: = l_ipm_net (ipm_net_index) .cidr_size;

    OPEN c_get_block_id.

    EXTRACT c_get_block_id INTO v_parent_blkid, v_parent_orgid;

    CLOSE C_get_block_id;

    l_ipm_ip_addr.extend;

    l_ipm_ip_addr (l_ipm_ip_addr.last): = t_ipm_ip_addr (gen_uuid () l_ipm_stat_host (indx) .ip_addr_int, l_ipm_stat_host (indx) .ip_addr, .attr1 l_ipm_stat_host (indx) | l_ipm_stat_host (indx) .attr2, v_parent_orgid, 'sharing', v_parent_blkid); < < <-this is the part that gives me an error (PLS-00306: wrong number or types of arguments in the call to 'T_IPM_IP_ADDR')

    EXIT;

    END IF;

    ipm_net_index: = l_ipm_net. Next (ipm_net_index);

    y_ctr: = y_ctr + 1;

    END LOOP;

    -dbms_output.put_line (l_ipm_stat_host (indx) .ip_addr);

    v_ctr: = v_ctr + 1;

    END LOOP;

    END;

    Help you enjoy! Thank you!

    I got it!

    I added another variable to record and the values assigned to it before passing it to the table. See below for more details.

    declare

    R_ipm_ip_addr RECORD TYPE IS
    (ip_addr_id, ipm_ip_addr.ip_addr_id%TYPE,
    ip_dec ipm_ip_addr.ip_decimal%TYPE,
    ip_addrr ipm_ip_addr.ip_address%TYPE,
    Comments ipm_ip_addr.comments%TYPE,
    own_orgid ipm_ip_addr.owner_organization_id%TYPE,
    sharing of ipm_ip_addr.sharing%TYPE,
    block_id ipm_ip_addr.block_id%TYPE);

    TYPE t_ipm_ip_addr IS TABLE OF THE r_ipm_ip_addr;

    rec_ipm_ip_addr r_ipm_ip_addr;
    l_ipm_ip_addr t_ipm_ip_addr: = t_ipm_ip_addr();

    BEGIN

    .......

    FOR indx IN 1... l_ipm_stat_host. Count

    LOOP

    ipm_net_index: = l_ipm_net. FIRST;

    While (ipm_net_index IS NOT NULL)

    LOOP

    IF l_ipm_stat_host (indx) .ip_addr_int .start_ip_int l_ipm_net (ipm_net_index) and l_ipm_net (ipm_net_index) .end_ip_int

    THEN

    dbms_output.put_line (l_ipm_stat_host (indx) .ip_addr |) » -->'|| l_ipm_net (ipm_net_index) .start_ipadd | » /'|| l_ipm_net (ipm_net_index) .cidr_size);

    v_ipnet_ipadd: = l_ipm_net (ipm_net_index) .start_ipadd;

    v_ipnet_cidr: = l_ipm_net (ipm_net_index) .cidr_size;

    OPEN c_get_block_id.

    EXTRACT c_get_block_id INTO v_parent_blkid, v_parent_orgid;

    CLOSE C_get_block_id;

    l_ipm_ip_addr.extend;

    rec_ipm_ip_addr.ip_addr_id: = gen_uuid();

    rec_ipm_ip_addr.ip_dec: = l_ipm_stat_host (indx) .ip_addr_int;

    rec_ipm_ip_addr. IP_ADDR: = l_ipm_stat_host (indx) .ip_addr;

    rec_ipm_ip_addr.comments: = l_ipm_stat_host (indx) .attr1 | » -'|| l_ipm_stat_host (indx) .attr2 | » -'|| l_ipm_stat_host (indx) .attr3 | » -'|| l_ipm_stat_host (indx) .attr4 | » -'|| .attr5 l_ipm_stat_host (indx);

    rec_ipm_ip_addr.own_orgid: = v_parent_orgid;

    rec_ipm_ip_addr. Sharing: = 'shared ';

    rec_ipm_ip_addr.block_id: = v_parent_blkid;

    l_ipm_ip_addr (l_ipm_ip_addr. (Last): = rec_ipm_ip_addr;

    EXIT;

    END IF;

    ipm_net_index: = l_ipm_net. Next (ipm_net_index);

    y_ctr: = y_ctr + 1;

    END LOOP;

    -dbms_output.put_line (l_ipm_stat_host (indx) .ip_addr);

    v_ctr: = v_ctr + 1;

    END LOOP;

    END;

  • Ask about the types of objects

    Hello

    I have a question about the type of object. I want to see the script for the type of object created, that is already stored in the database. How can I see who


    Concerning

    Hello

    So, you can try [DBMS_METADATA. GET_DDL | http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14258/d_metada.htm#ARPLS640]...

    MHO%xe> create or replace type mytype as object( col varchar2( 10 ));
      2  /
    
    Type is aangemaakt.
    
    Verstreken: 00:00:00.37
    MHO%xe> select dbms_metadata.get_ddl('TYPE', 'MYTYPE') from dual;
    
    DBMS_METADATA.GET_DDL('TYPE','MYTYPE')
    ------------------------------------------------------------------------------
    
      CREATE OR REPLACE TYPE "MHO"."MYTYPE" as object( col varchar2( 10 ));
    
  • Creation of Collection Types

    I understand that to create a collection type to define, and then to declare the variable. Definition of a collection type can be done using 'declare the type' and 'create the type' statement.

    What is the difference between these two?

    Thanks in advance.

    Hello

    declare the type-online PL/SQL

    create type-Online SQL

    A simple search on this forum and http://asktom.oracle.com will give you many examples about when to create a type SQL or when you can use PL/SQL.

  • How to access objects collection

    How to access the collections of objects for example ReportSections report? I can access ReportSection, but not his collection...

    Reference: http://www.ni.com/pdf/manuals/372844e.pdf

    Maybe you don't understand exactly what section of the report is. According to the help:

    Use this class objects to store, update and transfer reports. You typically use the ReportSection objects to avoid creating copies of a report that the report is transferred between the generator of reports, process, Report and ReportView control object models. You can create a new ReportSection object by calling the Report.NewReportSection method. ReportSection objects can contain other ReportSection objects.

    As a general rule, a process template creates and updates the ReportSection object and assigns to the report object by setting the Report.ReportSection property.

    It has a sub-property called ReportSubsections , which specifies a reference to the ReportSections object, which is a collection that contains a list of child ReportSection objects to the current object. Looking at this object, it's a list of items that you can index through to get each.

  • How do I know what type of prossesor my laptop is and what is the speed of the processor?

    How do I know what type of prossesor my laptop is and what is the speed of the processor?

    On the start menu, click computer , and then click System Properties.

  • How do you manage file types in windows 7?

    How do you manage file types in windows 7? There was a tab for it under XP folder options. If I can't solve the problem I will downgrade to xp and back to windows 7.

    Tab file types has been removed in Windows Vista & Windows 7 and replaced by "default programs". If you need to customize the type of file to a higher level associations (for example, the addition or the change of a supplementary verb in a class file), you need to maybe use a third-party tool or change the registry manually.

    If you have a specific requirement, pls after return.

    Ramesh Srinivasan, Microsoft MVP (since 2003) for Windows desktop experience. The Winhelponline Blog http://www.winhelponline.com/blog/ (Windows 7/Vista/XP troubleshooting)

  • How can I get the type of coverage to work

    type of coverage

    How can I get the type of coverage to work

    Hi Ted,

    Once you take the type of coverage, it's ready to go!

    You are in a place to type in information?

    Once it is aligned, it works like a regular keyboard.

    B Eddie

  • How can I change the type of image file to download on a site like walmart or walgreens for printing?

    How can I change the type of image file to download on a site like walmart or walgreens for printing?

    In general, they will accept the image in the format, that it was taken (if it was taken by the majority of cameras or cell phones).  But if so, you have a few options.

    The most simple and integrated solution is Microsoft Paint.  Yes it is from the 1980s, but it still works and changes of a good job for a time.  Just to right click on the photo file, choose open with and choose paint.  Then go to file > save as and save this return as the file type you want it to be (like PNG or BMP or JPG, quality declining in the JPG option).

    If you need more options like changing the quality he uses during conversion, another free option (of the very very many) is Paint.NET, an open source free image editing program. http://www.dotPDN.com/downloads/PDN.html

    There are also programs that can do it in bulk, so you can highlight 300 photos and do convert them all at once.  You can do this for free or with tools like Photoshop.

  • How to assign Array/collection of data payload Humantask

    Hi guys,.

    I have an obligation to pass a collection of DBAdapter data for a payload of humantask which also has the collection type.

    but I can't give the collection to the collection.

    If I tried to pass of each column to the variable of the payload, then it will affect only the first data in the collection.

    I have attached the screenshot.

    Thank you

    I addressed this in a recent post: Re: store multiple values in a process data object

    Dan

Maybe you are looking for