user-defined types

Hi all

I have a function that returns a type defined by the user in my sql environment. The type consists of 5 different columns. I pass a ref_id to my function, on the basis of which he does some calculations and returns me the type.

create or replace type my_type

(

number of col1,

col2 varchar2 (100),

COL3 varchar2 (10),

number of COL4,

number of col5

)

create or replace function fun (number in_id) return my_type

as

Start

-code1

-code2

Return (my_type)

end;

In my sql environment, I have a table which is the following structure

create table tab1

(

number of emeline

upgvc varchar2 (100),

number of Ref_ID, - this ref_id when it is passed to the function above will return a populated user-defined type values.

number of col1,

col2 varchar2 (100),

COL3 varchar2 (10),

number of COL4,

number of col5

)

I have a table tab2, using which i will be filling of the columns of the table tab1, tab2 table structure is as below

create table tab2

(

number of emeline

upgvc varchar2 (100),

number of Ref_ID)

now I have to fill each column in table tab1, tab2 table and my pleasure to feature.

something like

Insert into tab1

Select emeline,

upgvc,

Ref_ID,

Rest of the values must be completed by calling the function using the ref_id and fill in the values. What would be the best way to do it? I have millions of records with it. I tried to use this with the function of REGAL and tried fill lines, but its slow.  All of the suggestions.

Note: apologies for not sticking scripts and the original code since it will take days

Thank you

Rahul

PetervdZwan wrote:

Hello

I agree that you shouldn't calc function for each attribute. But you don't need an extra table for this type.

See below:

Not sure what you mean:

SQL > set serveroutput on
SQL > select a.deptno,.
2 a.f.col1 col1,
a.f.col2 3 col2,
4 a.f.col3 col3,
5 a.f.col4 col4,
6 a.f.col5 col5
7 of)
8. Select wagneur, f1 (deptno) f
scott.dept 9 d
10          ) a
11.

DEPTNO COL1 COL2 COL3 COL4 COL5
---------- ---------- ---------- ---------- ---------- ----------
10         10 A          B                   2          3
20         20 A          B                   2          3
30         30 A          B                   2          3
40         40 A          B                   2          3

Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
SQL >

As you can see, function runs again 5 times by each line. You need to materialize in line of sight. It can be done using NO_MERGE:

SQL > select a.deptno,.
2 a.f.col1 col1,
a.f.col2 3 col2,
4 a.f.col3 col3,
5 a.f.col4 col4,
6 a.f.col5 col5
7 of)
8 select / * + no_merge * /.
wagneur, f1 (deptno) 9 f
scott.dept 10 d
11          ) a
12.

DEPTNO COL1 COL2 COL3 COL4 COL5
---------- ---------- ---------- ---------- ---------- ----------
10         10 A          B                   2          3
20         20 A          B                   2          3
30         30 A          B                   2          3
40         40 A          B                   2          3

Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
Call to F1
SQL >

However, I have and I know not why, the function is called not 4 but 6 times, using the type of collection (as in my first response) causes function calls only 4 - one per each line.

SY.

Tags: Database

