FUNCTION/FORMULA to randomly sort, then select from rows

Hi! Using Numbers more now but still quite new. VERY used to Apple way and familiar with Automator, at least capable of copy/pasting an Applescript, and somewhat versed in UNIX. Basically need to shuffle all the entries in say "Column A" and maybe "B", and then pick from them and 'print' to a file or some other field or table. At the very least even being able to just make the couple thousand names being entered in to their-own field randomly-sorted would be a BIG help. Just in case I'm not being clear, instead of just sorting ascending or descending. Thank you!!!
Message was edited by: jon215

Hi jon,
Numbers will only sort in ascending or descending order, and sorts whole rows (not individual columns) on the basis of the contents of one or more columns. It will sort the entire table (excepting any header and footer rows), or will sort selected rows.
If you want to do a random sort of a column of names, you can do it by adding a column, entering this formula into all cells in the column (except header and footer cells), and sorting on the new column.
=RAND()
The formula generates a random number between 0 and 1. When the table is sorted, the sort will place those numbers in ascending or descending order (as you choose), but will then immediately calculate a new set of random numbers.
If you just need to pick a random name form the list, you can use OFFSET and RANDBETWEEN.
If the names are in column A, starting at A2, this formula, placed elsewhere on the same table, will return a random name from the list:
=OFFSET($A$1,RANDBETWEEN(1,ROWS($A)-1),0)
Regards,
Barry

