How to Make FUNCTION to return multiple column and multiple row output

Hi All,
Kindly Share ur Idea;Thanks in Advance;
i Have Table Demo.
table DEMO:
id name
1 a10
1 a11
1 a12
2 b10
2 b11
3 ccc
and the function is like:
create or replace function (p1 number) return varchar2 as
vid number;
vname varchar2(20);
begin
select id,name into vid,vname from demo where id=p1;
return v1;
end;
this function returns output for id=3;
BUT,
i need output as (for input as 1)
vid vname
1 a10
1 a11
1 a12

A function returns a single datatype.
That datatype may be an atomic datatype (varchar2, number etc.) or it may be an object/record datatype, or even a collection datatype.
Where are you going to use this function? In PL/SQL or SQL?
If you are wanting to use it in SQL, then you would need a pipelined function e.g.
SQL> CREATE OR REPLACE TYPE myemp AS OBJECT
  2  ( empno    number,
  3    ename    varchar2(10),
  4    job      varchar2(10),
  5    mgr      number,
  6    hiredate date,
  7    sal      number,
  8    comm     number,
  9    deptno   number
10  )
11  /
Type created.
SQL> CREATE OR REPLACE TYPE myrectable AS TABLE OF myemp
  2  /
Type created.
SQL> CREATE OR REPLACE FUNCTION pipedata(p_min_row number, p_max_row number) RETURN myrectable PIPELINED IS
  2    v_obj myemp := myemp(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
  3  BEGIN
  4    FOR e IN (select *
  5              from (
  6                    select e.*
  7                          ,rownum rn
  8                    from (select * from emp order by empno) e
  9                   )
10              where rn between p_min_row and p_max_row)
11    LOOP
12      v_obj.empno    := e.empno;
13      v_obj.ename    := e.ename;
14      v_obj.job      := e.job;
15      v_obj.mgr      := e.mgr;
16      v_obj.hiredate := e.hiredate;
17      v_obj.sal      := e.sal;
18      v_obj.comm     := e.comm;
19      v_obj.deptno   := e.deptno;
20      PIPE ROW (v_obj);
21    END LOOP;
22    RETURN;
23  END;
24  /
Function created.
SQL> select * from table(pipedata(1,5));
     EMPNO ENAME      JOB               MGR HIREDATE                    SAL       COMM     DEPTNO
      7369 SMITH      CLERK            7902 17-DEC-1980 00:00:00        800                    20
      7499 ALLEN      SALESMAN         7698 20-FEB-1981 00:00:00       1600        300         30
      7521 WARD       SALESMAN         7698 22-FEB-1981 00:00:00       1250        500         30
      7566 JONES      MANAGER          7839 02-APR-1981 00:00:00       2975                    20
      7654 MARTIN     SALESMAN         7698 28-SEP-1981 00:00:00       1250       1400         30
SQL> select * from table(pipedata(6,10));
     EMPNO ENAME      JOB               MGR HIREDATE                    SAL       COMM     DEPTNO
      7698 BLAKE      MANAGER          7839 01-MAY-1981 00:00:00       2850                    30
      7782 CLARK      MANAGER          7839 09-JUN-1981 00:00:00       2450                    10
      7788 SCOTT      ANALYST          7566 19-APR-1987 00:00:00       3000                    20
      7839 KING       PRESIDENT             17-NOV-1981 00:00:00       5000                    10
      7844 TURNER     SALESMAN         7698 08-SEP-1981 00:00:00       1500          0         30
SQL> select * from table(pipedata(11,15));
     EMPNO ENAME      JOB               MGR HIREDATE                    SAL       COMM     DEPTNO
      7876 ADAMS      CLERK            7788 23-MAY-1987 00:00:00       1100                    20
      7900 JAMES      CLERK            7698 03-DEC-1981 00:00:00        950                    30
      7902 FORD       ANALYST          7566 03-DEC-1981 00:00:00       3000                    20
      7934 MILLER     CLERK            7782 23-JAN-1982 00:00:00       1300                    10
SQL>If you are using it in PL/SQL then just populating a collection datatype and returning that will do. Though you should question why you want to pass large amounts of data around like that first.
Explain your purpose and what you are intending to do and we can recommend the best way.
{message:id=9360002}

Similar Messages

  • Time Capsule only works for one device at a time, how to make it capable to be used for multiple devices at times

    Time Capsule only works for one device at a time, how to make it capable to be used for multiple devices at times.
    Please help to set it up, thanks in advance

    You need to give more info..
    Firstly only works for what.. networking.. backup.. wireless. You need more nouns.. more adjectives... describe what you want and what fails.. then we can figure out why.
    Most likely you have bridged it when it should be in router mode..
    Most likely you are using Lion or ML which has the airport utility bridge the TC by default.
    Change it to working as a router. That might help.
    If you press reset button it will default back to router btw.
    If you are on Lion.. use a real utility. http://support.apple.com/kb/DL1547

  • How to execute function having return cursor

    hi all
    Please tell me
    How to execute function having return cursor
    regards

    CREATE OR REPLACE FUNCTION sp_get_stocks(v_price IN NUMBER)
    RETURN types.ref_cursor
    AS
    stock_cursor types.ref_cursor;
    BEGIN
    OPEN stock_cursor FOR
    SELECT ric,price,updated FROM stock_prices
    WHERE price < v_price;
    RETURN stock_cursor;
    END;
    SQL> exec :results := sp_get_stocks(20.0)
    PL/SQL procedure successfully completed.
    Message was edited by:
    chenks

  • Indexing multiple columns in multiple tables

    I have a multiple tables in which I want to search. I need to do text search that supports fuzzy logic for which I've currently set up a context index using the user_datastore. I also need to search columns such as numbers/dates/timestamps which from what I understand is not supported with the context search. I'm looking at setting up a second index of type ctxcat for this purpose - but I will need to index multiple columns in multiple tables. Is this possible?
    Can someone advise on the best way to create indexes and search when a table schema such as the following exists. I've tried to keep it simple by just giving a few example columns and tables.
    Order Table
    - Has columns related to the order details - order name (varchar2), description (varchar2), date order placed (timestamp), date order completed (date), order amount (number), customer Id
    Customer Table
    - Has columns related to the customer information - customer name, address, city, state, telephone etc (all varchar2 fields)
    Items Table
    - Has details about the items being ordered - item name (varchar2), item description (varchar2), cost (number) etc
    Order-Item Table
    - Table that maps an order to the items in that order - orderId, itemId, quantity
    Comments Table
    - Logs any comments with the customer - comment description (varchar2), call type (varchar2), comment date (timestamp)
    Currently with the Context index, I have it set up so I can search all text columns in all tables for a search term. This works fine.
    I now need to be able to do more advanced searches, where I can search for a specific text in all orders as well as orders created after a certain date or orders above a certain amount or orders with a item quantity purchase of more that 10. The text has to be searched across the all text columns in all tables. How can I achieve this with Oracle Text?

    There was a similar discussion with various ideas that may help you here:
    How can I make CONTAINS query work for a date range

  • Multiple columns and rows in MessageService

    I am attempting to create a message (via MessageService) which has multiple lines of data, and each line has multiple data columns.
    Background:  My program reads data from a web store, and creates Sales Orders in SBO.  A single run might process multiple orders.  When all orders have been entered, the program should send a (single) message to a list of recipients.  The message will have one line of data for each sales order produced.  Each line will contain two fields: the linked SBO sales order number, and the unlinked web order number.
    When the message is initially created, I'm defining the multiple columns and initializing the data lines:
    pMessageDataColumns = oMessage.MessageDataColumns
    pMessageDataColumn = pMessageDataColumns.Add()
    pMessageDataColumn.ColumnName = "SalesOrder"
    pMessageDataColumn.Link = BoYesNoEnum.tYES
    pMessageDataColumn = pMessageDataColumns.Add()
    pMessageDataColumn.ColumnName = "WebOrder"
    pMessageDataColumn.Link = BoYesNoEnum.tNO
    oLines = pMessageDataColumn.MessageDataLines()
    Later, as each Sales Order is processed, I'm attempting to inject the two data values into the message data:
    oLine = oLines.Add()
    oLine.Value = Str(pOrd.DocNum)
    oLine.Object = 17
    oLine.ObjectKey = Str(pOrd.DocEntry)
    oLine = oLines.Add()
    oLine.Value = pOrd.WebOrder
    The above code would be invoked for each Sales Order processed.  However, it generates an "Internal error (-5002) occurred" when the message is ultimately sent.
    The SDK documentation states:
    The MessageDataLine is a child data structure related to the MessageDataColumn. It contains the value of a specified cell in the Data table, which is defined by its column number (vtIndex of Item of MessageDataColumns) and row number (vtIndex of Item of MessageDataLines).
    I guess I don't understand the relationship between adding a "line" in my data display versus adding data into a "column".  It appears that the "oLines.Add()" is used to bump across the columns of the data.  If so, how do I advance to the next entire row of data in the message?
    Thanks, Dave

        Class Item
            Public ItemCode As String
            Public Dscription As String
        End Class
    Dim ItemCodes as new list( of item)
    Dim one as new item
    one.ItemCode = "ItemCode"
    one. Dscription ="Name of Item"
    itemcodes.add (one)
            Try
                Dim oCmpSvc As SAPbobsCOM.CompanyService = _ocmp.GetCompanyService()
                Dim oMsgSvc As SAPbobsCOM.MessagesService = oCmpSvc.GetBusinessService(ServiceTypes.MessagesService)
                Dim oMsg As SAPbobsCOM.Message = oMsgSvc.GetDataInterface(MessagesServiceDataInterfaces.msdiMessage)
                oMsg.Subject = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                oMsg.Text = Msg
                Dim oMsgDataColumn As SAPbobsCOM.MessageDataColumn
                If ItemCodes.Count > 0 Then
                    oMsgDataColumn = oMsg.MessageDataColumns.Add()
                    oMsgDataColumn.ColumnName = "Product / Item Code"
                    oMsgDataColumn.Link = BoYesNoEnum.tYES
                    For Each oneitem As Item In ItemCodes
                        Dim oMsgDataLine As SAPbobsCOM.MessageDataLine = oMsgDataColumn.MessageDataLines.Add()
                        oMsgDataLine.Object = "4"
                        oMsgDataLine.ObjectKey = oneitem.ItemCode
                        oMsgDataLine.Value = oneitem.Dscription
                    Next
                    oMsgDataColumn = oMsg.MessageDataColumns.Add()
                    oMsgDataColumn.ColumnName = "Description"
                    oMsgDataColumn.Link = BoYesNoEnum.tNO
                    For Each oneitem As Item In ItemCodes
                        Dim oMsgDataLine As SAPbobsCOM.MessageDataLine = oMsgDataColumn.MessageDataLines.Add()
                        oMsgDataLine.Value = oneitem.Dscription
                    Next
                End If
                        Dim oMsgRecipient As SAPbobsCOM.Recipient = oMsg.RecipientCollection.Add()
                        oMsgRecipient.UserCode = "manager"
                        oMsgRecipient.SendInternal = BoYesNoEnum.tYES
                        oMsgRecipient.SendEmail = BoYesNoEnum.tNO
                oMsgSvc.SendMessage(oMsg)
                MsgBox("SAP B1 internal Message sent...")
            Catch ex As Exception
                MsgBox("Unable to send SAP B1 internal message. Error:" + ex.Message)
            End Try
        End Sub

  • Flash cs3: how to make moving/scrolling photo menu left and right?

    http://media.moma.org/subsites/2008/miro/flashsite/index.html
    - click continue, then relative size link
    How can I do this with lash cs3: how to make moving/scrolling
    photo menu left and right?
    When you move left and right and paintings move. and when you
    click on a painting, you see the the title and it links to another
    page on the site.

    scene_mc start at x = -550... x wide is 2164 px
    now I have this and its working...
    navL_mc.addEventListener(MouseEvent.MOUSE_OVER, navL_Over);
    navL_mc.addEventListener(MouseEvent.MOUSE_OUT, navL_Out);
    function navL_Over(e:MouseEvent){
              if(scena_mc.x == 0){
                                  scena_mc.x == 0;
              else if(scena_mc.x <= -10){
                                  scena_mc.x += 10;
                                  navL_mc.addEventListener(Event.ENTER_FRAME, runL);
    function runL(e:Event):void{
              if(scena_mc.x == 0){
                                  scena_mc.x == 0;
              else if(scena_mc.x <= -10){
                                  scena_mc.x += 10;
    function navL_Out(e:MouseEvent){
              navL_mc.removeEventListener(Event.ENTER_FRAME, runL);
    navR_mc.addEventListener(MouseEvent.MOUSE_OVER, navR_Over);
    navR_mc.addEventListener(MouseEvent.MOUSE_OUT, navR_Out);
    function navR_Over(e:MouseEvent){
              if(scena_mc.x == -1164){
                                  scena_mc.x == -1164;
              else if(scena_mc.x >= -1154){
                                  scena_mc.x -= 10;
                                  navR_mc.addEventListener(Event.ENTER_FRAME, runR);
    function runR(e:Event):void{
              if(scena_mc.x == -1164){
                                  scena_mc.x == -1164;
              else if(scena_mc.x >= -1154){
                                  scena_mc.x -= 10;
    function navR_Out(e:MouseEvent){
              navR_mc.removeEventListener(Event.ENTER_FRAME, runR);

  • How to make a commentary track in iDVD and iMovie 6

    Could someone please explain how to make a commentary track using iMovie6 and iDVD? I think I will be able to import the commentary track onto the second sound track in iMovie 6 with no problem. I just can't figure out how to make it an optional track in the final DVD.

    Yes, you can put the commentary track on the second sound track in 06. You can also attach a mic and make the commentary as a recording. I will caution that you will need to depress any original sounds associated with the film so that it does not sound like a garbled mess with both tracks competing. I imagine you know how to grab the volume level line in the audio track and nudge it lower or higher?
    I also don't see any other option than including two versions of the film on the DVD. Pretty simple fix if it will fit... I would export the plain film first before adding the other audio (or you can simply uncheck one of the audio tracks while exporting to mute it).
    Terri

  • How to write Functional Spec s for Duplicate and Postal Check for ELM

    Hi Guru s
    Can any one guide me how to write functional specifications for Duplicate Check and postal Check for ELM kindly share information on this.
    Thanks & Regards,
    Prasanna

    Hello Jaya,
    I would say that there are many ways to write a FS. Maybe every big company has its own template. As it is the functional spec and not the technical one, I would say that you only need to describe what you want to see on the screen (like with mock-screenshots) or which functionality you want to have from a super-user''s point of view. All the technical details like which database table or function modules need to be investigated by the developer or technical consultant. I am currently in a SAP CRM Service in the technical role and that is the way we work here and I am fine with that. Unfortunately I am not allowed to send you an example.
    Best regards,
    Thomas Wagner

  • How can I create 25 charts on a page, each chart 2 columns and 10 rows

    I need to create a chart that has 25 tables. 5 tables in 5 columns. Each table has 2 columns and 10 rows. I know it can fit all on 1 page as I have seen it done but I can not figure out how

    I had some initial difficulty understanding your question. In Numbers, a "chart" is a graph.
    You want to create a 5 x 5 array of tables, each with two columns and 10 rows, placed on a single page.
    At the default size, each cell on a new Table is 1 inch wide and 0.2 inches high. So without displaying a title, each of your 25 charts would occupy a two inch square space.
    Butted closely together, that's a space that is 10 inches wide by 10 inches high.
    On a machine set to US localization,the default page size is US Letter, placed in Landscape orientation. Left, right and top margins are set to 0.75", bottom margin is 0.5", and there is a 0.25" height reserved for page header and page footer.
    That leaves a working space that's 9.5" wide and 6.75" high.
    Obviously, some adjustments will be needed.
    0.2" is pretty much the minimum for row height. You can go smaller by typing in a smaller height in the Table Inspector, but even with 9 point type, you begin to lose the descenders on ps and qs. Go with 0.2, then use the slider in Print view to further shrink the content.
    If you can narrow the columns significantly (to 0.75" or less), then go to Page setup and change to Portrait orientation.
    In the Sheet Inspector, decrease all margins to 0.5", and the header and footer spaces to 0. Set page orientation to Portrait.
    Now consider the Table(s). If you've opened a new, blank document, you'll have a multi column, multi row table with one header row and one header column. If you don't need the header row and header column, delete them (column A, Row 1) right away.
    Reduce the number of rows to 10 and the number of columns to 2. Select the whole table and, in the Table inspector, set the row height to 0.16" and the row width to 0.73".
    With the table still selected. press command-D four times to create four duplicate tables.
    Go View > Show Rulers, then View > Show Print View. go back to the Table Inspector and use the slider to set Content Scale to about 94%.
    Drag the still selected Table to the right margin of the page. Press command-A to Select All.
    Go Arrange > Align > Top
    Go Arrange > Distribute Space > Horizontal.
    With all five tables still selected, press command-D to duplicate the set.
    Hold down the Shift key and press the left arrow once, then the down arrow 14 times. This should bring the new row of tables into line with the previous ones, and move them down the page to just below the first row of tables. If fine adjustment is needed, use the arrow keys with the shift key released.
    Repeat three more times to add another three rows of tables.
    Adjust the spacing between tables as necessary.
    Regards,
    Barry

  • Indexing multiple columns of multiple tables

    Hi,
    I'm trying to index multiple columns of multiple tables.
    As I have seen, the way to do this is using User_Datastore.
    have the tables to share a (foreign)key? My tables have only 2 or 3 similar columns(description, tagnr...)
    I want to get the different tagnr belonging to the same description etc.
    Can I do this?
    Has anyone a Samplecode indexing multiple tables?
    Any suggestion would be helpful.
    Arsineh

    A USER_DATASTORE works like this:
    create table A
    ( id number primary key,
    textA varchar2(100));
    create table B
    ( id number primary key,
    textB varchar2(100));
    procedure foo (rid in rowid, v_document in out varchar2)
    v_textA varchar2(2000);
    v_idA number;
    v_textB varchar2(2000);
    begin
    select id, textA
    into v_idA, v_textA
    from A
    where rowid = rid;
    select textB
    into v_textB
    from B
    where id = v_idA;
    v_document := textA &#0124; &#0124; ' ' &#0124; &#0124; textB;
    end;
    create preferences for USER_DATASTORE
    create index ...
    on table A ( text) ...
    you also can build on table B
    This depends where you want the
    trigger to be build to sync the
    documents.
    null

  • How to make comnapy code defalut got 100 and 1001 in the PNP screen

    Hi Expart ,
    can u tell me my que how to make comnapy code defalut got 100 and 1001 in the PNP screen in HR reporting?
    Regards
    Razz

    Use the below code in the   INITIALIZATION   
                     INITIALIZATION                                      *
    initialization .
    " Make Default values for Company Code 2100 & 2200
      PNPBUKRS-LOW  = '2100'.
      PNPBUKRS-HIGH = '2200'.
      append PNPBUKRS.
    regards
    .....lakhan

  • How to make Nokia Suite remember the position and ...

    how to make Nokia Suite remember the position and the size i set it?
    because everytime i start it, it defaults in the middle of the screen and in the smallest possible size.
    Nokia Suite 3.3.86
    Windows Vista
    Greece Nokia X6 RM-559 v40.0.002

    Again, are you talking about genuine Nokia firmware, not any of some 3rd-party customised versions?
    For officially released firmware, you may force Nokia Suite to reinstall even if your firmware is already up to date. This feature might be missed in its GUI as its link is "hidden" in the prompt message, not on a button or highlighted with underscore. Try Nokia Suite, once the phone is connected, click the icon of Software Update on the top, then click the word "reinstall" in the prompted message.
    bbao
    * If this post helped you, please click the white Kudo star.
    * If this post has solved your issue, please click Accept as Solution.

  • Multiple sizes and multiple quantities of an item

    How do I create a shirt order form where someone can order multiple sizes and multiple quantities of an item?

    Hi,
    There’re some order templates, Shirt(Clothing) Order Form,  that might be meet your request. Or you can design a custom form according your requirement if you’re a form author or coauthor. For your case, when you design the form, you can choose the multiple choices, single choice, or other fields, etc.  And you have to enable the payment under options tab, and assign fields as a purchase fields. At the same time, you can share the web form to the form filler to make an order.
    Thanks,
    Guanshuai

  • Planning for  product using multiple bom and multiple recipe involving SOP

    Hi friends,
    The problem. Currently we have maintained single BOM and single recipe (The BOM and Recipe used for MRP) for long term planning run. The FMCG sector of Client requested to have multiple BOMs and multiple recipes in the long term planning run. I.e. The planning is done quarterly and they wanted to use different BOMs and Different recipes for each quarter. But since the existing system has configured to use a single BOM and a single recipe we have a problem to use the long term planning run with the current setups.The problem we have is in this ‘001’ planning scenario.
    appreciate if you can help me how to accommodate multiple BOMs and recepis in the long term planning run.
    thanks and regards
    om

    HI Mr. Ready,
    We create PIR though a submit Job and in this case how to mention the production version while creating PIRs . Also if I am creating PIR through MD61 how to record the version.
    Please advice.
    Thanks and Regards,
    Om

  • Partial-credit scoring in multiple response and multiple hot-spot questions

    Hello everyone,
    I'm calling on your generosity in the spirit of the holidays to help out a noob.  I would like to create matching, multiple-response and multiple-hot spot questions where the user receives credit based on the number of correct answers within the question. For example, in a matching question where there are four items; if the user gets 2 out of the four items matched correctly, I would like for him to receive 2 out of 4 points.
    I understand that Captivate doesn't support partial-credit scoring of this type, but a few posts have implied that it can be done with variables. Is there anyone who can walk me through this process, or send me to a link that will walk me through it? (I've scoured these forums and tried the Cp tutorials, to no avail.) And if it's not asking too much, please make it understandable to someone who has very little experience with variables.
    Thanks, and Merry Christmas.
    JR
    (Running CP 5 on Windows Vista)

    Hello,
    I did publish an article more specific on partial scoring, perhaps this could help you:
    Partial scores and customized feedback
    And since you are asking for more basic information, on my blog I point to some other articles to explain the meaning of variables with/without advanced actions. Feel free to have a look (there are more postings about advanced actions and links to articles over there):
    Curious about variables ?
    Unleash the power of variables with advanced actions
    Lilybiri

Maybe you are looking for

  • Want to add apps to 2nd generation ipod but it says i need to upgrade to iphone 3.0 ?

    I have an ipod touch 2nd generation. I would like to add some apps that i have on another mac products but, when i try it says to upgrade to iphone 3.0? I dont understand. when I sync it says that it is upgraded. please can anyone help?

  • How do I delete alias files on my macbook pro?

    when i go into finder and im on all my files there are files that i dragged to the trashcan and deleted but they are still there only with a blank icon now, and it doesnt let me drag them and when i click on them a message pops up saying "the alias..

  • Error while executing

    I am getting below error: STEP is :Loading Srcset0 Call sqldr org.apache.bsf.BSFException: exception from Jython: Traceback (innermost last): File "<string>", line 31, in ? File "D:\app\oraapp\product\11.1.1\Oracle_ODI_1\oracledi\client\odi\bin\..\..

  • Looking for a good media reader

    I am looking at either the SIIG 11 in 1 media reader for my express card slot or the Cables unlimited brand, My question is, the SIIG had issues in 10.4 with not allowing the MBP to sleep when installed and also XD cards would not mount does anyone k

  • MAILER-DAEMON shows as sender of spam

    Upon checking my mail queue in Server Admin, I see about 100 messages per day that seem to be sent from my Mailer daemon to spam addresses. Are these bounces from my mail server, or is my mail server spamming these addresses? And is there a need to s