How to pipeline a function with a dynamic number of columns?

Hi everyone,
I'm trying to figure out how to write a piplined function that generates a dynamic SQL statement from its inputs, executes the query, and returns the results of the query in the pipeline. The number and names of the columns in the dynamic query is unknown number until the function is invoked.
I suspect that DBMS_SQL is involved, but can't quite figure out how to construct a row using it that I can use PIPE ROW on. I also can't figure out what data type the function should return (ANYDATASET?)
pseudo-PLSQL follows:
create function myfunction ( param1 varchar2)
return anydataset pipelined
as
query_string := <... do stuff with param1 ...>
< -- >
open a cursor for query_string
determine the number of columns
read a row
PIPE ROW it
<--->
Can what I'm trying to do be done?
Thanks,
Keith

The following works on 10R2
create or replace type NColPipe as object
  l_parm varchar2(10),   -- The parameter given to the table function
  rows_requested number, -- The parameter given to the table function
  ret_type anytype,      -- The return type of the table function
  rows_returned number,  -- The number of rows currently returned by the table function
  static function ODCITableDescribe( rtype out anytype, p_parm in varchar2, p_rows_req in number := 2 )
  return number,
  static function ODCITablePrepare( sctx out NColPipe, ti in sys.ODCITabFuncInfo, p_parm in varchar2, p_rows_req in number := 2 )
  return number,
  static function ODCITableStart( sctx in out NColPipe, p_parm in varchar2, p_rows_req in number := 2 )
  return number,
  member function ODCITableFetch( self in out NColPipe, nrows in number, outset out anydataset )
  return number,
  member function ODCITableClose( self in NColPipe )
  return number,
  static function show( p_parm in varchar2, p_rows_req in number := 2 )
  return anydataset pipelined using NColPipe