Similar Messages

  • I opened Adobe Acrobate XI Standard to create a form.  I then selected From Template, which took me to Adobe FormsCentral Online.  However, I think the form is an HTML web form.  All I wanted was a regular PDF form that I could email my co-workers for an

    I opened Adobe Acrobate XI Standard to create a form.  I then selected From Template, which took me to Adobe FormsCentral Online.  However, I think the form is an HTML web form.  All I wanted was a regular PDF form that I could email my co-workers for an internal project we're colletively working on.  Now I see that FormsCentral is going away and I can't get my doc to save as a PDF without an upgrade?  Help

    You should be able to log into the online Formscentral Acrobat XI air app and see your doc there. From there you would need to save it out as a PDF without a submit button to have it continue to work past July. If you don't see your online form(s) please let me know the adobeID you use to log into the service as well as the form name that is missing and I will look into it for you.
    Andrew

  • Selected rows appear in random order when selected from ADF Table

    Hi All,
    I am working in ADF 10.1.3
    I have a ADF Table with a multi select option associated with a DataBean, My requirement is when I select multiple rows from the table and click on some button to goto next page, the selected rows are not getting populated as per the selection order.
    Example: If I select 1st,3rd,5th,7th,9th rows from the ADF Table then in the next page I see the results as 3rd,1st,5th,9th,7th. - Randomly it is getting displayed.
    I am using the following code to get the records from Multi select ADF Table.
    I am adding the selected records to a List.
    selectedRowSet = this.getTable1().getSelectionState().getKeySet();
    rowSetIter = selectedRowSet.iterator();
    if (selectedRowSet.size() > 0)
    Integer index = Integer.parseInt((String) rowSetIter.next());
    Object rowData = this.getTable1().getRowData(index.intValue());
    The order is getting jumbled when I see the final list.
    Pls help me in this.
    Thanks

    Hi Frank,
    Thanks for the update.
    We are using 10.1.3.3 and already our application in QA Testing. User need this to be fixed. Is there any work around for this problem?
    Thanks
    JP

  • Is select from view faster then select from table..???

    Hello Gurus,
    I want to query some data from two tables, both of table have many columns (attributes) and many rows...
    I use several where clauses to retrieve data from those tables..
    witch one is faster, I create a view or I just "select" from those tables???
    Regards.
    Nia...

    riedelme wrote:
    3360 wrote:
    riedelme wrote:
    Selecting through a view almost never helps performance and frequently hurts.Views do not affect performance.
    Views are simply queries and like queries there are fast and slow ones.I disagree.
    First of all, to use a view you are executing a query to get a result set, then accessing the data from that result set - a built-in extra step to perform to get data.First of all that entire explanation of how views work is not correct. The optimizer will rewrite the query to make the view go away if possible.
    SQL> create or replace view v as select * from dual;
    View created.
    SQL> explain plan for select * from dual where dummy = 'X';
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 272002086
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |     2 |     2   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("DUMMY"='X')
    13 rows selected.
    SQL> explain plan for select * from v where dummy = 'X';
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 272002086
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |     2 |     2   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("DUMMY"='X')
    13 rows selected.Exactly the same.
    >
    Second, when accessing the data from the view the result sets don't have indexes for fast lookups and efficient joins on later steps.This is also known as just making stuff up and is not how the database works. care to share any references at all for any of this?
    >
    Third, the systems I've seen that use views extensively - I am looking at one now - tend to perform joins on views using the same tables with the same data over and over. This is a design issue and not specifically a problem with views but they lend themselves to this misuse much too easilyCorrect as I said a view is just a query, and just like queries there are good fast views and bad slow views
    >
    I'll concede that the problem is not specifically with views themselves but as I just said they lend themselves to misuse. Tuning views of views and views joined to views is difficultYes, queries can be misused as can almost all SQL functions and functionality.
    As I said - Views are simply queries and like queries there are fast and slow ones.
    Nothing that you have posted that is accurate changes that.

  • How to use the same function in a column so it varies from row to row.

    In a spreadsheet, I have four columns: item, quantity, price, total cost.
    How can I write a function (product) for the entire "total cost" column that automatically will place the correct "total cost" for the item in that row; i.e.: =product(quantity,price)
    This would save time by writing one function for the entire column so that the function would not have to be written for each row.
    Thanks for your help.

    Question asked and responded several times.
    If quantity is in column C and price in column D,
    the common soluce is to use the formula:
    =C2*D2 in E2
    then use the fill down tool which will automatically create the formulas
    =C3*D3
    =C4*D4
    As I am a lazy guy, I use a shorter formula:
    =C*D
    and fill down reproduce it as is in the other cells.
    In fact I use
    =ROUND(C*D,2)
    Yvan KOENIG (from FRANCE samedi 4 juillet 2009 11:31:06)

  • Selecting from a function that returns a sys refcursor or an alternative

    I have a query that returns a resultset of three columns, namely SSN,PAID_YEAR and PAID_TOTAL. From this query I can:
    Create a view and then query it.
    Create a function and return resultset
    If I go the first way a simple query like the following takes more than 20 seconds:
    SELECT PAID_YEAR,PAID_TOTAL FROM VIEW_1 WHERE SSN=12345678912882;
    I know that is because when I query a view the engine first brings all the rows of the view and then it filters the rows for the criteria supplied.
    If I go the second way I can send a parameter and make the engine look only for those rows that match the condition and return the recordset. But I do not know how to then SELECT from that returned resultset. I took a look at pipelined tables but didn't quite get how to benefit them. So my ultimate question is if it's somehow possible to select from the resultset that is returned from a function like this:
    SELECT * FROM FUNCTION_1(12132323232).
    If yes, then how, if no, what would be an alternative way?

    I know that is because when I query a view the engine first brings all the rows of the view and then it filters the rows for the criteria supplied.
    No - you don't 'know that' because it isn't true. Just check the explain plan for yourself. Oracle can still use any appropriate indexes so that only the rows needed are returned.
    So my ultimate question is if it's somehow possible to select from the resultset that is returned from a function like this:
    SELECT * FROM FUNCTION_1(12132323232).
    No - you can't do it like that. You have to use the TABLE function to treat the function result set as a table:
    'SELECT * FROM TABLE(FUNCTION_1(12132323232)).
    -- 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
    -- 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;
    select * from table(get_emp(20))

  • Oracle 8i, selecting from Stored Procedudure

    Hi
    In InterBase it is possible to create a Stored Procedure with some input parameters and then select from it.
    for example:
    select * from my_stored_procedure (my_parameter);
    Is it possile to do something similar in Oracle 8i?
    Where to find examples on creating and using stored procedures like this?
    I am new to Oracle and have been browsing documentation CD and otn.oracle.com websites, however is seemes like finding a needle in a haystack.
    I would appreciate any samples or links.
    Thanks,
    Raigo

    As far as I know, this is not possible directly the same way as in IB. You can resort to using REF CURSORs though:
    create or replace package p
    as
    type t_rc is ref cursor; -- weak ref cursor
    function f( cond in number ) return t_rc;
    end;
    create or replace package body p
    as
    function f ( cond in number ) return t_rc
    is
    rv t_rc;
    begin
    open rv for 'select * from some_table where id = :cond' using in cond;
    -- just return open cursor
    return rv;
    end;
    end;
    then you can use it this way:
    declare
    c p.t_rc;
    r some_table%rowtype;
    begin
    c := p.f(100);
    loop
    fetch c into r;
    exit when c%notfound;
    -- process row r here
    end loop;
    end;
    You can also use SELECT FROM TABLE( CAST (function(...) AS collection_type)) syntax - browse Object-Relational Features guide, SQL Reference and Application Development - Fundamentals for more info and examples on this.

  • How can I double sort my message list? Sort then a sub sort

    I would like to sort my messages by date (or some other category), then sort by another category while keeping the first sort. In other words, a sort within a sort. I'm using TB 24.6.0

    example:
    If you select
    View > Sort by > select: 'From' and 'Descending' and 'Group by Sort'
    You will get a list of names Z at top and A at bottom, with a sublist of emails sorted with newest at top.
    Changing the sort selection from Descending to Ascending will put the names sorted A at top, but the dates per person will be oldest at top.
    As I prefer the emails to be in date newset on top, it means I have to select to have the order of 'From' with A at bottom; depends on your preference.
    Additional:
    If you start by selecting: 'From' and 'Descending' and 'Group by Sort'
    then change sort to 'Ascending', you may notice no change until you hover the mouse over the entire list, this is a known bug.
    Please feel free to Vote for this bug, you may need to logon / tregister.
    * https://bugzilla.mozilla.org/show_bug.cgi?id=497643

  • Sort - not columns - but rows in 3.01

    How to sort - not columns - but rows - in 3.01?

    Hi Sune,
    While we all wait for Apple to put this feature back in another update of Numbers 3, try this:
    You want to sort rows 11-14 (as an example). Add a Colour Fill to row 15 as a guide for later.
    Select rows 11-14. Click and *hold* on any Row Reference Tab. You will see the selected rows appear to 'lift'. Drag those rows away from Table 1 to a blank part of the 'canvas':
    and they will form a new table. Sort this table.
    Then select all rows of Table 2, and Copy.
    Click on Table 1. Select the colour filled row where you want to insert (row showing 23 Jun 2013 in this example).
    Menu > Insert > Copied Rows.
    Not as easy as Numbers 2.3 Reorganize Panel, but a workaround.
    If you frequently resort the same rows, consider placing them in their own table.
    Regards,
    Ian.

  • Show the checkbox as selected by selecting the row.

    Hi friends,
    I have a table. It is possible to select multiple rows, after selecting rows, I get the selected
    rows in this table from the context. Now my question is, how can i cause that by selecting a row
    the checkbox on this row will be also selected (shown as checked)?
    So this is the coding in the eventhandlermethod on onselect property of the table:
    METHOD onactionmark_cb .
      DATA lo_nd_table_data TYPE REF TO if_wd_context_node.
      DATA lo_el_table_data TYPE REF TO if_wd_context_element.
      DATA ls_table_data TYPE wd_this->element_table_data.
      DATA lt_table_data TYPE wd_this->elements_table_data.
      DATA lt_set TYPE wdr_context_element_set.
    DATA lv_idx TYPE i.
    navigate from <CONTEXT> to <TABLE_DATA> via lead selection
      lo_nd_table_data = wd_context->get_child_node( name = wd_this->wdctx_table_data ).
    This would now contain the references of all the selected rows
      CALL METHOD lo_nd_table_data->get_selected_elements
        RECEIVING
          set = lt_set.
      LOOP AT lt_set INTO lo_el_table_data.
        " Use the references to get the exact row data
        CALL METHOD lo_el_table_data->get_static_attributes
          IMPORTING
            static_attributes = ls_table_data.
        APPEND ls_table_data TO lt_table_data.
        CLEAR ls_table_data.
      ENDLOOP.
    mark/shhow the checkboxes checkd in the selected rows
    ENDMETHOD.
    Thank you for any help
    Haleh
    Edited by: Haleh Mir Ashrafi on Nov 9, 2008 6:29 PM

    Hi Haleh,
    I tried replicating your requirement and have written below the exact working code for the same. I will try to explain you my component so that you can get to understand its functionality. I have 2 tables & 1 input field in my view. The user enters a customer number in the input field and presses on a button. This leads to the corresponding sales orders filled into the 1st table ui element. The user then selects multiple rows from this table and presses on a toolbar button to copy these selected rows to the 2nd table. Within the same event I also set the checkbox for the rows selected by the user in the 1st tables row to selected. Hope that this would meet your requirement. On pressing the button the system would check if the checkbox is enabled & then mark the selected rows checkboxes as selected and would also copy the rows to the 2nd table. If the checkbox is disabled then the system would neither set it as checked nor copy it to the 2nd table. The rest of the checkboxes for the rows which weren't selected by the user remain as unchecked.
    METHOD onactioncopy_selected_rows .
      DATA:  wd_node TYPE REF TO if_wd_context_node,
             ls_node1 TYPE ig_componentcontroller=>element_node1,
             lt_node1 TYPE ig_componentcontroller=>elements_node1,
             wa_temp  TYPE REF TO if_wd_context_element,
             lt_temp  TYPE wdr_context_element_set.
      wd_node = wd_context->get_child_node( name = 'NODE1' ).
      " Get all the context element information for the rows selected by the user
      CALL METHOD wd_node->get_selected_elements
        RECEIVING
          set = lt_temp.
      " Just get the reference of the 2nd table to which you want to copy selected rows
      wd_node = wd_context->get_child_node( name = 'NODE2' ).
      LOOP AT lt_temp INTO wa_temp.
        CALL METHOD wa_temp->get_static_attributes
          IMPORTING
            static_attributes = ls_node1.
        " Check if the checkbox is disabled/enabled. The "enabled" property of the checkbox
        " is bound to the boolean context attribute by name ENABLED
        IF ls_node1-enabled EQ abap_true.
          wa_temp->set_attribute( EXPORTING name  = 'CHECKBOX'
                                            value = abap_true ).
          APPEND ls_node1 TO lt_node1.
          CLEAR ls_node1.
        ENDIF.
      ENDLOOP.
      " Bind the rows selected by the user to the 2nd table ui element
      wd_node->bind_table( new_items = lt_node1 ).
    ENDMETHOD.
    I have checked your code where you say like:
    IF elem_test->is_selected( ) = abap_true AND stru_test-enabled = abap_false.
    You had earlier fetched the entire elements list using the get_elements method of if_wd_context_node & then checking each 1 of them individually to determine whether it was selected or not using the method id_selected. You can directly get only the elements which were selected by the user by using the method get_selected_elements instead. So now you will only have to check whether the checkbox field in that particular row is disabled/enabled. You now don't have to combine 2 conditions using AND & check them within the loop.
    Regards,
    Uday

  • Random selection of rows from a 2D array then subset both the rows that were selected and those that were not. Please see message below.

    For example, I have a 2D array with 46 rows and 400 columns. I would like to randomly select 46 data rows from the 2D array. By doing the random selection it means that not all individual 46 rows will be selected some rows may appear more than once as there may be some duplicates or triplicates in the random selection. The importan thing is that we will have randomly selected 46 rows of data (no matter that some rows appear more than once). Then I would like to subset these randomly selected 46 data rows (some which will be duplicated, or triplicated, etc.) and then also find and subset the rows that were not selected. Does this make sense? Then i would like to do this say 10 times for this data set. So that then I will have 2 by 10 data sets: the first 10 each with 46 rows and the other 10 with n rows depending on how many WERE NOT randomly selected. i hope that my explanation is clear. I am relatively new to Labview. It is really great so I am getting better! If anyone can help me with this problems it will be great. RVR

    Start by generating randon #s between 0 and 45. Run a for loop X times and in it use the random function, multiply the result by X and round down (-infinity). You can make this into a subVI, which you can reuse later. In the same loop, or in a different one, use Index Array to extract the rows which were selected (wiring the result out of the loop with auto indexing causes it to be rebuilt into a 2D array).
    One possible solution for the second part would be to go over the array of randomly generated numbers in a for loop and use Search 1D Array to find each of the numbers (i). If you get -1, it means the row wasn't selected and you can extract it.
    I hope this puts you on the right path. If not, don't be afraid to ask more.
    To learn more about LV, I suggest you read the LabVIEW user manual. Also, try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide.
    Try to take over the world!

  • SELECT from table vs. CALL FUNCTION

    Hello,
    I have always wondered what the "best practice" is in this case, so I am looking for input.  When writing custom reports etc. in SAP, is it generally regarded as better practice to write a SELECT statement to get a line from say a Txxx configuration table, or is it best to use an associated BAPI or call to function module?  I know in some cases perfomance must obvioulsy be considered, but in terms of SAP's recommendations or upgrade considerations, which is typically better? 
    Assume for example something as simple as getting company code data...  Is it best to do <b>SELECT * FROM T001...</b> or to call a BAPI like <b>BAPI_COMPANYCODE_GETDETAIL</b>?
    Any feedback would be greatly appreciated.

    Hi
    Never accusing people of regarding performance, however I emphasize safety while developing. Even if it is a T* table, I try to use a standard function or call a subroutine of a standard program doing the work. I feel safer this way. Nevertheless, when I can't find any suitable (as of its interface), I use direct SELECT statements.
    If it is a simple report program then doing direct selects may be tolerable. However, if it is a more sophisticated one, especially if it deals with database updates, I highly recommend to use standards.
    As another way, I am aware you mean simple tables, but by the way, if it has a functional relation with a business entity (e.g. pa0001 for employee), I regard it as mandatory using standard FMs where applicable (I feel myself obliged to call "HR_READ_INFOTYPE" instead of using "SELECT* FROM PA0001...").
    *--Serdar

  • How to get result of Select from stored function.

    I need to get result of select from a stored function.
    In the end of my stored function I makes final select (four columns).
    How it can be retrived from function?

    Hi,
    A function can only return one value, but it sounds like you want to return 4 values.
    The one value that you return can be a record, with many columns, such as a ROWTYPE, or a TYPE that you define.
    You can return an XMLTYPE that has whatever elements you want.
    You can write a procedure that has several OUT parameters. (You can have OUT parameters in a function, but a lot of people find that confusing.)
    In very special circumstance, you might consider returning a string that is a delimited list of values, such as '7639,SMITH,,17-DEC-1980'.
    Someoneelse has a good point.
    We could give a better answer if you ask a specific question, like:
    "I have this table ...
    I want a function such that, if I call it with these parameters ... I get ...
    but if I call it like this ... then I get ..."

  • Select from local (tmp) Table in Function - Table not found

    Hi,
    I want to create a cursor which selects from a Table which does not exist in database.
    I create this table as local table (how is it called? nested table?).
    Not shown in the code but I want to fill this local table later.
    After filled my cursor is going to use this filled table.
    When try to run I get the error Table or View does not exist at the "FROM TempTab_var T1;" of my cursor.
    This is my simplified code:
    CREATE OR REPLACE FUNCTION PC_RL_MTA_PMT
    RETURN PC_RL_MTA_TYPE_PMT
    IS
    result_out PC_RL_MTA_TYPE_PMT;
      TYPE TempTab_record_type IS RECORD
        (ID int);
      TYPE TempTab_type IS TABLE OF TempTab_record_type
              INDEX BY BINARY_INTEGER;
      TempTab_var TempTab_type;
      CURSOR TempCursor3_var IS
        SELECT    ID AS ID_var
        FROM    TempTab_var T1;
    BEGIN
    RETURN result_out;
    END PC_RL_MTA_PMT;
    Any Ideas whats wrong?
    Thanks very much in advance.

    And a further example from my library of examples, just to help you out...
    SQL> CREATE OR REPLACE TYPE num_descript AS OBJECT(num number, descript varchar2(30))
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE tbl_num_descript AS TABLE OF num_descript
      2  /
    Type created.
    SQL> CREATE OR REPLACE PACKAGE reftest AS
      2    FUNCTION pipedata(p_choice number) RETURN tbl_num_descript PIPELINED;
      3  END;
      4  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY reftest AS
      2    FUNCTION pipedata(p_choice number) RETURN tbl_num_descript PIPELINED IS
      3      v_obj num_descript := num_descript(NULL,NULL);
      4      v_rc  sys_refcursor;
      5    BEGIN
      6      IF p_choice = 1 THEN
      7        OPEN v_rc FOR SELECT empno as num, ename as descript FROM emp;
      8      ELSIF p_choice = 2 THEN
      9        OPEN v_rc FOR SELECT deptno as num, dname as descript FROM dept;
    10      END IF;
    11      LOOP
    12        FETCH v_rc INTO v_obj.num, v_obj.descript;
    13        EXIT WHEN v_rc%NOTFOUND;
    14        PIPE ROW(v_obj);
    15      END LOOP;
    16      CLOSE v_rc;
    17      RETURN;
    18    END;
    19  END;
    20  /
    Package body created.
    SQL> select * from table(reftest.pipedata(1));
           NUM DESCRIPT
          7369 SMITH
          7499 ALLEN
          7521 WARD
          7566 JONES
          7654 MARTIN
          7698 BLAKE
          7782 CLARK
          7788 SCOTT
          7839 KING
          7844 TURNER
          7876 ADAMS
          7900 JAMES
          7902 FORD
          7934 MILLER
    14 rows selected.
    SQL> select * from table(reftest.pipedata(2));
           NUM DESCRIPT
            10 ACCOUNTING
            20 RESEARCH
            30 SALES
            40 OPERATIONS

  • Pipelined function, select from table t1 or t2 depending on user's choise

    Hi all,
    My need is to select data from table t1 or t2 depending on user's choise using pipelined function. You can find my first guess below. Maybe someone can help me to save some code, I mean getting the same result without writing "PIPE ROW" twice.
    FUNCTION fn_indicators (p_datbeg date, p_datend date, p_indicatorid number) return cl_risk_act pipelined IS
    v_obj cl_user_type;
    BEGIN
    case when p_indicatorid = 1 then
    FOR e IN (
    select trunc(sysdate-1) as adate, 0 as cid, 0 as indicatorid, '0' as code, '0' as indicatorname, 0 as value, 0 as cnt, '0' as cname from dual
    LOOP
    v_obj.adate              := e.adate;
    v_obj.cid                  := e.cid;
    v_obj.indicatorid       := e.indicatorid;
    v_obj.code               := e.code;
    v_obj.indicatorname  := e.indicatorname;
    v_obj.value              := e.value;
    v_obj.cnt                 := e.cnt;
    v_obj.cname            := e.cname;
    PIPE ROW (v_obj);
    END LOOP;
    when p_indicatorid = 2 then
    FOR e IN (
    select trunc(sysdate-2) as adate, 1 as cid, 1 as indicatorid, '1' as code, '1' as indicatorname, 1 as value, 1 as cnt, '1' as cname from dual
    LOOP
    v_obj.adate              := e.adate;
    v_obj.cid                  := e.cid;
    v_obj.indicatorid       := e.indicatorid;
    v_obj.code               := e.code;
    v_obj.indicatorname  := e.indicatorname;
    v_obj.value              := e.value;
    v_obj.cnt                 := e.cnt;
    v_obj.cname            := e.cname;
    PIPE ROW (v_obj);
    END LOOP;
    end case;
    RETURN;
    end;

    marco wrote:
    Justin,
    In my real code table real_t1 or pipelinedfn_t2 is joined to other tables, so surely real code is bigger than sample one. It is not wise to keep code twise with only one table name changed. I think about dynamic sql to choose from two tables:
    with t1 as
    (select * from real_t1
    t2 as
    (select * from pipelinedfn_t2
    t3 as (
    [dynamic selection of t1 or t2 depending on user's choise]
    select * from t3, t... where...I don't know correct syntax.
    Any ideas?
    >Justin,
    In my real code table real_t1 or pipelinedfn_t2 is joined to other tables, so surely real code is bigger than sample one. It is not wise to keep code twise with only one table name changed. I think about dynamic sql to choose from two tables:
    with t1 as
    (select * from real_t1
    t2 as
    (select * from pipelinedfn_t2
    t3 as (
    [dynamic selection of t1 or t2 depending on user's choise]
    select * from t3, t... where...I don't know correct syntax.
    Any ideas?
    Dynamic code does NOT scale.
    Making the tradeoff of smaller code size for reduced performance is not one that I would make.

Maybe you are looking for