Similar Questions

  • Question of the user defined Type (UDT)

    Hello

    The attached file is NEITHER sample to call a VB6 vi.

    The following is declared in the declaration section:

    ' Global declarations
    Dim lvapp As LabVIEW.Application
    Dim vi LabVIEW.VirtualInstrument

    When I paste these statement in another project (that I'm working on), I get an error 'undefined user-defined type '.

    Can someone point out to me were in the sample, these type definitions are declared?

    Thank you

    Rafi

    PS the attachment is indeed xxx.rar and not xxx.zip.  I changed the name because .rar has not been accepted.  Please rename .rar

    Thank you

    I forgot to mark references to my project

    Project--> references--> LabView. Type library of xxx

    Thank you

  • List of tables of objects or the user-defined type columns

    Hello

    SQL > select * from v version $;

    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE Production 11.2.0.2.0
    AMT for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production

    I have n number of tables in my db, since I have several
    tables containing "user defined type columns.
    so, how can I get/list db objects that contains the user-defined type columns only.
    Please suggest me on this

    Kind regards
    Faiz

    Dear Sir

    I have n number of tables in my db,from that i have several
    tables which contains"user defined type columns"
    so how could i get/list the db objects which contains user defined type columns only.
    Kindly suggest me on this
    

    Use this

    select
          tab.table_name
        , tab.column_name
        , tab.data_type
    from
        user_tab_columns tab
      , user_types typ
    where
        tab.data_type = typ.type_name
    order by
        tab.table_name
        ;
    

    Best regards

    Mohamed Houri

  • retrieving data from columns of user defined type

    Abstract types, I learned the other day. So I created an abstract type and a table.

    Create the student_ty as an object type
    (name varchar2 (20), number of roll);

    create table result)
    Student student_ty,
    (total);



    I also inserted data. But I'm having some trouble with the rretrieval of data. Suppose I want to choose only the roller and the name of the student as described in the type of studen. So I used the follwing query: -.

    Select result student.name;

    But it's not working. But when I use something like this: -.
    Select r.total, r.student.name in result r;


    This works perfectly. My question is that it is a rule that oracle needed to use an alias, whenever retrieve values for a user defined type data?. Help, please.
    Thanks in advance.

    Yes, you can use an alias when the type of object in a table like this.

    select r.student.name, r.student.roll, r.total
      from result r
    
  • Querying the user-defined types

    I have a chart in which one of the columns is a user-defined data type:
    SQL> describe my_table
    ...
    USER_DATA    MYTYPE
    The type 'MYTYPE' is a simple object that contains a field: a CLOB called MESSAGE:
    SQL> describe mytype
    Name       Null?    Type
    ------     -----    ----
    MESSAGE          CLOB
    When I do a "select *...» "in this table, the USER_DATA column appears as"MYTYPE (oracle.sql.CLOB@898c2d).

    I know that for CLOB and BLOB fields, Developer SQL let me double click on the value and display the content. But for type like this defined by the user that contains a field, I can't navigate the data members of type. I find myself wanting to do something like a 'select user_data.message from my_table", but this is not a valid syntax. Is there a way to query a given specific member of this type defined by the user with the rest of the columns in the table, I can display the CLOB member instead of a representation of the object? If not, is it possible to configure SQL Developer to allow me to browse the data members of types defined by the user? TOAD has a feature like that but I would only use SQL Developer and it is a table that I work with on a regular basis.

    csimons,

    Try this:

    select  t1.user_data.message
    from    eimgr.aq_rtv_docs_out_table t1
    where   rownum = 1;
    

    See you soon

    Edited by: Frenchwood on September 22, 2009 22:38

  • With the help of a user defined type as a return type of function with a type of object

    Hi, I created my own data type of table I want to use as data type back to a member function of an object type that I created.

    I work in an environment of 10g.

    The code I used looks like this:

    create or replace
    Dim p As Package as

    type p_rec is (number of v1);
    type p_tab is table of the p_rec;

    end p;
    /

    CREATE or REPLACE TYPE p_ot () AS OBJECT

    / * some statements * /.

    NO DEFINITIVE MEMBER FUNCTION p.p_tab RETURN foo

    );
    /


    When I try to compile p_ot I get an error: Error (5.40): PLS-00201: identifier 'P.P_TAB' must be declared.

    I don't know the syntax is correct so I must be missing something, amy hepl would be great.

    See you soon

    You can define types of objects

    create type p_rec as object ( v1 number );
    create type p_tab as table of p_rec;
    

    They can be used inside the package (p) in your example) as well as defined in the package.
    In this case, there will be no problems with create type

    CREATE TYPE p_ot AS OBJECT (
    
    /* some declarations*/
    
    NOT FINAL MEMBER FUNCTION foo RETURN p_tab
    );
    
  • Add the column to an existing table-based user-defined type

    Hello guys,.
    I am compiling my function that returns a type defined by the user based on an existing table. Throughout the process of initialization so my query returns an additional column - SCORE (1). Here is my package:

    create or replace
    PACKAGE STAFF_AGENCY_PKG AS

    TYPE TYPE_SEEKER_TABLE IS TABLE OF THE DRAW. SEEKER % ROWTYPE;
    FUNCTION GET_SEEKERS (IN_KEYWORD IN VARCHAR2)
    TYPE_SEEKER_TABLE RETURN PIPELINE;

    END STAFF_AGENCY_PKG;
    -------

    create or replace
    STAFF_AGENCY_PKG PACKAGE BODY
    AS

    FUNCTION GET_SEEKERS (IN_KEYWORD IN VARCHAR2)
    TYPE_SEEKER_TABLE RETURN PIPELINE
    IS
    R_TBL TYPE_SEEKER_TABLE; -to return
    BEGIN
    FOR R IN)
    SELECT Seeker.SEEKER_ID,
    Seeker.FIRSTNAME,
    Seeker.LASTNAME,
    Seeker.NATIONALITY,
    Seeker.ISELIGIBLE,
    Seeker.BIRTHDATE,
    Seeker.ISRECIEVEEMAILS,
    Seeker.HIGHESTDEGREE,
    Seeker.ETHNICITY,
    Seeker.GENDER,
    Seeker.ISDISABILITY,
    Seeker.DISABILITY,
    Seeker.CV,
    Seeker.PASSWORD,
    Seeker.PREFFERED_CITY,
    SEEKER. E-mail
    SEEKER. JOB_PREFERENCES_ID,
    SCORE (1)
    THE APPLICANT Seeker
    WHERE CONTAINS (CV, ' < query >)
    < textquery lang 'grammar' = 'context' = > ' |
    GET_RELATED_CATEGORIES (IN_KEYWORD) |
    ' < / textquery >
    < score datatype = "INTEGER" / >
    (< / query > ', 1) > 0
    )
    LOOP
    PIPE ROW (R); -Error (38,10): PLS-00382: expression is of the wrong type
    END LOOP;
    RETURN;

    END GET_SEEKERS;
    END STAFF_AGENCY_PKG;

    How do I change my user type to be sufficient?

    Oracle version 11.2.0.1.0
    Thanks in advance!

    >
    How do I change my user type to be sufficient?
    >
    You will need to create two new TYPEs. The one who has all the columns of the draw. The REQUESTOR table and the new column SCORE, then a TYPE which is an array of the first type.

    See example 12-22 using a Pipelined Table function for a Transformation in the PL/SQl language reference

    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/tuning.htm#i53120

    Here's the first part

    -- Define the ref cursor types and function
    CREATE OR REPLACE PACKAGE refcur_pkg IS
      TYPE refcur_t IS REF CURSOR RETURN employees%ROWTYPE;
      TYPE outrec_typ IS RECORD (
        var_num    NUMBER(6),
        var_char1  VARCHAR2(30),
        var_char2  VARCHAR2(30));
      TYPE outrecset IS TABLE OF outrec_typ;
     FUNCTION f_trans(p refcur_t)
          RETURN outrecset PIPELINED;
    END refcur_pkg;
    /
    
    CREATE OR REPLACE PACKAGE BODY refcur_pkg IS
      FUNCTION f_trans(p refcur_t)
       RETURN outrecset PIPELINED IS
        out_rec outrec_typ;
        in_rec  p%ROWTYPE;
      BEGIN
    

    Change

      TYPE outrec_typ IS RECORD (
        var_num    NUMBER(6),
        var_char1  VARCHAR2(30),
        var_char2  VARCHAR2(30));
      TYPE outrecset IS TABLE OF outrec_typ;
    

    to include all the columns you need. Unfortunately, you have to manually list all the columns in the draw. The REQUESTOR table. If you think you need this same structure in other places you must create them as SQL types instead of PL/SQL types.

    This example should be enough to show you how to modify your code to do something similar.

  • call a DLL that has the user-defined types

    I am trying to call a function in a DLL that is

    int32 system_config(&recCfg, &pulseCfg, errMsg)
    

    recCfg is a structure consisting of 3 double rooms and 2 integers

    and pulseCfg is a structure consisting of just Boolean

    I don't know how to set the input parameters for this call the library feature.

    LabVIEW sees as

    void system_config(void)
    

    I see the only choice of Numeric, Array, String, waveform, digital waveforms, digital data, ActiveX, Adapt to Type and pointer to Instance data for arg1.  ActiveX seems to be the only one to use?

    NYC says:

    I am trying to call a function in a DLL that is

    int32 system_config(&recCfg, &pulseCfg, errMsg)
    

    recCfg is a structure consisting of 3 double rooms and 2 integers

    and pulseCfg is a structure consisting of just Boolean

    Actually contrary to what Simon says you can do in this case. But your line you are showing is unfortunately very unclear, because he does not understand the real typedef for your clusters. So I have to go by what you write in prose that is... Well... not very detailed.

    The first is simply a cluster in LabVIEW with 3 floats to double precision, followed of 2 integers. You find yourself what bitsize integer, you need, as you do not show the typedef in the cluster. In order to connect to a cluster in a CLN you must configure this setting as to adapt to the Type. But be careful who does not work for clusters containing strings or arrays at all. Tables and chains of LabVIEW are something completely different than what awaits a C DLL. You can configure the parameters of function to be C compatible pointers to arrays and strings and LabVIEW will make sure to do the conversion on every call, but you cannot configure the CLN to convert strings and tables within a cluster.

    The second group is really equivalent to a simple Boolean value passed by reference. As you do not show the actual type of the Boolean value, it is difficult to recommend this type of data to use in LabVIEW. Windows BOOL is a 32-bit integer and C++ bool is usually a 8-bit value which would coincide with the Boolean LabVIEW 8-bit use. You cannot configure a Boolean setting directly in the NLCS, so you can either use an integer of size accordingly or create this cluster with a single LabVIEW boolean anyway (if your bool is a bool C++ and not something else) and do the same as for the previous cluster/structure parameter.

  • Create user defined TYPE in sql

    Hi all

    I want to create type as below.

    Student TYPE
    IS
    record
    (
    TABLE of object VARCHAR2 (100),
    TABLE FOR mark1 VARCHAR2 (50).
    TABLE OF mark2 VARCHAR2 (50).
    Brand TABLE 3 VARCHAR2 (100)
    );


    I get the error. Like this
    Error (28.3): PLS-00103: encountered the symbol "TABLE" during awaits one of the following values: pragma < an ID > < a between double quote delimited identifiers of >

    My intention is that,

    For each student, I need to HAV an arrary of topics, mark1, mark2, mark 3...
    I actually cut my requirement of project very simple requirement.
    Here for a reason, I need this structure to be like that. Kindly ignore the idea that the subtype of object, mark1,... etc.

    Kindly help me in this regard.


    Thank you
    Sabarisri. N

    something like

    create type subject_tt
    is table of varchar2(100)
    /
    
    create type mark_tt
    is table of varchar2(50)
    /
    create type student
    as object
    (subjects subject_tt
    ,marks    mark_tt
    )
    /
    

    What I don't understand is, why don't you make a relational good datamodel? Makes life a lot easier...

    Published by: Alex Nuijten on August 19, 2011 11:33

  • Inserting data from the user-defined Type

    Hi all

    I have the following type
    create or replace type answer_obj is object (all_employee_seq integer,questionseq varchar2(10),text_answer varchar2(4000),optionseq varchar2(10));
    
    create or replace type answer_tbl is table of answer_obj;
    I have the procedure (within a package) that pulls in the python papers.
    TYPE answer_tbl_type IS TABLE OF question_answer%ROWTYPE
                                   INDEX BY PLS_INTEGER;
    
    PROCEDURE submit_survey (p_answers IN OUT answer_tbl)
       IS
          l_answers_tbl   answer_tbl_type;
       BEGIN
          FOR i IN p_answers.FIRST .. p_answers.LAST
          LOOP
             l_answers_tbl (i).all_employee_seq := p_answers (i).all_employee_seq;
             l_answers_tbl (i).questionseq := p_answers (i).questionseq;
             l_answers_tbl (i).text_answer := p_answers (i).text_answer;
             l_answers_tbl (i).optionseq := p_answers (i).optionseq;
          END LOOP;
    
    
          FORALL idx IN l_answers_tbl.FIRST .. l_answers_tbl.LAST
             INSERT INTO QUESTION_ANSWER
                  VALUES l_answers_tbl (idx);
       
       END;
    My question is, is it better to insert the data directly from the (record) (records) argument using for LOOP INSERT or the conversion of the argument in an associative array and a FORALL?
    As you can see, it's a FOR LOOP to set the values in the array and then by the FORALL.

    I think the above is even faster because of the first LOOP IS done in memory and real integration is carried out with FORALL.
    I want to get as many opinions.


    See you soon,.
    Joel

    Hello

    Because you created the SQL Types, what just to do this within your procedure?

    INSERT INTO QUESTION_ANSWER (all_employee_seq, questionseq, text_answer, optionseq)
    SELECT all_employee_seq, questionseq, text_answer, optionseq
    FROM TABLE(p_answers);
    
  • Selection in the SQL user-defined Type

    I can't try to fill a SQL can be set from a query type:
    SQL> select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    
    SQL> create type typ_colVarchar30 is table of varchar2(30)
      2  /
    
    Type created.
    
    SQL> declare
      2     v_colVarchar30 typ_colVarchar30;
      3  begin
      4     select table_name into v_colVarchar30 from user_tables;
      5  end;
      6  /
       select table_name into v_colVarchar30 from user_tables;
              *
    ERROR at line 4:
    ORA-06550: line 4, column 11:
    PL/SQL: ORA-00932: inconsistent datatypes: expected UDT got CHAR
    ORA-06550: line 4, column 4:
    PL/SQL: SQL Statement ignored
    
    
    SQL> drop type typ_colVarchar30;
    
    Type dropped.
    I can't use a collection of PL/SQL. It must be a SQL type.

    Thank you.

    Brian

    Use BULK COLLECT

    declare
        v_colVarchar30 typ_colVarchar30;
    begin
       select table_name bulk collect into v_colVarchar30 from user_tables;
    end;
    
  • How to get user defined Native Types is displayed

    I added a new user defined native Type using type Admin

    Define Custom Type.png

    I saved, closed and then reopened the Data Modeler, but he does not appear in the Source Type drop-down list when I define a column in the relational model. I've defined the relational model to use 12 c as the Site of RDBMS. Am I missing a step in the installer?

    I use 4.1.3 on a Mac.

    Hello Kent,

    the native DB types never appear in the column definition. You need to create the new type of logical data and map it to the native type or change the mapping of logical type existing. The steps are confusing because it's like the problem or chicken (which is the first), you you will be defined first:

    (1) define the native type - save definitions - defined by the user of the native types had to be saved in order to be available for native types logic mapping

    (2) identify the type of logic - probably VARIANT in your case, define the mapping of native type logic

    (3) in native type definition define the mapping of native code to the logical type (it is mapped on the CLOB type on your photo - probably you will change it)

    (4) save the definitions

    Philippe

  • 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.

  • 9144 with FPGA and SGL EtherCAT custom user-defined Variables?

    Hello

    I currently have a small instrument driver (rs485) running on a chassis of 9144. The output values are communicated to the master EtherCAT using FXP numbers. I would like to pass these FXP to SGL, since I've upgraded to SP1 2012 LV with FPGA now supports numbers of SGL.

    Is this possible? I tried several times to create the Variables defined by the user of SGL in the project, but the date type is gray.

    Greetings from Munich,

    Götz

    Unfortunately, SGL is not a data type supported for communication to and from a 9144. The types of data available for the I/O user-defined variables are:

    * Fixed point
    * Signed integers (Int8, Int16, Int32, Int64)
    * Integers (UInt8, UInt16, UInt32, UInt64)
    * 32 bit field
    * Boolean

    More information on I/O user-defined variables can be found at:

    Programming EtherCAT i/o with FPGA Intelligence to: Differences in LabVIEW FPGA programming API
    http://www.NI.com/white-paper/10618/en#toc4

  • How to create a user-defined function?

    is there a substitute for the exe instsrv and srvany in Vista?

    I don't know what means your post, so here's how to create a user-defined function:
    1) click Start
    (2) select "Control Panel".
    (3) select "system and maintenance".
    4) click on "Administrative Tools".
    5) click on "Task Scheduler."
    (6) click on "create task" (right in the list pane under) "Actions") "
    "(7) opened in the general tab it will choose if it only works when the account that is used to implement is connected, or ' if that user is logged in or not" (leave the box ' do not store the... "empty password)
    (8) always in the general tab, check the box 'run with highest privileges '. (This will ensure that no program can block)
    (9) type a name for the task (in the general tab)
    (10) to set the job to run an awhile, use the "triggers" tab, if you want to set a task runs after xx min. temps_inactivite, choose the 'conditions' tab, then choose the desired time.
    (12) click on the 'actions' tab click on 'new '. in the program/script line, search for and select the program you want to run, and then click Open.
    13) click OK in the window "create a task".
    14) click OK again and you are done.
    I hope this helps.

Maybe you are looking for