Function to get Table indices

Dear all,
i'm looking for a function modul to get indices of individuell table.
I could'nt dfinde any one!
best regards

you get the following tables in the FM.. right?
DBINDEXES
DBINDFLDS
in this DBINDEXES you have 1 field for index another for unique.. for primary key it would be 'X'.
or any ways the index <tab_name>~0 means primary key( ~0).
after getting this...
you delete the lines for <tab_name>~0 from DBINDFLDS and rest are your secondary keys

Similar Messages

  • Function module get tables from view

    Hello,
    I am looking for a function module or something alike where I can find the tables used in a specific view.
    I know how to get the data from the view, but I only want the table names.
    Can anyone help?

    Hi,
    Please try with the Function Module "VIEW_GET_TABLES" by passing the name of the View to the Importing Paramater "VIEWNAME" and tables parameter "VIEW_TABLES" will list the tables used in the VIEW.
    Regards,
    Srinivas

  • CE function to get distinct values from Column table

    Hi All,
    Could you please let me know the appropriate CE function to get the distinct values from column table.
    IT_WORK = SELECT DISTINCT AUFNR FROM :IT_WO_DETAILS;
    Thank you.

    Hi,
    If you have 10g, you can use Model( with model performance is better than connect by )
    Solution
    ========================================================================
    WITH t AS
    (SELECT '0989.726332, 1234.567432, 3453.736379, 3453.736379, 0989.726332, 3453.736379, 1234.567432, 1234.567432, 0989.726332'
    txt
    FROM DUAL)
    SELECT DISTINCT TRIM(CHAINE)
    FROM T
    MODEL
    RETURN UPDATED ROWS
    DIMENSION BY (0 POSITION)
    MEASURES (CAST( ' ' AS VARCHAR2(50)) AS CHAINE ,txt ,LENGTH(REGEXP_REPLACE(txt,'[^,]+',''))+1 NB_MOT)
    RULES
    (CHAINE[FOR POSITION FROM  1 TO NVL(NB_MOT[0],1) INCREMENT 1] =
    CASE WHEN NB_MOT[0] IS NULL THEN TXT[0] ELSE REGEXP_SUBSTR(txt[0],'[^,]+',1,CV(POSITION)) END );
    =========================================================================
    Demo
    =======================================================================
    SQL> WITH t AS
    2 (SELECT '0989.726332, 1234.567432, 3453.736379, 3453.736379, 0989.726332, 3453.736379, 123
    4.567432, 1234.567432, 0989.726332'
    3 txt
    4 FROM DUAL)
    5 SELECT DISTINCT TRIM(CHAINE)
    6 FROM T
    7 MODEL
    8 RETURN UPDATED ROWS
    9 DIMENSION BY (0 POSITION)
    10 MEASURES (CAST( ' ' AS VARCHAR2(50)) AS CHAINE ,txt ,LENGTH(REGEXP_REPLACE(txt,'[^,]+',''))+1 NB_MOT)
    11 RULES
    12 (CHAINE[FOR POSITION FROM  1 TO NVL(NB_MOT[0],1) INCREMENT 1] =
    13 CASE WHEN NB_MOT[0] IS NULL THEN TXT[0] ELSE REGEXP_SUBSTR(txt[0],'[^,]+',1,CV(POSITION)) END );
    TRIM(CHAINE)
    3453.736379
    1234.567432
    0989.726332
    SQL>
    ========================================================================

  • Function module to get table description

    Is there any function module to get table description on passing table name

    Hi,
    We need to use : 'G_RW_TABLE_DESCRIPTION_GET' function module.
    we pass the table name and the language.
    call function 'G_RW_TABLE_DESCRIPTION_GET'
        exporting
          rw_table = p_table
          langu    = sy-langu
        importing
          tab_text = l_tabtext
        exceptions
          others   = 1.
    thanx.

  • Update partner function in KNVP table using FM sd_customer-maintain_all

    Hi All,
    I have to update Partner Function ‘PARVW’  in KNVP table using FM sd_customer_maintain_all.
    I had already created a BDC program for updating which is running successfully.
    But  my requirement is to create a BAPI using FM customermaintain_all.
    Ex:  Tcode VD02
              KUNNR          PARVW             KUNN2
    Old data      123          Z1          70006666
              123          Z2          70007777
    Req. output      123          Z1          70006666
              123          Z1          70007777
    PARVW ‘Z2’  should not exist after updation.
    When updating, I am getting the error message to my inbox as
    “ Error Info...   F2 802: System error in table KNVP ”
    The above error is triggered while committing work after execution of  ‘SD_CUSTOMER_MAINTAIN_ALL’.
    The options I tried while looping at internal table containing kunnr, parvw & kunn2
    CALL FUNCTION 'SD_CUSTOMER_MAINTAIN_ALL'
    EXPORTING
        I_KNA1                              = w_kna1
      I_KNB1                              =
        I_KNVV                              = w_knvv
      I_BAPIADDR1                         =
      I_BAPIADDR2                         =
      I_MAINTAIN_ADDRESS_BY_KNA1          = ' '
      I_KNB1_REFERENCE                    = ' '
      I_FORCE_EXTERNAL_NUMBER_RANGE       = ' '
      I_NO_BANK_MASTER_UPDATE             = ' '
      I_CUSTOMER_IS_CONSUMER              = ' '
      I_RAISE_NO_BTE                      = ' '
        PI_POSTFLAG                         = 'X'
      PI_CAM_CHANGED                      = ' '
      PI_ADD_ON_DATA                      =
      I_FROM_CUSTOMERMASTER               = ' '
    IMPORTING
      E_KUNNR                             =
      O_KNA1                              =
      E_SD_CUST_1321_DONE                 =
    TABLES
      T_XKNAS                             =
      T_XKNBK                             =
      T_XKNB5                             =
      T_XKNEX                             =
      T_XKNVA                             =
      T_XKNVD                             =
      T_XKNVI                             =
      T_XKNVK                             =
      T_XKNVL                             =
        T_XKNVP                             = I_XKNVP
      T_XKNZA                             =
      T_YKNAS                             =
      T_YKNBK                             =
      T_YKNB5                             =
      T_YKNEX                             =
      T_YKNVA                             =
      T_YKNVD                             =
      T_YKNVI                             =
      T_YKNVK                             =
      T_YKNVL                             =
        T_YKNVP                             = i_yknvp ***
      T_YKNZA                             =
      T_UPD_TXT                           =
    EXCEPTIONS
        CLIENT_ERROR                        = 1
      KNA1_INCOMPLETE                     = 2
      KNB1_INCOMPLETE                     = 3
      KNB5_INCOMPLETE                     = 4
      KNVV_INCOMPLETE                     = 5
      KUNNR_NOT_UNIQUE                    = 6
      SALES_AREA_NOT_UNIQUE               = 7
      SALES_AREA_NOT_VALID                = 8
      INSERT_UPDATE_CONFLICT              = 9
      NUMBER_ASSIGNMENT_ERROR             = 10
      NUMBER_NOT_IN_RANGE                 = 11
      NUMBER_RANGE_NOT_EXTERN             = 12
      NUMBER_RANGE_NOT_INTERN             = 13
      ACCOUNT_GROUP_NOT_VALID             = 14
      PARNR_INVALID                       = 15
      BANK_ADDRESS_INVALID                = 16
      TAX_DATA_NOT_VALID                  = 17
      NO_AUTHORITY                        = 18
      COMPANY_CODE_NOT_UNIQUE             = 19
      DUNNING_DATA_NOT_VALID              = 20
      KNB1_REFERENCE_INVALID              = 21
      CAM_ERROR                           = 22
        OTHERS                              = 23.
    IF sy-subrc eq ‘0’.
    Commit work and wait.
    Endif.
    All above tables have a field called ‘KZ’ which has options
    U-update
    D-delete
    I-insert
    E-………(I don’t know)
    Ex: T_XKNVP structure = KNVP Structure + Field ‘KZ’.
    Documentation for this FM is not Available in English or German
    1.  I tried sending Z2  KZ as ‘D’ first &  Z1 with KZ as ‘I’ with business partner of Z2 (KUNN2)
         as single update.
    Ex: T_XKNP table
    KUNNR          PARVW             KUNN2          KZ
    123          Z2          70007777     D
    123          Z1          70007777     I
    2.  I tried it as a separate delete record and insert record i.e calling the FM twice .
    3.  I tried passing table  T_YKNVP with old partner data + TXKNVP table new partner data
    Ex: T_YKNP table
    KUNNR          PARVW             KUNN2          KZ
    123          Z2          70007777     U or space (I tried both one after another)
    4. All combinations for field ‘KZ’  are tried.
    Please help me to overcome this problem.
    I )   I need which parameters are to be passed to FM for updating partner function in KNVP table .
    II)   Do I need to pass structure I_KNA1 or I_KNVV to FM ? (Blank or with values corresponding to   
         partner function ).
    III)  Any sample code which can guide me.
    Even a small hint or clue from you will certainly help me.
    Thanks in Advance.
    AJAX

    i have the same problem. I need to update the partner function PARVW thru a program that i created. I tried to use this FM but it didn't work. Anyone knows another FM that i can use to update the KNVP table?

  • Server side function not get called after dispatching cairngorm event second time on same page

    Hi All,
    I am facing a urgent issue regarding cairngorm event. Actually my page contain 3 button add,delete,save
    and  clicking of any button I do the respected functionality. For ex:
    I click the add button & on clicking of add button I fire a cairngorm evnt & after getting response from server side that the record is added
    I displayed a message that the record is added & update the data source.
    After addition of the record , with out going to other page if I perform the same functionaly(Like adding another record) on same page the cairngorm
    event not call the server side function  -  after debugging I find out that cairngorm event  reach to the corresponding excutecommand function & called that function  but it is not calling my server side function & I also din't get any error message .
    I dont know why  the server side function not get called?. similarly if I try for delete or update case the same things happend. Only for the first time it works properly but not for the second  time.
    Could any of  you please tell me why the cairngorm event not calling the server side function.
    Thank you for your kind assistance.
    Regards,
    Ujjwal

    Okay, well I think I've worked out the problem.
    In ASP.NET we would typically bind repeating controls such as DataLists and Repeaters manually using <i>Control</i>.DataBind(), because we're usually using a separate class library containing collections for our objects. Seems the SAP Table control doesn't like this approach.
    I changed the code so that the databinding is specified on the control, and call the Page's DataBind() method and it all worked fine.
    One tip: because the collection I used to bind to is in a separate class library, I receieved a <i>BC306523: Reference required to assembly MyAssemblyName...</i> message, even though I had a reference to the assembly in my project and the DLL is being properly deployed. To fix this, you must include the following directive at the top of the component's ASCX file:
    <%@ Assembly Name="AssemblyName" %>

  • Use SQL function to get the original order number using the invoice number

    Hi All,
    wondering is someone can help me with this challenge I am having?  Often I need to return the original order numbers that created the resulting invoce.  This is a relatively simple seriese of joins in a query but I am wanting to simplify it using a SQL function that can be referenced each time easily from with in the SELECT statement.  the code i currently have is:
    Use SQL function to get the original order number using the invoice number
    CREATE FUNCTION dbo.fnOrdersThatMakeInvoice(@InvNum int)
    RETURNS nvarchar(200)
    AS
    BEGIN
    DECLARE @OrderList nvarchar(200)
    SET @OrderList = ''
    SELECT @OrderList = @OrderList + (cast(T6.DocNum AS nvarchar(10)) + ' ')
    FROM  OINV AS T1 INNER JOIN
          INV1 AS T2 ON T1.DocEntry = T2.DocEntry INNER JOIN
          DLN1 AS T4 ON T2.BaseEntry = T4.DocEntry AND T2.BaseLine = T4.LineNum INNER JOIN
          RDR1 AS T5 ON T4.BaseEntry = T5.DocEntry AND T4.BaseLine = T5.LineNum INNER JOIN
          ORDR AS T6 ON T5.DocEntry = T6.DocEntry
    WHERE T1.DocNum = @InvNum
    RETURN @OrderList 
    END
    it is run by the following query:
    Select T1.DocNum, dbo.fnOrdersThatMakeInvoice(T1.DocNum)
    From OINV T1
    Where T1.DocNum = 'your invoice number here'
    The issue is that this returns the order number for all of the lines in the invoice.  Only want to see the summary of the order numbers.  ie if 3 orders were used to make a 20 line inovice I only want to see the 3 order numbers retuned in the field.
    If this was a simple reporting SELECT query I would use SELECT DISTINCT.  But I can't do that.
    Any ideas?
    Thanks,
    Mike

    Thanks Gordon,
    I am trying to get away from the massive table access list everytime I write a query where I need to access the original order number of the invoice.  However, I have managed to solve my own problem with a GROUP BY statement!
    Others may be interested so, the code is this:
    CREATE FUNCTION dbo.fnOrdersThatMakeInvoice(@InvNum int)
    RETURNS nvarchar(200)
    AS
    BEGIN
    DECLARE @OrderList nvarchar(200)
    SET @OrderList = ''
    SELECT @OrderList = @OrderList + (cast(T6.DocNum AS nvarchar(10)) + ' ')
    FROM  OINV AS T1 INNER JOIN
          INV1 AS T2 ON T1.DocEntry = T2.DocEntry INNER JOIN
          DLN1 AS T4 ON T2.BaseEntry = T4.DocEntry AND T2.BaseLine = T4.LineNum INNER JOIN
          RDR1 AS T5 ON T4.BaseEntry = T5.DocEntry AND T4.BaseLine = T5.LineNum INNER JOIN
          ORDR AS T6 ON T5.DocEntry = T6.DocEntry
    WHERE T1.DocNum = @InvNum
    GROUP BY T6.DocNum
    RETURN @OrderList 
    END
    and to call it use this:
    Select T1.DocNum, dbo.fnOrdersThatMakeInvoice(T1.DocNum)
    From OINV T1
    Where T1.DocNum = 'your invoice number'

  • Calling functions and inserting tables based on values entered

    Hello Everyone,
    I am creating a function as below:
    create or replace function func(flags in number,Ctry in varchar2) return number
    is
    maxv number;
    flagv number;
    begin
    flagv:=1;
    select max(num) into maxv from A;
    if flags =1 then
    insert into A(num,nam) values(maxv+1,Upper(Ctry));
    else
    flagv:=0;
    end if;
    return flagv;
    end;
    The function takes two parameters-The first one will be either 0 or 1.The second one will be name of a country.
    If the first parameter is 1 then we would insert the country name passed, to the table name A.If its 0 then no insertion occurs and the function would return a value 0.
    On compiling the function I get a success!.
    When I do a
    SQL>select distinct func(0,'UK') from B;
    it works well and returns 0
    However when I do
    SQL>select distinct func(1,'UK') from B;
    I expect an output of 1 & also expect UK to be inserted as anew row in the table A.However It throws an error saying "ORA-14551: cannot perform a DML operation inside a query .."
    It is very important for me to use select to call the function, as my application would fire a select with that function and based on the value entered would insert or not insert at the back end.
    Is there any way out to do this??
    variable temps number
    exec :number :=func(1,'UK');
    does work but I cant use this in my application.
    Hope you can help! Thanks!

    create or replace function func(flags in number,Ctry in varchar2) return number
    is
    PRAGMA AUTONOMOUS_TRANSACTION;
    maxv number;
    flagv number;
    begin
    flagv:=1;
    select max(num) into maxv from A;
    if flags =1 then
    insert into A(num,nam) values(maxv+1,Upper(Ctry));
    COMMIT;
    else
    flagv:=0;
    end if;
    return flagv;
    end;
    Is the above changes in BOLD enough or I need to do something else too in order to incorporate the autonomous transaction??
    I am not too familiar with autonomous transaction.Could you please suggest the changes I need if any more required??
    Thanks a ton for your suggestions!
    Message was edited by:
    user579245
    Message was edited by:
    user579245

  • RFC function : passing a table as input

    Hi,
    I have no trouble passing input values to an RFC model in web dynpro, but I have difficulties to pass an input table.
    By default, the input "it_table" node of the model I use, is defined like this : card 0..n, selec 0..1 Singleton True.
    Do I have to change something?
    Then, what is the correct code for creating the node (because card is 0..n) and then add items (for each line of my table)?
    For the moment, I get this error : value node is created without a reference.
    Thanks

    I finally managed to get it work.
    Here is the COMPLETE solution.
    Note that in my solution, it was easier for me to put data in a value Node FIRST and THEN to copy it to the model Node.
    --> In the RFC function, declare the table "TYPE TLINE_T", and not "LIKE TLINE".
    GestionAvisComp - Context
    - Z2_I_Gestion_Simplifiee_Avis_Input (Model Node, card 0..1, sel 0..1, singleton true)
             + It_Ajout_Texte_Avis (card 0..n, sel 0..1, singleton true) Class Tline
                - Tdformat
                - Tdline
             - Qmart
    - It_Texte_Avis (Value node, card 0..n, sel 0..1, singleton true)
      public void wdDoInit()
        //@@begin wdDoInit()
         //$$begin Service Controller(1353609186)
         Z2_I_Gestion_Simplifiee_Avis_Input input = new Z2_I_Gestion_Simplifiee_Avis_Input();
         wdContext.nodeZ2_I_Gestion_Simplifiee_Avis_Input().bind(input);
         //$$end
        //@@end
    WhateverView
    public void onActionSauvegarderAvis(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
         // Add two elements to the value node
         IIt_Texte_Avis_InputElement firstTexte_AvisEl = wdContext.nodeIt_Texte_Avis_Input().createIt_Texte_Avis_InputElement();
         IIt_Texte_Avis_InputElement secondTexte_AvisEl = wdContext.nodeIt_Texte_Avis_Input().createIt_Texte_Avis_InputElement();
         firstTexte_AvisEl.setTdformat("/*");
         firstTexte_AvisEl.setTdline("Line 1");
         secondTexte_AvisEl.setTdformat("/*");
         secondTexte_AvisEl.setTdline("Line 2");
         wdContext.nodeIt_Texte_Avis_Input().addElement(firstTexte_AvisEl);
         wdContext.nodeIt_Texte_Avis_Input().addElement(secondTexte_AvisEl);
         // Moving the elements of the value node into the model node
         int size = wdContext.nodeIt_Texte_Avis_Input().size();
         for (int i = 0; i < size; i++) {
              wdContext.nodeIt_Texte_Avis_Input().setLeadSelection(i);
              Tline x = new Tline();
              x.setTdformat(wdContext.currentIt_Texte_Avis_InputElement().getTdformat());
              x.setTdline(wdContext.currentIt_Texte_Avis_InputElement().getTdline());
              wdContext.currentZ2_I_Gestion_Simplifiee_Avis_InputElement().modelObject().addIt_Ajout_Texte_Avis(x);
         wdContext.currentZ2_I_Gestion_Simplifiee_Avis_InputElement().setQmart("ZE");
         // Execute the RFC model
         // Clear the Value Node
         while ( wdContext.nodeIt_Texte_Avis_Input().size() > 0 )
                   wdContext.nodeIt_Texte_Avis_Input().removeElement(
                        wdContext.nodeIt_Texte_Avis_Input().getElementAt(0)
         // Clear the Model Node          
              if (wdContext.currentZ2_I_Gestion_Simplifiee_Avis_InputElement().modelObject().getIt_Ajout_Texte_Avis() != null) {
              while(wdContext.currentZ2_I_Gestion_Simplifiee_Avis_InputElement().modelObject().getIt_Ajout_Texte_Avis().size() > 0)
                   wdContext.currentZ2_I_Gestion_Simplifiee_Avis_InputElement().modelObject().getIt_Ajout_Texte_Avis().remove(0)
    Edited by: Emanuel Champagne on Jan 17, 2008 9:32 PM
    Edited by: Emanuel Champagne on Jan 18, 2008 10:20 PM

  • Reg: Functions of Planning Table MF50

    Hi Friend,
    i wish you all a happy Friendship day...
    I need to know the following Function in REM,
    1. Functions of Planning table.(MF50)
    2.When we carry out Backflush , Components , activities get Posted. where can i find the reports for activities and components posted.
    3. Preliminary Costing Values.
    Thanks in advance.

    Hi dayanan,
    1. Planning table MF50 is used to create a manual planned order respective date wise inspite of creating in MD11 one by one.
    2. When you assembly backflush in MFBF your component consumption and Activities will get posted automatically GI, GR & Activities will be posted. This component consumption you can see through movement type 261 in MB51. Cost of that consumption and activities you can monitor in Product cost collector. PPC. for that go to KKF6N-select version- Header---- costs.... There you can refer the updated cost of consumption and MHR.
    3. If you to consume additional component without GR that means only GI, goto MFBF and select component backflush and enter the component which you want to consume.
    Hope this will clear all your doubts.
    Regards,
    Santhosh.

  • How to get table data column by column dynamically

    Hi ,
    first of all
    i have something like this
    cursor sys_cursor is
    select * from sys.all_objects;
    v_data varchar2(200);
    fetch sys_cursor
    into v_owner, v_object_name, v_subobject_name, v_object_id, v_data_object_id, v_object_type, v_created, v_last_ddl_time, v_time_stamp, v_status, v_temporary, v_generated, v_secondary;
    v_data := v_owner || ' ' || v_object_name || ' ' || v_subobject_name || ' ' ||
    v_object_id || ' ' || v_data_object_id || ' ' ||
    v_object_type || ' ' || v_created || ' ' || v_last_ddl_time || ' ' ||
    v_time_stamp || ' ' || v_status || ' ' || v_temporary || ' ' ||
    v_generated || ' ' || v_secondary;
    encrypt(v_data);
    it is ok for "sys.all_objects" but i need to modify this for all tables
    so , i need to know column names of table and type of it and value of it
    then i need to get column values by one by and encrypt it.
    i used dbms_sql and succeed to find column name and type
    however , i couldnt get the values.i can't use dbms_sql.column_values because i find column type dynamically.
    what can i do?
    how can i get table data by row
    and then for each row , i need to get values of columns by one by and encrypt those values.
    any idea is appriciated.
    thanks
    Aykut

    Dynamic SQL is the solution. Right from getting the column names, their data types to passing the string to encrypt function that you have.
    You will need to handle datatypes like LONG, LOB etc... as they cannot be concatenated with strings.
    Also, you need to manage dates and numbers.
    Obviously this would be very complicated code.
    Even if you decide to code the procedure to encrypt tables one by one, still you need to make this procedure dynamic to handle above situations.

  • Function not returning table object correctly

    Instead of returning a table, my function is returning this:
    SCHEMA_OWNER.TBL_SUMS([SCHEMA_OWNER.SUMS_OBJ])
    Does anyone see a syntax error in my function or the ddl of my table and object types?
    This is a stripped down, simplified version of my function:
    create or replace FUNCTION "F_TEST" (p_skey number, p_start_date date, p_end_date date)
    RETURN tbl_sums
    IS
    tmp_A NUMBER;
    tmp_B NUMBER;
    l_tbl tbl_sums := tbl_sums();
    BEGIN
    SELECT SUM(FieldA), SUM(FieldB)
    into tmpA, tmpB
    from myTable where SKEY = p_skey
    and DATE_VALUE >= p_start_date
    and DATE_VALUE < p_end_date;
    l_tbl.extend;
    l_tbl(l_tbl.count()) := sums_obj(p_start_date, p_end_date, p_skey, tmpA, tmpB);
    return l_tbl;
    END;
    My types are:
    create or replace type sums_obj is object (start_date DATE, end_date DATE, skey NUMBER, SumA NUMBER, SumB NUMBER);
    create or replace type tbl_sums is table of sums_obj;
    Thanks!

    >
    RETURN tbl_kpi
    >
    What is 'tbl_kpi'? That isn't defined anywhere. Your original post said this:
    >
    RETURN tbl_sums
    >
    We can't help you if you don't post what you are really using. Cut & Paste is ok but you have to paste the correct code.
    Your funtion is returning a TABLE but it is NOT PIPELINED. So if you query the function from DUAL you will get a DATASET as the result.
    If you query the function AS A TABLE you will get the 'contents' of the table.
    If you make your function a PIPELINED function then you use PIPE ROW to return each row but the function is still declared to return a TABLE. Maybe that is what is confusing you.
    Try the following sample code to see what the difference is.
    Here are two SQL types based on the EMP table in the scott schema.
    -- type to match emp record
    create or replace type emp_scalar_type as object
      (EMPNO NUMBER(4) ,
       ENAME VARCHAR2(10),
       JOB VARCHAR2(9),
       MGR NUMBER(4),
       HIREDATE DATE,
       SAL NUMBER(7, 2),
       COMM NUMBER(7, 2),
       DEPTNO NUMBER(2)
    -- table of emp records
    create or replace type emp_table_type as table of emp_scalar_type
    /Now - here is a function (similar to yours) that returns that EMP_TABLE_TYPE. NOTE: the function IS NOT PIPELINED
    CREATE OR REPLACE function SCOTT.get_emp1( p_deptno in number )
      return emp_table_type
      as
    tb emp_table_type;
    BEGIN
      select emp_scalar_type(empno, ename, job, mgr, hiredate, sal, comm, deptno)
        bulk collect into tb from emp where deptno = p_deptno;
      return tb;
    end;
    /If I just select the function itself from DUAL I get this:
    select get_emp1(20) from dual
    GET_EMP1(20)
    (DATASET)I can use TOAD or sql developer to examine that dataset and see the records.
    But I can actually query the records by using the TABLE function:
    select * from table(get_emp1(20))
    EMPNO     ENAME     JOB     MGR     HIREDATE     SAL     COMM     DEPTNO
    7369     SMITH     CLERK     7902     12/17/1980     800          20
    7566     JONES     MANAGER     7839     4/2/1981     2975          20
    7788     SCOTT     ANALYST     7566     4/19/1987     3000          20
    7876     ADAMS     CLERK     7788     5/23/1987     1100          20
    7902     FORD     ANALYST     7566     12/3/1981     3000          20This is a similar function. It returns the same EMP_TABLE_TYPE but it is a PIPELINED function.
    -- pipelined function
    create or replace function get_emp( p_deptno in number )
      return emp_table_type
      PIPELINED
      as
       TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
        emp_cv EmpCurTyp;
        l_rec  emp%rowtype;
      begin
        open emp_cv for select * from emp where deptno = p_deptno;
        loop
          fetch emp_cv into l_rec;
          exit when (emp_cv%notfound);
          pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
              l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
        end loop;
        return;
      end;
      /The ONLY way I can query this function is by using the TABLE function:
    select * from table(get_emp(20))
    EMPNO     ENAME     JOB     MGR     HIREDATE     SAL     COMM     DEPTNO
    7369     smith     CLERK     7902     12/17/1980     800          20
    7566     jones     MANAGER     7839     4/2/1981     2975          20
    7788     scott     ANALYST     7566     4/19/1987     3000          20
    7876     adams     CLERK     7788     5/23/1987     1100          20
    7902     ford     ANALYST     7566     12/3/1981     3000          20The query of the PIPELINED function is the same and the result set is the same.
    The difference is that the PIPELINED function returns ONE ROW at a time and does NOT need to accumulate a lot of data in a collection before returning it. That collection uses expensive PGA memory and the more data you have the more memory it uses.
    Your function (and my similar one) doesn't return ANY data until it has produced ALL of it. And it uses that expensive PGA memory. What is the point of creating your collection one row at a time and waiting until you have it all before you return it?
    You could easily modify your function and add PIPELINED to the declaration. Then use the PIPE ROW clause to return each row as it is produced. That will eliminate the need for the collection (and memory) within the function.
    You can also then chain the function calls together if you need to.
    See 'Using Pipelined and Parallel Table Functions' in the Data Cartridge Developer's Guide
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28425/pipe_paral_tbl.htm
    There is little use for your function that is not pipelined but returns a table type unless you were storing that table-type in an object column of a table.
    There are many uses for PIPELINED functions.

  • Function module in table TADIR

    Hi,
    Table TADIR is a repository for all objects. However if I try to locate any function module(Object type = FUNC) in this table I dont get any entries. Why does this happen? Is there any other table which keeps a list of all function modules?
    Thanks,
    Saurabh

    hi,
    check this table TFDIR...
    <b>ENLFDIR</b> Additional Attributes for Function Modules -- this table contains FUNCTIONAL GROUP OF the particular function module..and other details
    <b>reward points if it is useful..</b>

  • Functional Modular or table name to component for a material

    Hi,
    Please help me for finding Functional Modular or table name to get all component (Alternative BOM also) for a particular material.
    thanks

    Hi sahoo
    try this CUBM_MATERIAL_BOM_READ
    or look for other FM on se37 with bomread*
    Regards
    Marco

  • Using power shell function and SQL Table

    I have a table holding file path of over 1 million documents. so like column one is documentID and column two is full file path.
    Now, I want to get the file size of each of the documents. I have a function in power shell that gets the size of a file given file path.
    My problem, is I do not know how to use that function and the table to get the size of each of the files(documents).
    Help Much Appreciated!!
    ebro

    I am not clear with your questions sir. Do you mean the category this question belongs too? If so, may be some body could help redirect the question to the appropriate place.
    So what category does this belong too CM12 or Powershell?
    http://www.enhansoft.com/

Maybe you are looking for