create or replace type body NColPipe as
  static function ODCITableDescribe( rtype out anytype, p_parm in varchar2, p_rows_req in number := 2 )
  return number
  is
    atyp anytype;
  begin
    anytype.begincreate( dbms_types.typecode_object, atyp );
    if p_parm = 'one'
    then
      atyp.addattr( 'one'
                  , dbms_types.typecode_varchar2
                  , null
                  , null
                  , 10
                  , null
                  , null
    elsif p_parm = 'two'
    then
      atyp.addattr( 'one'
                  , dbms_types.typecode_varchar2
                  , null
                  , null
                  , 10
                  , null
                  , null
      atyp.addattr( 'two'
                  , dbms_types.typecode_varchar2
                  , null
                  , null
                  , 10
                  , null
                  , null
    else
      atyp.addattr( p_parm || '1'
                  , dbms_types.typecode_varchar2
                  , null
                  , null
                  , 10
                  , null
                  , null
      atyp.addattr( p_parm || '2'
                  , dbms_types.typecode_varchar2
                  , null
                  , null
                  , 10
                  , null
                  , null
      atyp.addattr( p_parm || '3'
                  , dbms_types.typecode_number
                  , 10
                  , 0
                  , null
                  , null
                  , null
    end if;
    atyp.endcreate;
    anytype.begincreate( dbms_types.typecode_table, rtype );
    rtype.SetInfo( null, null, null, null, null, atyp, dbms_types.typecode_object, 0 );
    rtype.endcreate();
    return odciconst.success;
  exception
    when others then
      return odciconst.error;
  end;  
  static function ODCITablePrepare( sctx out NColPipe, ti in sys.ODCITabFuncInfo, p_parm in varchar2, p_rows_req in number := 2 )
  return number
  is
    elem_typ sys.anytype;
    prec pls_integer;
    scale pls_integer;
    len pls_integer;
    csid pls_integer;
    csfrm pls_integer;
    tc pls_integer;
    aname varchar2(30);
  begin
    tc := ti.RetType.GetAttrElemInfo( 1, prec, scale, len, csid, csfrm, elem_typ, aname );
    sctx := NColPipe( p_parm, p_rows_req, elem_typ, 0 );
    return odciconst.success;
  end;
  static function ODCITableStart( sctx in out NColPipe, p_parm in varchar2, p_rows_req in number := 2 )
  return number
  is
  begin
    return odciconst.success;
  end;
  member function ODCITableFetch( self in out NColPipe, nrows in number, outset out anydataset )
  return number
  is
  begin
    anydataset.begincreate( dbms_types.typecode_object, self.ret_type, outset );
    for i in self.rows_returned + 1 .. self.rows_requested
    loop
      outset.addinstance;
      outset.piecewise();
      if self.l_parm = 'one'
      then
        outset.setvarchar2( to_char( i ) );
      elsif self.l_parm = 'two'
      then
        outset.setvarchar2( to_char( i ) );
        outset.setvarchar2( 'row: ' || to_char( i ) );
      else
        outset.setvarchar2( 'row: ' || to_char( i ) );
        outset.setvarchar2( 'row: ' || to_char( i ) );
        outset.setnumber( i );
      end if;
      self.rows_returned := self.rows_returned + 1;
    end loop;
    outset.endcreate;
    return odciconst.success;
  end;
  member function ODCITableClose( self in NColPipe )
  return number
  is
  begin
    return odciconst.success;
  end;
end;
/And to use it
SQL> select * from table( NColPipe.show( 'test', 3 ) );
test1      test2           test3
row: 1     row: 1              1
row: 2     row: 2              2
row: 3     row: 3              3
SQL>  select * from table( NColPipe.show( 'two', 5 ) );
one        two
1          row: 1
2          row: 2
3          row: 3
4          row: 4
5          row: 5
SQL> select * from table( NColPipe.show( 'one' ) );
one
1
2
SQL> Anton

Similar Messages

  • How to create a table with a dynamic amount of columns

    Hi, all!
    Thare is a tutorial at javaFX documentation page. This example describes how to make tableView, if you have some certain java class, which can tell you which columns you are going to have. (That is a Person class in this example).
    But what if i do not have any specific class, and number of columns can vary from time to time? In my case i have such data structure:
    class TableData{
        List<Row> rows; //A list with all my rows i need to have in my table
    class Row{
        List<Column> columns; //Cells\Columns for every row.
    class Column{
        Attribute attr; //Each column - is somethig like a wrapper for the real data i need to show in a cell;
    class Attribute{ //My precues data
        String name;
        SupportingInfo info;
    class SupportingInfo{//Some supporting fields...
        String name;
        String value;
        //...etc....
    }So, my case is very similar to [this one|http://blog.ngopal.com.np/2011/10/19/dyanmic-tableview-data-from-database/] . The only differents is that data from the case above is not binded with its representation in javaFX table (so, even if some one will make extra controls to edit this data in a tableView, the actual object with that data will never know about it.), because it(data) goes to the table like some strings, not like some objects;
    So, what do i need - is to push data to the table (like that: table.setItems(tableData)), set some set Factories, to give user ability to edit data, and to have this edited data in my tableData object;
    Here are some code i've tried to make for this purpose:
    //prepare my table
    private void createTableHeader(TableView table, List<Attribute> ias) {
        int i = 0;
        for (final Attribute ia : ias) {
            final int j = i;
            i++;
            TableColumn tc = new TableColumn(ia.getName());
            tc.setSortable(true);
            tc.setCellValueFactory(new Callback<CellDataFeatures<List<Attribute>, String>, ObservableValue<String>>() {
                @Override
                public ObservableValue<String> call(CellDataFeatures<List<Attribute>, String> arg0) {
                    if(arg0.getValue().get(j).getSupportingInfo() == null){
                        arg0.getValue().get(j).setSupportingInfo(new SupportingInfo());
                    return new SimpleObjectProperty(arg0.getValue().get(j),"value");
            table.getColumns().add(tc);
    //loading some data to my tableView
    private void createTableBody(TableView curTable, List<Row> rows) { 
        ObservableList<List<Attribute>> data = FXCollections.observableArrayList();
        for (Row row : rows) {
            data.add(row.getColumns());
        curTable.setItems(data);
    //this one is to define some extra controls for editing data in a table by users
    private void makeCellFactory(TableColumn curTableCol, final Attribute templateIa, final Document doc) {
        curTableCol.setCellFactory(new Callback<TableColumn, TableCell>() {
            public TableCell call(TableColumn p) {
                final EditingCell cell = new EditingCell(templateIa, doc);
                return cell;
    }But, as a result, i have just empty rows in my table, with an ability to click some cell and recieve table editing controls. But there is not defult values in by table; What am i doing wrong in my code?
    Edited by: 929064 on 21.09.2012 2:24
    Edited by: 929064 on 24.09.2012 8:26
    Edited by: 929064 on 24.09.2012 8:27

    I put an example up on this thread No DataGrid component? with a TableView displaying values from a non-JavaFX aware data model. It might help get you started. This example is not editable, to make your table editable you would need to update the data model directly when editing is complete.
    Note that if you're building the data model from scratch, there's no need for the listener-notification to be built by hand, as I did in the example. Your data model can directly use the same JavaFX collections instances the table is using.

  • BI  Layout/Template | Table with dynamic number of columns

    hi!
    i have a problem concerning the creation of a dynamic report with the BI publisher.
    in my BI template i need a table with a dynamic number of columns. i have searched the
    forums but havent really found a solution for this type of problem.
    first of all this is A dummy-structure of my dataset:
    <ROWSET>
         <ROW>
              <FIELD1>1</FIELD2>
              <FIELD2>2</FIELD2>
              <FIELD3>3</FIELD3>
              <FIELD4>4</FIELD4>
         </ROW>
         <ROW>
              <FIELD1>a</FIELD2>
              <FIELD2>b</FIELD2>
              <FIELD3>c</FIELD3>
              <FIELD4>d</FIELD4>
         </ROW>
    </ROWSET>
    in the report the fields represent the columns i need in the table.
    the problem is, that the number of the fields vary. in this example i have 4 fields/columns
    but another time i may have 6 or 10 etc..
    my dataset is always different because i am loading my dataset via a http request which is
    returning the needed data in XML.
    is there a nativ possibility within the publisher to generate the columns dynamically?
    i read about <?split-column-header:group element name?> etc. but this is only for cross-tables.
    can anybody give me a hint how to approach this problem?
    would be very glad for some advice.
    thanks a lot in advance!

    Specific answer is here
    http://winrichman.blogspot.com/2008/09/dynamic-column.html
    but these link let you know, how to do
    http://winrichman.blogspot.com/search/label/Dynamic%20column
    http://winrichman.blogspot.com/search/label/Cross-tab
    http://winrichman.blogspot.com/search/label/cross%20tab

  • How to create a function with ref_cursor as parameter in OWB 10.1

    Hi,
    Can any one help me how to create a function with ref_cursor as parameter in OWB 10.1.?
    Its urgent. Please help me.
    Thanks,
    Siv

    Hi David,
    Thanks for your reply.
    Before going for this function, I need to create a package in transformation node in owb module.
    My package is as follows,
    Create or replace package 123
    type xxx is RECORD ( parameters);
    type yyy is RECORD (parameters);
    type aaa is table of yyy;
    type bbb is REF CURSOR return xxx;
    type ccc is record (parameters);
    type ddd is ref cursor return eee;
    END;
    How can I create the above kind of package manually in OWB 10.1 (Should not to import the package)
    Please help me its urgent.
    Thanks,
    Siv

  • How to use TRUNC function with dates in Expression Builder in OBIEE.

    Hi There,
    How to use TRUNC function with dates in Expression Builder in OBIEE.
    TRUNC (SYSDATE, 'MM') returns '07/01/2010' where sysdate is '07/15/2010' in SQL. I need to use the same thing in expression builder in BMM layer logical column.
    Thanks in advance

    use this instead:
    TIMESTAMPADD(SQL_TSI_DAY, ( DAYOFMONTH(CURRENT_DATE) * -1) + 1, CURRENT_DATE)

  • How to use INVOKE function with INT parameter types

    Can you tell me how to use invoke function with int parameter type ?

    Pass the int as an Integer.

  • How can I Create function with an  out Parameter

    how all
    how can I Create function with an out Parameter
    I try to create it it sucess but how can I CALL it , it give me error
    please I want A simple example
    thanks

    3rd post on same question by same user :
    Re: how can I Create function with an  out Parameter
    how can I Create function with an  out Parameter

  • How Create procedure or function with ADO ?

    Hello,
    How Create procedure or function with ADO?It's my question.
    Thanks.
    Henri

    This message if post by Taiwan-ChangHaw-Oracle-Stored-Procedure-For-Business-Rule-Club
    public bool ConnectDatabase()
    try
    { string strConnectionString =
    "Provider=OraOLEDB.Oracle" +";"+
         "Data Source=" + ConnectionParams.Datasource +";"+
    "User Id =" + ConnectionParams.Username +";"+
    "Password =" + ConnectionParams.Password;
         m_conn=new ADODB.Connection();
         m_conn.ConnectionString=strConnectionString;
         m_conn.Open("","","",0); //i_"YYAOl Open the connection
    catch(Exception e)
    {     System.Windows.Forms.MessageBox.Show(e.Message);
         return false;
    return true; //YYAOl_B>3I9&connected successfully
    public void InsertDescription(string p_product,string p_language,string p_tname,string p_tdescription)
    { string sql="{Call inserttranslateddescription(?,?,?,?,?)}";
    try
    { ADODB._Command cmd=new ADODB.Command();//Create a command object
    cmd.ActiveConnection=m_conn; //Set its active connection to open connection
    ADODB.Properties properties=cmd.Properties;//Get the command properties into ADODB Properties object
    IEnumerator ienum=properties.GetEnumerator();//Get an enumerator on above properties
    ADODB.Property singleprop;
    while(ienum.MoveNext()) //iterate through the enumerator
         {singleprop=(ADODB.Property)ienum.Current;//Get the current property from enumerator
         string propname= singleprop.Name; //Get the name of current property
         if(propname.Equals("NDatatype")) //if the property is 'NDatatype' set its value to true
         singleprop.Value=true;
    cmd.CommandType=ADODB.CommandTypeEnum.adCmdText;
    int pid=Int32.Parse(p_product);
    ADODB._Parameter langid     =cmd.CreateParameter("langid",          ADODB.DataTypeEnum.adChar,ADODB.ParameterDirectionEnum.adParamInput, 100,p_language);
    ADODB._Parameter productid =cmd.CreateParameter("productid",     ADODB.DataTypeEnum.adNumeric,ADODB.ParameterDirectionEnum.adParamInput, 100,pid);
    ADODB._Parameter tname =cmd.CreateParameter("tname",          ADODB.DataTypeEnum.adBSTR,ADODB.ParameterDirectionEnum.adParamInput, 50,p_tname);
    ADODB._Parameter tdescription=cmd.CreateParameter("tdescription",ADODB.DataTypeEnum.adBSTR,ADODB.ParameterDirectionEnum.adParamInput, 50,p_tdescription);
    ADODB._Parameter check          =cmd.CreateParameter("check",          ADODB.DataTypeEnum.adNumeric,ADODB.ParameterDirectionEnum.adParamOutput,100,0);
    cmd.Parameters.Append(langid);
    cmd.Parameters.Append(productid);
    cmd.Parameters.Append(tname);
    cmd.Parameters.Append(tdescription);
    cmd.Parameters.Append(check);
    cmd.CommandText=sql;
    //Execute the command to insert product details in database
    object recs;
    object param=p_language;
    cmd.Execute(out recs,ref param,1);
    ienum.Reset();
    while(ienum.MoveNext()) //iterate through enumerator
    { singleprop=(ADODB.Property)ienum.Current;//Get the current property in to Property object
    string propname= singleprop.Name; //Get the name of current property
    if(propname.Equals("NDatatype")) //if it is 'NDatatype' set its value to true
    singleprop.Value=false;
    IEnumerator iprop=cmd.Parameters.GetEnumerator();//Get the enumerator for command parameters
    while(iprop.MoveNext()) //loop through enumerator
    { //Get the current parameter in enumerator
    ADODB._Parameter checkval=(ADODB._Parameter)iprop.Current;
    if(checkval.Name.Equals("check")) //if the parameter is 'check'
    if(checkval.Value.ToString().Equals("0")) //If check's value is zero data was inserted
    System.Windows.Forms.MessageBox.Show("Product details Inserted successfully");
    else
    System.Windows.Forms.MessageBox.Show("Product Details Updated");//else data was updated
    catch(Exception e)
    System.Windows.Forms.MessageBox.Show(e.Message);//Display any error message
    }

  • How to link Partner function with EDI ?

    Hi all,
    While sending PO thourgh EDI i am getting some error message...Partner function is not assigned with EDI..this message is not coming with ALE.
    Can any body help me to "How to link Partner function with EDI "?
    Thanks in advance.
    ankush

    Hi Ankush,
    Perhaps unintentionally, you are not rewarding points for correct answers, instead of clicking on the radio button"AWARD POINTS", you are clicking  "SOLVED BY OWN".
    and no points are being given from your side.
    Please award points if you find the answers helpful.
    Now also you can award points first, unassign by clicking again and then assign to whomsoever you think deserves.
    Regards,
    Sachendra Singh

  • How to call java function with parameter from javascript in adf mobile?

    how to call java function with parameter from javascript in adf mobile?

    The ADF Mobile Container Utilities API may be used from JavaScript or Java.
    Application Container APIs - 11g Release 2 (11.1.2.4.0)

  • How to create 2D array with 3 rows and unlimit column?

    how to create 2D array with 3 rows and unlimit column?

    Here are images of what I described in my previous post
    Message Edited by JoeLabView on 11-14-2007 07:56 AM
    Attachments:
    2D-array_code.PNG ‏7 KB
    2D-array_values.PNG ‏13 KB

  • I've lost my iphone 5. How to locate the phone with the AMEI number?

    I've lost my iphone 5. How to locate the phone with the AMEI number?

    You can't. Only if you set up find my iphone on the phone then you can use icloud to find it.

  • HT1529 how to find my iphone with the serial number

    hi
    could you please tell how to find my iphone with the serial number ?

    Sorry, there is no way to do that.
    What To Do If Your iDevice or Computer Is Lost Or Stolen
    iPhone, iPod Touch, and iPad
    If you activated Find My Phone before it was lost or stolen, you can track it only if Wi-Fi is enabled on the device. What you cannot do is track your device using a serial number or other identifying number. You cannot expect Apple or anyone else to find your device for you. You cannot recover your loss unless you insure your device for such loss. It is not covered by your warranty.
    If your iPhone, iPod, iPod Touch, or iPad is lost or stolen what do you do? There are things you should have done in advance - before you lost it or it was stolen - and some things to do after the fact. Here are some suggestions:
    This link, Re: Help! I misplaced / lost my iPhone 5 today morning in delta Chelsea hotel downtown an I am not able to track it. Please help!, has some good advice regarding your options when your iDevice is lost or stolen.
      1. Reporting a lost or stolen Apple product
      2. Find my lost iPod Touch
      3. AT&T. Sprint, and Verizon can block stolen phones/tablets
      4. What-To-Do-When-Iphone-Is-Stolen
      5. What to do if your iOS device is lost or stolen
      6. 6 Ways to Track and Recover Your Lost/Stolen iPhone
      7. Find My iPhone
      8. Report Stolen iPad | Stolen Lost Found Online
    It pays to be proactive by following the advice on using Find My Phone before you lose your device:
      1. Find My iPhone
      2. Setup your iDevice on iCloud
      3. OS X Lion/Mountain Lion- About Find My Mac
      4. How To Set Up Free Find Your iPhone (Even on Unsupported Devices)
    Mac Computer
           Find My Mac can be used from Find My Phone at iCloud.com and via Find
           My Phone on your iDevice.
          The following is third-party anti-theft software:
               1.  STEM 2.1
               2.  MacPhoneHome 3.5
               3.  MacTrack 7.5.0
               4.  VUWER 1.7
               5.  Sneaky Bastar* 0.2.0
               6.  Undercover 5.1.1
               7.  LoJack for Laptops
               8. Hidden 2.0

  • Dynamic Number of Column in a table

    Hi guys,
    I have a requirement that needs dynamic number of column in a tale.
    It is possible to do this in Adobe forms.
    Thanks,
    Chirantan

    Hello. It of course is possible in Adobe.
    You need to write a simple script using JavaScript or FormCalc to hide or show columns according to some special value. You will work with the presence attribute of the object. E.g. MYFIELD.presence = "visible" or "hidden" or "invisible". You will need to change your subforms content to flowed.
    Use these guides:
    http://www.adobe.com/devnet/livecycle/articles/lc_designer_scripting_basics/lc_designer_scripting_basics.pdf
    help.adobe.com/en_US/livecycle/es/FormCalc.pdf
    Hope this helps, good luck, Otto

  • How to call javascript function with dynamic data in display tag

    Hi,
    Iam new to pagination concept. Iam using display tag to display rows in jsp by strtus.
    I have a problem when calling the javascript function using ahref in attribute in display tag.
    <bean:define name="form1" property="EditDetails.List" id="ListDisplay"/>
    <display:table name="pageScope.ListDisplay" cellpadding="0" cellspacing="1" pagesize="10" partialList="false" size="listSize" requestURI="">
    <display:column property="poNo" href='javascript:searchEditDetails("./submitOrder.do? actionID=getMISLoadEdit&poNumberSel=<%=((com.po.bean.EditDetails)poListDisplay).getNo()%>&statusIdSelected=<%=((com.po.bean.EditDetails)ListDisplay).getStatusId()%>")'
    title="Number"/>                         
    <display:column property="strDate"title="Date" />
    <display:column property="orderValue"title="Order Value(INR)"/>
    <display:column property="stringRequestedDeliveryDate"title="Suggested Delivery Date"/>
    <display:column property="statusDescription" title="Status" />
    </display:table>
    The above code display the data in row format is working fine when I click the No It thow javascript error and its not redirecting to the other page.
    When I try this with ordinary struts its working fine the code is:
    <logic:iterate id="polist" name="Form1" property="EditDetails.List" indexId="i" type="com.bean.EditDetails">
    <tr>
    <td ><a href="javascript:searchEditDetails("./submitOrder.do?actionID=getMISLoadEdit&NumberSel=<%=((com.bean.EditDetails)polist).getNo()%>&statusIdSelected=<%=((com.bean.EditDetails)polist).getStatusId()%>")"><html:hidden name="polist" property="No" write="true" /></a>     </td>
    <td><html:hidden name="polist" property="strDate" write="true" /></td>
    <td><html:hidden name="polist" property="orderValue" write="true" /></td>
    <td><html:hidden name="polist" property="stringRequestedDeliveryDate" write="true" />     </td>
    <td><html:hidden name="polist" property="statusDescription" write="true" /></td>
    </tr>
    </logic:iterate>
    Please help me how to call javascript with dynamic data.
    Thanks in advance

    The ADF Mobile Container Utilities API may be used from JavaScript or Java.
    Application Container APIs - 11g Release 2 (11.1.2.4.0)

Maybe you are looking for

  • Problem overloading "set data" function on Button DataGrid Renderer

    Hi all, I'm hoping this is something simple. I have a class that extends mx.controls.Button and implements mx.core.IDataRenderer.  I need to set the button icon whenever the Data property is set from the DataGrid.  My problem is that my overloaded se

  • Best options to use in Temp Table

    Hello, I was just trying to figure out the best options we can choose with when we come across a scenario where we need to use a  Temp Table/Table Variable/Create a Temp Table on the fly. However, I could not see any big difference in using those opt

  • KPI doesn't filter according to the repository variables- obiee 11g

    Hello all, I have created a KPI that contains the following dimensions: Year, Monthname, Trn_date I have also created some 3 repository variables: CurrentYearRepoVariable: holds current year (select to_char(trunc(sysdate, 'yyyy'),'yyyy') from dual) C

  • "in update task" and "strings"

    Hi guys, I tried to extend a table by a string. this table is updated via a function module (Verbuchungsbaustein = in update task). The new rows are submited via the tables option. But this leads to a dump, could it be that it is not possible to use

  • VL06 / LT0S create Transfer Order for Multiple Deliveries

    Dear all, My customer is used to create a WM Transfer Order for multiple Deliveries with transaction LT0S. The group that is processed here was created with VL06 / subsequent functions/ Group / Create with WM reference / TO for Multiple Deliveries. -