Question about function table in pipeline

I did an object:
CREATE TYPE FML_DAT_ITEMS_OBJ AS OBJECT ("F0"      varchar2(4000), ...
Then I did an object table:
create or replace type fml_dat_items_ftab is table of FML_DAT_ITEMS_OBJ
Everything is fine!

Now, I want to do the function pipeline:
create or replace 
FUNCTION get_fml_items_dat (pfml_nr in number) return fml_dat_items_ftab pipelined as
  
   out_rec FML_DAT_ITEMS_OBJ := FML_DAT_ITEMS_OBJ() ;
   
  begin
     select item_dat into out_rec."F0" from fml_dat_items where fml_nr = pfml_nr and item_nr=   0.00;
     pipe row (????); -- HOW can I pipe the object to the function result set?
Published by: Walter on 14.05.2013 05:29

Hello

Try this:

create or replace type FML_DAT_ITEMS_OBJ AS OBJECT
(
f_name varchar2(20)
,l_name varchar2(20)
)
;

create or replace type fml_dat_items_ftab as table of FML_DAT_ITEMS_OBJ
;

select
  *

from
  table(fml_dat_items_ftab(FML_DAT_ITEMS_OBJ('peter', 'zwan')
                          ,FML_DAT_ITEMS_OBJ('peter', 'zwan')
                          )
        )
;
F_NAME               L_NAME
-------------------- --------------------
peter                zwan
peter                zwan                 

create or replace
FUNCTION get_fml_items_dat (pfml_nr in number) return fml_dat_items_ftab pipelined as

--   out_rec FML_DAT_ITEMS_OBJ := FML_DAT_ITEMS_OBJ() ;
  out_rec FML_DAT_ITEMS_OBJ ;
begin
   select FML_DAT_ITEMS_OBJ('peter', 'zwan') into out_rec from dual;

  for i in 1 .. pfml_nr loop
    pipe row (out_rec);
  end loop;

end get_fml_items_dat;
/

select
  *
from
  table(get_fml_items_dat(2))
;

F_NAME               L_NAME
-------------------- --------------------
peter                zwan
peter                zwan                 

Hope this helps,

Kind regards

Peter

Tags: Database

Similar Questions

  • How can I call a function table in pipeline via DB link?

    I am using a function table in pipeline defined in a remote DB (DB_A) of my DB in local (DB_B) via a link DB (DB_A_REMOTE).

    The function table in pipeline is defined in a package with all the specifications of type he needs and works very well when she is called locally but when called it remotely fails

    Here is an example configuration in DB_A:
    connect scott/tiger
    create or replace
    package pkg as
      type rec is record (
        dte date
      );
      type rec_set is table of rec;
      
      function dts(p_eff_date date) return rec_set pipelined;
      function dt(p_eff_date date) return date;
    end;
    /
    create or replace
    PACKAGE BODY pkg AS
    
      function dts(p_eff_date date) return rec_set pipelined AS
        r rec;
      BEGIN
        r.dte := p_eff_date;
        pipe row(r);
        r.dte := r.dte+1;
        pipe row(r);
        RETURN;
      END dts;
    
      function dt(p_eff_date date) return date as
      begin
        return p_eff_date;
      end;
    
    END pkg;
    /
    In DB_B, I have the following configuration:
    create database link DB_A_REMOTE connect to Scott identified by tiger using 'DB_A';
    create or replace synonym RPKG for PKG@DB_A_REMOTE;
    In DB_A, I can access the two PKG functions very well
    SQL> select pkg.dt(sysdate) from dual
    DJ.DT(SYSDATE)       
    ----------------------
    21-SEP-2012 11:26:31   
    
    SQL> select * from table(pkg.dts(sysdate))
    DTE                  
    ----------------------
    21-SEP-2012 11:26:31   
    22-SEP-2012 11:26:31   
    23-SEP-2012 11:26:31   
    24-SEP-2012 11:26:31   
    However, in DB_B the I get the following:
    SQL> select rpkg.dt(sysdate) from dual
    RPKG.DT(SYSDATE)     
    ----------------------
    21-SEP-2012 11:29:05   
    
    SQL> select * from table(rpkg.dts(sysdate))
    
    Error starting at line 2 in command:
    select * from table(rpkg.dts(sysdate))
    Error at Command Line:2 Column:20
    Error report:
    SQL Error: ORA-06553: PLS-752: Table function DTS is in an inconsistent state.
    06553. 00000 -  "PLS-%s: %s"
    *Cause:    
    *Action:
    selection rpkg.dt shows I can get to the remote package and run functions in it, but the second line is where my problem.

    Why the function table in an inconsistent state and how can I fix this problem so that it will work in all of the linlk database?

    Published by: Sentinel on September 21, 2012 11:35

    Go! You have posted more than 1,000 times and know that you must provide your Oracle version 4-digit.
    >
    Why the function table in an inconsistent state and how can I fix this problem so that it will work in all of the linlk database?
    >
    You can't - it is not supported.

    See the note under the PIPELINED clause in the declaration section of the definition of the doc of PL/SQL and function
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/function.htm
    >
    Note:

    You cannot run a function table in pipeline over a database link. The reason is that the return type of a function table in pipeline is a SQL type defined by the user, which can be used in a single database (as explained in the Guide of the Oracle object-relational database developer). Although the return type of a function table in pipeline may appear as a PL/SQL type, the database actually converts this PL/SQL type to a type defined by the corresponding SQL user.
    >
    Your code using PL/SQL types for these types are implicitly converted to the SQL type needed to access the service using SQL. But the SQL types have an OID (object ID) which is not recognized on the other server so that the other server is unable to create the appropriate type.

    If you click on the link provided to the other doc in this note, you will see that even though you can create a type and specify an OID you still won't be able to use it as you wish.
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e11822/adobjbas.htm#ADOBJ7083
    >
    Restriction on the use of Types defined by the user with a remote database

    Objects or user-defined types (specifically, types declared with a SQL CREATE TYPE statement, as opposed to types declared in a PL/SQL package) are currently only useful in a single database. Oracle database limits the use of a link of database as follows:

    Unable to connect to a remote database for select, insert, or update a type defined by the user or a REF object on a remote table.

    You can use the CREATE TYPE statement with the Optional keyword OID to create an object identifier specified by the user (OID) that allows an object type for use in multiple databases. See the discussion on the attribution of an OID for a type of object in Oracle Database Data Cartridge Developer's Guide.

    You cannot use the links from the database of the PL/SQL code to declare a local variable of a type defined by the remote user.

    You cannot pass an argument value or return of type user defined in a PL/SQL remote procedure call.

  • Question of functions table

    Hello people,

    I just want to know why I can't use indexed tables in the table as return type functions. For example when I write "pls_integer index" at the end of the holder_t code, table function does not work. I would like to know why? What are the differences?

    create or replace
    package my_pack
    is
    type holder_t is table of Hello % rowtype;
    / * When I type this table like this, type holder_t is table of the Hello % rowtype index by pls_integer; table function does not work * /.
    type ref_cur_t is ref cursor
    Hello return % rowtype;
    end;

    create or replace
    function pipeline (SLEEP my_pack.ref_cur_t)
    parallel_enable my_pack.holder_t return pipeline (partition SLEEP by any)
    is
    my_row Hello % rowtype;
    holder hello_o: = hello_o (null, null);
    Start

    loop
    When the exit SLEEP % notfound;
    extract SLEEP them in my_row;
    Holder.a: = my_row.a;
    Holder.b: = my_row.b;
    course of action (my_row);
    end loop;
    Close SLEEP;

    return;

    end;



    Thank you.

    Polat says:
    OK, but what are the differences with the type holder_t is table of Hello % rowtype and type holder_t table with % rowtype index by pls_integer Hello? I mean both of them are table, but if I then use as return type it gives an error, I am trying to understand this?

    Difference is

    type holder_t is table of hello%rowtype index by pls_integer;
    

    Is an associative array. Similar to a hash table. This is only one type of PL/SQL, SQL cannot be used.

    This

    type holder_t is table of hello%rowtype;
    

    Is a nested table, similar to a set (or bag). This can be used in SQL, too.

    Looking at the docs for functions in pipeline, type that see you back:

    The data type of the value returned by a function table in pipeline must be a collection type defined at the schema or within a packet level (therefore, it cannot be a type of associative array).
    The elements of the collection type should be given SQL type, not data types supported only by the PL/SQL (for example PLS_INTEGER and BOOLEAN).

    Looking for all ther son you have on this topic, you should certainly read and try under rest three different collection types offered:
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/composites.htm#LNPLS00501

    Concerning
    Peter

  • function table in pipeline

    CREATE TABLE  TXN
    (
      SYS_ID       NUMBER,
      TXN_CODE  VARCHAR2(12),
       TXN_NO    NUMBER
    );
    
    SELECT SYS_ID,TXN_CODE, TXN_NO FROM TXN ORDER BY 1
    
    
    
    CREATE OR REPLACE TYPE TXN AS OBJECT 
    (
      SYS_ID     NUMBER(12),
      TXN_CODE   VARCHAR2(12),
      TXN_NO     NUMBER,
      
    )
    
    
    CREATE OR REPLACE TYPE TXN_DATA AS TABLE OF TXN
    
    
    
    CREATE OR REPLACE PACKAGE PKG 
    AS
       FUNCTION TXN(SYS_ID NUMBER) 
       RETURN TXN_DATA PIPELINED;
    END;
    
    
    CREATE OR REPLACE PACKAGE BODY  PKG AS 
    FUNCTION  TXN RETURN TXN_DATA PIPELINED IS
    BEGIN
      FOR I IN 1..NVL(SYS_ID,999999999)
        LOOP
          PIPE ROW(TXN(SYS_ID));
        END LOOP;
        RETURN;
       END;
    END;       
    
    
    I am getting the following errors while executing the package..
    
    PLS-00201: Indentifier SYS_ID must be declared
    PLS-00323: subprogram or cursor TXN is declared in a package specification and must be defined in the package body
    
    Kindly suggest the solution ?
    
    Sanjay 

    user12957777 wrote:
    I want to use the Pipelined function to write a single line instead of complex query query.

    Evil. This is done by using views. Tables not channelled burst.

    The latter is mainly used for the transformation of data. Unfortunately, it seems to serve often stupid hacks. Hacks which decrease only scalability performance and limits.

    Be very sure of the way in which a function table of pipeline works and what are its benefits, before using it.

  • Function table in pipeline and the key-preservation - (ORA-01779)

    Hey oraclers,

    If I had to use a function table in the pipeline to cover complex application logic, I rarely update a subset of...

    (simplified example)
    create type derived_t as object ( key integer, value varchar2(100) );
    create type derived_tc as table of result_t;
    
    create or replace function new_derivations( p_param varchar2 ) return derived_tc pipelined
    is
      l_derived derived_t;
    begin
     
      loop
        /* do stuff here */
        .....
        pipe row( l_derived );
      end loop;
    return;
    end;
    /
    
    create table derivations
    as 
    ( 
      key integer primary key,
      value varchar2(100)
    );
    
    
    insert into derivations select t.* from table( cast( new_derivations( 'test' ) as derived_tc ) ) t;
    But when I try...
    update ( 
       select d.rowid,
                d.key,
                d.value,
                t.value new_value
       from   derivations d,
                table( cast( new_derivations( 'test' ) as derived_tc ) ) t
       where d.key = t.key 
       and     d.key between :low_key and :high_key
    )
      set value = new_value;
    I get ORA-01779: cannot modify a column that is mapped to a table not preserved key...

    OK... so reading around us need to be able to tell Oracle that each row in the result set view is preserved key - the 'key' of derivations from the table column and the column "key" to the result of the function in the pipeline are unique (and compatible).

    Is it possible to hint Oracle (11.2.0.2.0 on Windows) to achieve this?

    Thanks muchly,.

    Lachlan Pitts

    You can rewrite this kind of update in a MERGE statement statement, which I think does not suffer the problem you are experiencing:

    merge into derivations d
    using (select t.key, t.value new_value from table( cast( new_derivations( 'test' ) as derived_tc ) ) t) s
    on (d.key = s.key and d.key between :low_key and :high_key)
    when matched then update set d.value = t.new_value
    

    (Not checked for syntax errors)

    You can also watch this:
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:760068400346785797

    Published by: Toon Koppelaars February 8, 2011 05:40

  • Question about functions in pipeline

    Version: Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production

    Hello

    I have a Pipelined function is used in a 4.1.1.00.23 APEX application. The function should return an array object to use in the WHERE clause of the query. So far, all of the values used in the function have been digital. Now, I have alphanumeric values and I get an error 'Character of digital Conversion'.

    A Pipelined can only use digital data?

    The function of reference is:

    FUNCTION to CREATE or REPLACE get_list (p_string in VARCHAR2
    , p_delimiter IN VARCHAR2 DEFAULT ':'
    )
    RETURN vc_array_1
    PIPELINED

    IS

    l_array wwv_flow_global.vc_arr2; -Creates a table type.

    BEGIN

    l_array: = APEX_UTIL.string_to_table (p_string, p_delimiter); -API to separate a delimited string colon by in a table.

    BECAUSE me IN l_array. FIRST... l_array. LAST
    LOOP
    LINE (TRIM (l_array (i)));
    END LOOP;

    RETURN;

    END;

    I thought that, given that the parameters are of type VARCHAR2 passing a valid value could be used. Apparently, I'm wrong?

    The WHERE clause that is used is in the format:

    ...

    WHERE < column_name > IN (SELECT * FROM TABLE (get_list (: P127_BASELINE_INIT_NAME)))

    ...

    If only the digital data can be used, how to use alpha-numeric values?

    Thank you

    Joe

    Stako, Anton and Jason thanks for your help!

    While I was waiting for my company to get the security put in place so that I could use sqlplus I was talking about this problem with another developer and it turns out that the function had NOTHING to do with this problem.

    It was all the me. The values passed into the function is from a Select list that allows multiple selectable values and this is whence the colon delimited string.

    IF no value is selected, it is a default value that can be used to not limit the number of rows in the WHERE clause. I used a 0 (zero) as a return value, so as the data type of the column is VARCHAR2 he compared a numeric character; where the error.

    The "bug" has been corrected and of course no error!

    Thank you all again!

    Thank you

    Joe

  • Question about function keys and cards Flash on my Satellite A210 - 10 c

    Hi people,

    I reinstall Vista without the recovery CD and now the FN keys work, but not all. That is, I can't lock the Touchpad and the FlashCards also didn't come down, if I press a FN key.
    The user darksys tell about it (http://forums.computers.toshiba-europe.com/forums/click.jspa?searchID=172641&messageID=100112) it is useful to install the Flash memory card Support utility that is not available on the European download Site. So I downloaded it from the Canadian Site, but during the Installation it tells me I have an invalid Nummber Serial? !!
    I have a satellite A-210-10 c (model Nummber: PSAEGE-xyz). So I think the installation tells me I have an invalid series because it's for another series of model.

    Its boring, the drafting of a text, and then suddenly the mouse jump lent else because I press the button by mistake...

    So I hope that someone could help.

    So long...

    Hello

    Check the support site of Toshiba Europe again to see if there is ever a version for VAP. I have a A200 and there was a problem with VAP installed in the recovery image.

    I deleted it from the system and installed the latest version of the Toshiba support page. Now, by pressing the key of KN, flash cards appear very fast and I can use al of them without any problem.

    Also check the touchpad settings. There must be also the option to disable touchpad.

  • Question about function

    Dear After Effects community, I'm doing something wrong. I started with the example of skeleton and changed to what I thought, I want it to do, however, it does not work. I changed the "MySimpleGainFunc8" and "MySimpleGainFunc16" to look like this:

    () MySimpleGainFunc16

    void * Conref.

    A_long xL,

    A_long yL,

    PF_Pixel16 * inP,

    PF_Pixel16 * output)

    {

    PF_Err err = PF_Err_NONE

    TempR PF_FpLong = 0;

    PF_FpLong tempG = 0;

    PF_FpLong TempB = 0;

    Output->alpha = inP->alpha;

    Output->Red ->Red + tempR inP = * 0.5;

    Output->Green = inP->Green + tempG * 0.5;

    Output->Blue = inP->Blue + tempB * 0.5;

    tempR = inP->Red + tempR * 0.5;

    tempG = inP->Green + tempG * 0.5;

    tempB = inP->Blue + tempB * 0.5;

    return err;

    }

    Now, what I want to do, it's for each image, the color of each pixel in the previous image should be averaged with the color of each respective pixel in the active frame. The function that I put in place now does not seem to work properly. When I apply the effect to a composition, nothing happens at all. Can someone please help me try to understand where I'm wrong. Thanks in advance!

    I find it difficult to follow what exactly is happening there, but it seems that you are a little confused as to how the functions are defined, and where should things go exactly.

    In your header file (formerly skeleton.h):

    -Set your RenderData structure:

    struct RenderData {}

    PF_EffectWorld * prev_frame_world;

    };

    (It is noted here that you can put what you want in this struct - everything you may need to access in your function iterate).

    In your main file (formerly skeleton.cpp):

    -Set your sampler of pixel outside any other function:

    Inline PF_Pixel * sampleIntegral32 (PF_EffectWorld & def, int x, int y) {}

    return ((char*) def.data (PF_Pixel *) + (y * def.rowbytes) + (x * sizeof (PF_Pixel)));

    }

    (Note that I used 'inline' rather than 'static' - this will give you a hint to the compiler to Inline the contents of the service where you call SampleIntegral32 directly, but you can use static, if you want. For some reason, you had declared it as static PF_Err, which returns a PF_Err, rather than the PF_Pixel *)

    -Your iterator or several functions:

    () MySimpleGainFunc8

    void * Conref.

    A_long xL,

    A_long yL,

    PF_Pixel8 * inP;

    PF_Pixel8 * output)

    {

    PF_Err err = PF_Err_NONE;

    RenderData * render_data = reinterpret_cast(prevframe);

    PF_Pixel * p_prev_frame = sampleIntegral32 (render_data-> prev_frame_world, xL, yL);

    Output-> alpha = (inP-> alpha) + p_prev_frame-> alpha * 0.5; I think that's what you wanted to do, no?

    etc...

    return err;

    }

    -Your function of rendering:

    PF_EffectWorld is exactly the same as PF_LayerDef. You withdraw your OK setting (even if the parameter ID "SKELETON_GAIN" is probably a cursor rather than the input layer. You can use 0 (zero) here, as the first parameter is always the PF_EffectWorld of entry, but read on, the first param is the enum SKELETON_INPUT, so we will use.

    PrevFrame PF_ParamDef = {};

    ERR (PF_CHECKOUT_PARAM (in_data,

    SKELETON_INPUT,

    in_data-> current_time - (1 * in_data-> time_step), / / I think it's a good...

    -> time_step in_data,

    in_data-> time_scale,

    & prevframe));

    When you go wrong here is that you are trying to make a PF_ParamDef to a PF_EffectWorld in your render data. You must point the layer data instead:

    RenderData render_data;

    render_data.prev_frame_world = & prevframe.u.ld;     Point your def of layer prev_frame_world pointer in the union

    ERR (suites. Iterate8Suite1()-> iterate (in_data,

    0, / / basic course

    output-> height, / / final course. Use linesL if you set as on the skeleton model

    & params [SKELETON_INPUT]-> u.ld, / / src

    NULL, / / area - null for all pixels

    (void *) & render_data, / / Conref - your custom data pointer

    MySimpleGainFunc8, / / function pixel pointer

    output));

    Check in this setting!

    Err2 (PF_CHECKIN_PARAM (in_data & prevframe));

    And it should work I think! It's not tested, but the basics are there.

  • question about function in one of the CC of economics programs

    At work, I use a PC and at home, I use an Imac. When I work on my PC, for example Illustrator and use the Save as function to keep the old file and create a new version with the last correction. As soon as I clicked on save as and name the new file that I find myself with the new file in the window of my illustrator. So that I can continue to work on the new file without overwriting the original. However on my Imac I always find myself with the original, and the new version is stored whenever I taped. Several times I clicked Save I think I work in a new file and then lost my original CD. How can I change the settings so that when I choose to save as the new file replaces the Moose and Moose is stored safely? I consulted a few other mac owners and none have the same setting. Anyone know if this is a setting that I can change?

    Thank you!

    Looks like you're confusing 'Save a Copy' and 'record under. At least on Mac 'Save a Copy' leave the original file open while 'record under"let the newly named file open.

  • Question about functionality

    One of my requirements is to create. PNG files with transparent backgrounds incorporating images imported with deleted circles usung the Tools eraser and brush. Is this possible using elements? If this is not the case, what product (s) of the suite, Adobe will provide this feature? Thanks in advance

    Yes it can. You use the "Save for Web" feature, select PNG (8 or 24 bit) and check the box 'transparency '. There are a variety of tools that can be used to remove the background, including a conveniently called "gum background."

    See you soon,.
    --
    Neale
    Insanity is hereditary, get you your children

    If this post or by post from another user solves the original problem, please mark as correct and/or useful messages accordingly. This helps other users with similar trouble getting answers to their questions more quickly. Thank you.

  • Question about 'functions of confidence. "

    Ref: "JavaScript for Acrobat QAnywhere," pp. 32-143-145.

    I need to let my JavaScript is running in a privileged context to allow this.mailForm (.) run without user intervention.  The reference above p. 144 tells me how to "mark a function as being approved." This is for me a script for a 'trustedNewDoc' function to put in a .js file that she "can be run of anywhere", but "cannot normally be executed by a mouse event."

    Please tell me How to attach this .js to my PDF file.

    (I know HTML, I can attach a file with the line .js):
    < script type = "text/javascript" src = "config.js" > < / script >
    "(but I don't know how to do it with a PDF document on my website)."

    It loads to the predetermined location when Acrobat/Reader is open. For more information, see: http://acrobatusers.com/tutorials/2006/folder_level_scripts/

  • Question about function. Pretty simple id assume

    Scene 1: Part 1, I have 2movie clips. Say MC1 and MC2.

    On the frame, I have the function:

    function my_func()

    {_root. MC2.nextFrame (); }

    then, inside MC1, I my_func();

    What is the problem, how to operate.

    inside MC1, you must use:

    _parent. My_Func();

  • question about functions on a calendar...

    Hi, if the following code is from the first image of a chronology:

    stage.addEventListener (MouseEvent.MOUSE_MOVE, message_follow);

    function message_follow(Event:MouseEvent):void {}

    follow_cursor_mc.x = 475;

    follow_cursor_mc.y = parent.ymouse + 80;

    updateAfterEvent();

    }

    This.following_cursor_mc. Visible = false;

    However, the clip "follow_cursor_mc" is only available in 10 to 20 frames... each of these frameworks has: a unique content, navigation between the other controls frames from 10 to 20, a "stop(); action and finally the code to make the visible follow_cursor_mc, "this.follow_cursor_mc.visible = true;"
    The thing is, the follow-up of the cursor should be visible on the images of 10 to 20.  But, where the follow_cursor_mc of film clip must be placed?  On the first frame of the movie - even if it's just remains invisible until the frames 10-20?
    Where should I put this follow_cursor_mc and the above code referring to it?
    If the clip in one of the frames to nine - albeit invisible - is not otherwise ineffective?  Not bad will load on the first image... could just start on frame 10, and cover all the way to 20... with the above code is placed on the framework one?
    If (listener and function) code is repeated on each picture between 10 and 20, duplicate error messages are thrown.
    I'm just not sure where to put this code and its music video accompanying it.
    Thank you...

    The object must exist when the code exists.  The object might have only one key image and expand some length of executives, rather than having several keyframes for that.  If you would like this invisible object in frames 1-9, then just set its visible property to zero for this range of cells.  Then set it to visible in frame 10 and assign it this code there as well.

  • question about function cont

    Hi all
    table rg_types / / DESC
    LIDER number (5),
    SERIAL_N number (8).
    CODE_T number (3)
    Number TYPE_I (1),
    SHIPMENT_NUM number 4
    No p.k on table or a unique index.
    TYPE_I can contain the values vary [0-5].
    for each leader can be sug_i [0-5].
    Select * from rg_type by SHIPMENR_NUM, TYPE_I, LIDER
    LIDER SERIAL_N CODE_T TYPE_I SHIPMENT_NUM
    11 956307 1 0 564
    11 956308 1 0 564
    11 956309 1 1 564
    400 956310 3 0 564
    500 956311 1 2 564
    600 956312 1 5 564
    600 956313 1 5 564
    200 956314 1 0 565
    400 956315 3 4 565
    700 956316 1 5 565
    .
    Note that not all of the lider appear in every shipment_num, every doe'nt lider must also has all the type_i all shipment_num (could be, but need not be)
    I need to run a query that will show all the lider how
    many types of each type (0-5)
    spomething like that
    TYPE_I
    0 1 2 4 5 LIDER
    ___________________________________________________________
    11-2-1
    1 200
    400 1 1
    1 500
    2 600
    1 700
    Help, please
    Thanks in advance
    Naama

    Lack of expression is the expression of the column before you leave (sorry, my mistake) finished with a comma

    select lider,
           max(decode(type_i,0,the_count)) count_0,
           max(decode(type_i,1,the_count)) count_1,
           max(decode(type_i,2,the_count)) count_2,
           max(decode(type_i,3,the_count)) count_3,
           max(decode(type_i,4,the_count)) count_4,
           max(decode(type_i,5,the_count)) count_5  /* a comma was left here by mistake */
      from (select lider,type_i,count(*) the_count
              from rg_type
             group by lider,type_i
           )
     group by lider
     order by lider
    

    the subselect Gets the counties you are looking for and your problem could be solved already
    but
    you want to type_i County of each leader appear as a column line that lider (bringing rows of columns is called pivoting)
    to get there you first

    select lider,
           decode(type_i,0,the_count) count_0,
           decode(type_i,1,the_count) count_1,
           decode(type_i,2,the_count) count_2,
           decode(type_i,3,the_count) count_3,
           decode(type_i,4,the_count) count_4,
           decode(type_i,5,the_count) count_5
      from (select lider,type_i,count(*) the_count
              from rg_type
             group by lider,type_i
           )
     order by lider
    

    and then use max to get rid of all these null values getting a single line for each value of lider

    Concerning

    Etbin

    p.s. I have not access database error of free detailed examples

  • Function table in oracle

    Hi all

    I am using Oracle 11g

    I want to know in order to learn

    What is the CURSOR in the function table.

    What is its usefulness

    Can someone explain to me.

    SELECT x.*

    (TABLE (package1.function1)

    CURSOR (SELECT

    t.*

    OF test1 t))) x

    Thank you

    What is the CURSOR in the function table.

    What is its usefulness

    Can someone explain to me.

    SELECT x.*

    (TABLE (package1.function1)

    CURSOR (SELECT

    t.*

    OF test1 t))) x

    This slider is NOT 'in the function table. It is in the call to YOUR function named "packagae1.function1" and the function returns a collection. If it is the result of the collection of YOUR function call which is 'in the function table.

    Your probable function takes a REF CURSOR as a parameter, so the code above uses the CURSOR operator to create a cursor from a subquery.

    Your function then returns a collection and SCOREBOARD operator is used to make this collection available in SQL.

    See FUNCTIONS TABLE in the Oracle documentation. A simple search for 'oracle 11g table function' returns the Oracle doc as the FIRST result listed:

    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28425/pipe_paral_tbl.htm

    This chapter describes the functions of table

    . . .

    Overview of the functions of table

    Table functions are producing a set of lines (a nested table or a varray) that can be queried as a physical database table. You use a function table as the name of a database table, in the FROM clause of a query.

    A table function can take a set of input lines. A parameter of the input collection can be of a collection type or a REF CURSOR .

    . . .

    Look at the examples 5-13 and 13-6, because they show the code for your EXACT example:

    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28425/pipe_paral_tbl.htm#CIHEGADE

    . . .

    Example 13-6 How to use a function Table in pipeline with REF CURSOR Arguments

    SELECT * FROM TABLE(StockPivot(CURSOR(SELECT * FROM StockTable)));
    

    In the previous query, the function table in pipeline StockPivot retrieves the lines of the CURSOR subquery SELECT * FROM StockTable , performs the transformation and channels the results to the user in the form of table. The function produces two lines of output for each input line (items in the collection).

    Note that when a CURSOR subquery went from SQL for a REF CURSOR argument of function as in the previous example, the referenced cursor is already open when the function begins to run.

    As the doc example, as in your example, a subquery of CURSOR to create a cursor to be used as a function parameter. Example 13 - 5 has the actual code for the function.

    The documentation is your FRY - don't be afraid to use it.

    If you try to learn something a good question to ask on the forums is: where can I get more information about the functions of the table (or other topic).

    Then, we can direct you to the Oracle documentation that covers this topic.

Maybe you are looking for