How to pass multiple records to target side using xquery

Hi Everybody,
I am using xquery transformation.
Input: Source payload contains 5 variables.
Target payload contains 5 variables.
I have input with payload with multiple instance like:
<Input>
<payload1>
<a>1<a>
<b>2<b>
<c>3<c>
<d>4<d>
<e>5<e>
</payload1>
<payload1>
<a>6<a>
<b>7<b>
<c>8<c>
<d>9<d>
<e>10<e>
</payload1>
</Input>
So my requirement is to pass above records into target side,
So I am using xquery Transformation.
I have written code as follows.
(:: pragma bea:global-element-parameter parameter="$tHRecAdv1" element="ns0:THRecAdv" location="../XMLSchemas/THRecAdv.xsd" ::)
(:: pragma bea:global-element-return element="ns1:ShipmentReceiptEBO" location="../../AIAReferenceModelProject/EnterpriseObjectLibrary/Core/EBO/ShipmentReceipt/V1/ShipmentReceiptEBO.xsd" ::)
declare namespace ns2 = "http://xmlns.oracle.com/EnterpriseObjects/Core/Custom/EBO/ShipmentReceipt/V1";
declare namespace ns1 = "http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/ShipmentReceipt/V1";
declare namespace ns4 = "http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2";
declare namespace ns3 = "http://xmlns.oracle.com/EnterpriseObjects/Core/Custom/Common/V2";
declare namespace ns0 = "http://diversey.com/THRecAdv";
declare namespace xf = "http://tempuri.org/ShipmentReceiptServicesProject/XMLTransformations/THRecAdvFile_ShipmentReceiptEBO_JDE_XQuery/";
declare function xf:THRecAdvFile_ShipmentReceiptEBO_JDE_XQuery($tHRecAdv1 as element(ns0:THRecAdv))
as element(ns1:ShipmentReceiptEBO) {
for $THRecAdvFields  in $tHRecAdv1/ns0:THRecAdvFields
return
<ns1:ShipmentReceiptEBO>
<ns4:Identification>
<ns4:BusinessComponentID>{ data($THRecAdvFields/ns0:JD_WHSE_Code) }</ns4:BusinessComponentID>
<ns4:ID schemeID = "{ (data($THRecAdvFields/ns0:JD_PO_Number)) }"
schemeVersionID = "{ data($THRecAdvFields/ns0:JD_PO_Type) }">{ data($THRecAdvFields/ns0:WMS_InternalPONumber) }</ns4:ID>
<ns4:ApplicationObjectKey>
<ns4:ID>{ data($THRecAdvFields/ns0:JD_BranchPlant) }</ns4:ID>
</ns4:ApplicationObjectKey>
<ns4:Revision>
<ns4:Reason>{ data($THRecAdvFields/ns0:ReturnReceiptReasonCode) }</ns4:Reason>
</ns4:Revision>
</ns4:Identification>
<ns1:ExpectedReceiptDate>{ data($THRecAdvFields/ns0:WMS_ReceiptDate) }</ns1:ExpectedReceiptDate>
<ns4:InvoiceReference>
<ns4:InvoiceIdentification>
<ns4:ID>{ data($THRecAdvFields/ns0:JDE_SupplierInvoiceNumber) }</ns4:ID>
</ns4:InvoiceIdentification>
</ns4:InvoiceReference>
<ns1:ShipmentReceiptLine actionCode = "{ data($THRecAdvFields/ns0:ActionFlag) }">
<ns4:Identification>
<ns4:ID schemeID = "{ data($THRecAdvFields/ns0:JD_PO_LineNumber) }"
schemeVersionID = "{ data($THRecAdvFields/ns0:ExternPONumber) }">{ data($THRecAdvFields/ns0:WMS_ReceiptNumber) }</ns4:ID>
<ns4:ContextID>{ data($THRecAdvFields/ns0:WMSReceivingClerk) }</ns4:ContextID>
<ns4:ApplicationObjectKey>
<ns4:ID schemeID = "{ data($THRecAdvFields/ns0:BatchNumber) }"
schemeVersionID = "{ data($THRecAdvFields/ns0:BatchLineNumber) }">{ data($THRecAdvFields/ns0:JD_LocationCode) }</ns4:ID>
</ns4:ApplicationObjectKey>
<ns4:AlternateObjectKey>
<ns4:ID>{ data($THRecAdvFields/ns0:SupplierCode) }</ns4:ID>
<ns4:ContextID>{ data($THRecAdvFields/ns0:LineNumber_Or_SequenceNumber) }</ns4:ContextID>
</ns4:AlternateObjectKey>
<ns4:Revision>
<ns4:Label>{ data($THRecAdvFields/ns0:Records) }</ns4:Label>
</ns4:Revision>
</ns4:Identification>
<ns1:ReceivedQuantity unitCode = "{ data($THRecAdvFields/ns0:ReceiptUOM) }">{ data($THRecAdvFields/ns0:UnitReceipt) }</ns1:ReceivedQuantity>
<ns1:SourceDocumentTypeCode>{ data($THRecAdvFields/ns0:SKU_Code) }</ns1:SourceDocumentTypeCode>
<ns1:DestinationTypeCode>{ data($THRecAdvFields/ns0:DestinationProcessFlag) }</ns1:DestinationTypeCode>
<ns1:Comment>{ data($THRecAdvFields/ns0:Remarks) }</ns1:Comment>
<ns4:Status>
<ns4:Code>{ data($THRecAdvFields/ns0:ProcessSourceFlag) }</ns4:Code>
<ns4:EffectiveDateTime>{ data($THRecAdvFields/ns0:ADDDATE) }</ns4:EffectiveDateTime>
</ns4:Status>
<ns1:ShipmentReceiptTransaction>
<ns1:ShipmentReceiptTransactionLot>
<ns1:ShipmentReceiptItemLotReference>
<ns1:ExpirationDate>{ data($THRecAdvFields/ns0:ExpiryDate) }</ns1:ExpirationDate>
<ns1:CreationDateTime>{ data($THRecAdvFields/ns0:ProductionDate) }</ns1:CreationDateTime>
</ns1:ShipmentReceiptItemLotReference>
</ns1:ShipmentReceiptTransactionLot>
</ns1:ShipmentReceiptTransaction>
</ns1:ShipmentReceiptLine>
</ns1:ShipmentReceiptEBO>
declare variable $tHRecAdv1 as element(ns0:THRecAdv) external;
xf:THRecAdvFile_ShipmentReceiptEBO_JDE_XQuery($tHRecAdv1)
But while importing this code to OSB,and tested it ,
With 1 payload it successfully shows the data in Target side,
But while testing with multiple line items,i am getting an error as follows.
*Error executing the XQuery transformation: line 14, column 17: {err}FORG0005: expected exactly one item, got 2+ items*
So please provide me the steps how to pass multiple records to target side using xquery.
Regards,
Jyoti Nayak

Hi Jyoti Nayak,
You have to do something like the example bellow, you can not just repeat the inner element, you will need an outer "container" tag. So you will have to change the target element of your xq transformation.
declare function xf:setToList($set1 as element(ns0:set))
as element(ns0:list) {
<ns0:list>
for $pair in $set1/ns0:pair
return
<ns0:entry>
<ns0:key>{ data($pair/ns0:key) }</ns0:key>
<ns0:value>{ data($pair/ns0:value) }</ns0:value>
</ns0:entry>
</ns0:list>
Cheers,
Vlad
Give points - it is good etiquette to reward an answerer points (5 - helpful; 10 - correct) for their post if they answer your question. If you think this is helpful, please consider giving points

Similar Messages

  • How to pass multiple records to stored procedure??

    Hi,
    Can a web application call stored procedure (could be JDBC call)with resultset as it's input parameter? I'm sure there has to be some way to deal with this and I will appreciate your feedback. The web page has multiple records in tabular format and submit should save each record. Is it possible to pass all the records at once through resultset instead of calling stored procedure for each one?
    I'm thinking to use cursor variable as a input parameter of a stored procedure. But I'm not sure whether stored procedure can open/fetch this cursor variable into record structure. Here's the sample example of cursor variable definition.
    TYPE EmpRecTyp IS RECORD (
    emp_id NUMBER(4),
    emp_name VARCHAR2(10),
    job_title VARCHAR2(9),
    dept_name VARCHAR2(14),
    dept_loc VARCHAR2(13));
    TYPE EmpCurTyp IS REF CURSOR RETURN EmpRecTyp;
    PROCEDURE save_staff (emp_cv IN EmpCurTyp);
    Thanks for your help.
    Hemal

    You can't pass in a result set, but you can make each parameter a PL/SQL table.
    Since you also can't pass in a PL/SQL table of records, I typically create a parameter for each "field", with each parameter containing one or more elements. You can then use bulk binding to process the tables in one statement.

  • How to update multiple records in the table using POST parameters:

    i got this idea from this website:http://www.karlrixon.co.uk/articles/sql/update-multiple-rows-with-different-values-and-a-s ingle-sql-query/comment-page-1/#comment-5409. Basically i am trying to update all the status in the results page, and by adding $i in front of the id in the text fields, and checkboxes, i can name the different inputs with different names:
    The image of how it takes the inputs is shown here:http://forums.adobe.com/thread/709034?tstart=0
    I tried this but got this error:Parse error: syntax error, unexpected T_IF, expecting ')' in C:\xampp\htdocs\Database Query\results_change.php on line 51
    will not work in the update code section:
    for($i=0;$i<$maxRows_Recordset1;$i++)
    {$a=sprintf("%s",GetSQLValueString($_POST['changeid $i'],"int"));
    $b=sprintf("%s",GetSQLValueString($_POST['checkbox $i'],"text"));
    $display_order .= array(
        $a => $b
    if($i<$maxRows_Recordset1-1)
    $ids = implode(',', array_keys($display_order));
    $updateSQL = "UPDATE `change` SET Status = CASE Change_id ";
    foreach ($display_order as $a => $b) {
        $updateSQL .= sprintf("WHEN %d THEN %s ", $a,$b);
    $updateSQL .= sprintf("END WHERE `Change_id` IN ($ids)");

    Hi,
    Try
    BEGIN
      FOR i IN 1..APEX_APPLICATION.G_F03.COUNT LOOP
        UPDATE xx_test
        SET checkbox = 'Y'
        WHERE rec_no = APEX_APPLICATION.G_F03(i);
      END LOOP;
    END;Code loops all checked checkbox. You do not need commit on page process.
    Regards,
    Jari
    http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0

  • How to update multiple records in a table using procedure?

    Dear All,
    1 am using 11.1.2.1.0
    my question is i have a table like
    emp id(primary key), empname,location
    1                             damby      blore
    2                             rocky       kormangala
    3                              biswa     india
    my question  is i need to write one procure that at a time i can update empname and location(wat the value are there in empname and location i  need to change at a time).
    thanks
    Damby

    Hi, Damby,
    That sounds like what the UPDATE statement does, exactly.  Just use an UPDATE statement to change any number of columns in existing rows.  You don't need a procedure, but, if you're using a procedure for some other reason, you can do the UPDATE in the procedure.  UPDATE works the same in SQL or PL/SQL.
    Sometimes MERGE is more convenient than UPDATE.  Like UPDATE, it can change any number of columns, either in SQL or PL/SQL.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
    Explain, using specific examples, how you get those results from that data.
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How to update multiple records in custom table using checkbox in APEX 4.1?

    Hi,
    I have a SQL report which brings up all the data records using the following query.
    select
    "REC_NO" AS hidden_rec_no,
    "REC_NO",
    APEX_ITEM.CHECKBOX (3,rec_no) AS edit,
    "MEETING_TYPE",
    "PAGE_NO",
    "CHECKBOX"
    from "XX_TEST" m
    WHERE page_no = :p_page_no
    Out of all records, any records which are checked, I only want to update their flag to 'Y' on the database column "Checkbox". For this, I have a SUBMIT button on the report region. The processing code on pressing the SUBMIT button is:
    DECLARE.
    l_row NUMBER := 1;
    BEGIN
    FOR i IN 1..APEX_APPLICATION.G_F03.COUNT
    LOOP
    FOR j IN l_row..APEX_APPLICATION.G_F01.COUNT
    LOOP
    IF APEX_APPLICATION.G_F01(j) = APEX_APPLICATION.G_F03(i) THEN
    UPDATE xx_test
    SET checkbox = 'Y', -- APEX_APPLICATION.G_F03(j)
    WHERE rec_no = APEX_APPLICATION.G_F03(i);
    l_row := j + 1;
    EXIT;
    END IF;
    END LOOP;
    END LOOP;
    COMMIT;
    END;
    However, that is not happening. Please help me with this. Any solutions/suggestions are most welcome.
    Regards.

    Hi,
    Try
    BEGIN
      FOR i IN 1..APEX_APPLICATION.G_F03.COUNT LOOP
        UPDATE xx_test
        SET checkbox = 'Y'
        WHERE rec_no = APEX_APPLICATION.G_F03(i);
      END LOOP;
    END;Code loops all checked checkbox. You do not need commit on page process.
    Regards,
    Jari
    http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0

  • How to Pass multiple parameter into single store procedure

    How to Pass multiple parameter into single store procedure
    like a one to many relationship.
    it is possible then reply me immediatly

    you mean like this .....
    CREATE OR REPLACE procedure display_me(in_param in varchar2,in_default in varchar2 := 'Default') is
    BEGIN
    DBMS_OUTPUT.put_line ('Values is .....'||in_param || '....'||in_default);
    END display_me;
    CREATE OR REPLACE procedure display_me_2 as
    cnt integer :=0;
    BEGIN
    For c1_rec In (SELECT empno,deptno FROM test_emp) Loop
         display_me(in_param => c1_rec.empno);
         cnt := cnt+1;
         end loop;
         DBMS_OUTPUT.put_line('Total record count is ....'||cnt);
    END display_me_2;
    SQL > exec display_me_2
    Values is .....9999....Default
    Values is .....4567....Default
    Values is .....2345....Default
    Values is .....7369....Default
    Values is .....7499....Default
    Values is .....7521....Default
    Values is .....7566....Default
    Values is .....7654....Default
    Values is .....7698....Default
    Values is .....7782....Default
    Values is .....7788....Default
    Values is .....7839....Default
    Values is .....7844....Default
    Values is .....7876....Default
    Values is .....7900....Default
    Values is .....7902....Default
    Values is .....7934....Default
    Values is .....1234....Default
    Total record count is ....18

  • How to pass multiple values from workbook to planning function ?

    Hi,
    I have created Planning function in Modeler and it has one parameter(Variable represents = Multiple single values).
    When executing the planning function by create planning seq. in the web template : I see value of variable store data like ...
        A.) input one value -> V1
        B.) input three values -> V1;V2;V3
    This function execute completely in web.
    However, I want to use the planning function in workbook(Excel).
    The value of variable can't input V1;V2;V3... I don't know how to pass multiple values from workbook to parameter(Multiple single values type) in planning function ?
    thank you.

    Hi,
    Please see the attached how to document (page no 16).
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0881371-78a1-2910-f0b8-af3e184929be">how to</a>
    Hope this was helpful
    thanks

  • How to get multiple records using fn-bea:execute-sql()

    Hi,
    I created Proxy service(ALSB3.0) to get records from DB table. I have used Xquery function(fn-bea:execute-sql()). Using simple SQL query I got single record, but my table having multiple records. Please suggest how to get multiple records using fn-bea:execute-sql() and how to assign them in ALSB variable.
    Regards,
    Nagaraju
    Edited by: user10373980 on Sep 29, 2008 6:11 AM

    Hi,
    Am facing the same issue stated above that I couldnt get all the records in the table that am querying in the Proxyservice.
    For example:
    fn-bea:execute-sql('EsbDataSource', 'student', 'select Name from StudentList' ) is the query that am using to fetch the records from the table called StudentList which contains more than one records like
    Id Name
    01 XXX
    02 YYY
    03 ZZZ
    I tried to assign the result of the above query in a variable and while trying to log the variable, I can see the below
    <student>
    <Name>XXX</Name>
    </student>
    I want to have all the records from my table in xml format but it's not coming up. I get the value only from the first row of my table.
    Please suggest.
    regards,
    Venkat

  • How to select multiple records from a TREE in the table

    HI,
    I have a tree structure which is in the table.When I open the node of the tree,all the subnodes are coming as one-one records in the table.I want to slect multiple record from this table.I applied onLeadSelect for this table,I can select only 1 record from the table.
    Can any one plz suggest me how to select multiple records from the table so that I can get all the data of those selected record.
    Regards
    -Sandip

    Rashmi/Kukku,
    First of all, Thanks for your help!
    Is there any other way in which we can access tables other than using BAPIs or RFCs?
    In my case, there is a table structure which has to be updated with values after validating a key. i don't think there is any RFC available now. do i need to create bapi/rfc for that?
    Krishna Murthy

  • How to insert multiple records in a single query

    Dear all,
    Can you please tell
    how to insert multiple records in a single query ??

    INSERT INTO table_name (column_1, column_2) VALUES ('value_A', 'value_B')OR
    INSERT INTO table_name
    (column_1, column_2)
    SELECT 'value_A', 'value_B' FROM DUAL
    UNION ALL
    SELECT 'value_C', 'value_D' FROM DUAL
    ;Edited by: Benton on Nov 9, 2010 1:59 PM

  • How to send multiple records in file2file and file2db or all scenarios//

    I'm able to send single record for file2file and file2db,
    how to send multiple records in file2file and file2db or all scenarios//
    what should add or make changes for dis.

    1 put Occurance 1 to Unbounded in data type of IR
    2 In the test tag of message mappings in IR,select one node and use "duplicate subtree" in its context menu
    After that,you can download the test data in XML format with the button "save document source"
    for example:
      <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:ZFileDemo xmlns:ns0="http://hand-china.com/mm/po_01">
    - <Item>
      <ItemNo>1</ItemNo>
      <Matnr>2</Matnr>
      <Text>3</Text>
      </Item>
    - <Item>
      <ItemNo>4</ItemNo>
      <Matnr>5</Matnr>
      <Text>6</Text>
      </Item>
      </ns0:ZFileDemo>

  • How to Pass Multiple Parameters To ReportReuest Method in Oracle  BI 11g

    Hi,
    Am integrate Oracle BI Publisher 11g via Web Services in Oracle Forms,For that am developing code in PublicReportServiceClient Class. This worked properly with out passing parameter to the report. so how to pass parameters to the report . If Report is requried some Parameters to generate report.
    If any one knows about How to Passing Multiple Parameters to ReportRequest Methos in Oracle 11g. Pls help me.
    Am trying with the below code for PassParameters to ReportReuest Method in Oracle BI 11g. But by using this code am able to pass only one parameter to the Report, not for multiple Parameter Passing.
    ArrayOfParamNameValue PnameValue=new ArrayOfParamNameValue();
    ParamNameValue Namevalue=new ParamNameValue();
    Namevalue.setName("P_SNO"):
    ArrayOfString aos=new ArrayOfString();
    aos.getItem().add("2");
    Namevalue.setValues(aos);
    PnameValue.getItem().add(Namevalue);
    ReportRequest RepReq = new ReportRequest();
    RepReq.setParmeterNameValues(PnameValue);
    Following method  callRunReport() with an array of parameters used in Oracle Bi 10g,To pass multiple report parameters to ReportRequest method.
    public void callRunReport (String reportPath, String[] paramName, String[] paramValue, Stringusername, String password, String format, String template, String outFile)
    try {
    bip_webservice.proxy.PublicReportServiceClient myPort =new bip_webservice.proxy.PublicReportServiceClient();
    // Calling runReport
    ReportRequest repRequest = new ReportRequest();
    repRequest.setReportAbsolutePath(reportPath);
    repRequest.setAttributeTemplate(template);
    repRequest.setAttributeFormat(format);
    repRequest.setAttributeLocale(“en-US”);
    repRequest.setSizeOfDataChunkDownload(-1);
    if (paramName != null)
    ParamNameValue[] paramNameValue = new ParamNameValue[paramName.length];
    String[] values = null;
    for (int i=0; i<paramName.length; i++)
    paramNameValue[i] = new ParamNameValue();
    paramNameValue.setName(paramName[i]);
    values = new String[1];
    values[0] = paramValue[i];
    paramNameValue[i].setValues(values);
    repRequest.setParameterNameValues(paramNameValue);

    Ramani_vadakadu wrote:
    window.open("http://hq-orapp-03.kuf.com:9704/xmlpserver/~weblogic/kufpec/BTA/KUF_CONF_ITINUD.xdo?_xpf=&_xpt=1&_xdo=%2F~weblogic%2Fkuf%2FBTA%2FKUF_CONF_ITINUD.xdo&_xmode=&_paramsP_BTM_ID="+parseInt(document.getElementById('P3_BTA_ID').value)+"&_xt=KUF_CONF_ITINUD&_xf=pdf&_xautorun=true&id=weblogic&passwd=kuf2011","_blank");
    the above code we are using apex JS to BI publisher calling for report as PDF
    i don't know exactly where your parameters , did you customize my link to multiple parameters
    'http://192.168.0.57:8889/reports/rwservlet?userid=retail/1@xe&destype=cache&desformat=PDF&paramform=no&report=item_cost&P_BATCH_NO='+$v('P138_BATCH_NO'); 

  • How to show multiple records in JDeveloper automatically

    Hi, you guys,
    May I ask you how to show multiple records, say consecutive three records, of a View object in JDeveloper?
    I know that we can just drag and drop a view object as a child (Table) of a scrollPane.
    Are there any other approaches?
    Thanks a lot for your time.
    damon

    Thanks for your reply.
    You are right.
    Table binding is the best solution for that.
    But in my mind, a record in a table is always shown in one row (or one line), am I right?
    If so, it is not convient to show records with multitple columns.
    Let's say, there are 20 columns to show for each record. Then we should display a record in, say 3 lines.
    How can we do that?
    Are there any suggestions?
    I am thinking that maybe I can use secondary row set iterators for that since we can create two or more row set iterators for the same view object.
    Assume I want to show three consecutive records. I can use attribute binding to show the current record in three lines by dragging attributes one by one from Data Control Palette to Design Window as Child | TextField;
    But I do not know how to use a secondary row set iterator for the next record. Where shall I create a secondary row set ietrator such that I can use it to create and synchronize the bindings.
    Thanks a lot
    Damon
    Message was edited by:
    user599641

  • How to Save Multiple Records In Data Block

    Hi All,
    I Have Two Blocks --> Control Block,Database Block
    Please Any Idea How to Save Multiple Records In Data Block when User changed Data in Control Block.
    Thanks For Your Help
    Sa

    Now i have to use each record of control block(ctl_blk) as where condition in data base block(dat_blk)and display 10 records from database table.>
    Do you want this coordination to be automatic/synchronized or only when the user clicks a button or something else to signal the coordination? Your answer here will dicate which trigger to put your code in.
    As to the coordination part, as the user selects a record in the Control Block (CB), you will need to take the Key information and modify the Data Block's (DB) "DEFAULT_WHER E" block property. The logical place to put this code is the CB When-New-Record-Instance (WNRI) trigger. You code will look something like the following:
    /* Sample WNRI trigger */
    /* This sample assumes you do not have a default value in the BLOCK WHER E property */
    DECLARE
       v_tmp_dw    VARCHAR2(250);
    BEGIN
       v_tmp_dw := ' DB_Key_Column1 = '||:CONTROL.Key_Column1||' AND DB_Key_Column2 = '||:CONTROL.Key_Column_2;
       Set_Block_Property('DATA_BLOCK', DEFAULT_WHER E, v_tmp_df);
       /* If you want auto coordination to occur, do the following */
       Go_Block('DATA_BLOCK');
       Execute_Query;
       /* Now, return to the Control Block */
       Go_Block('CONTROL_BLOCK');
    END;
    The Control block items are assigned with values in Form level (Key_exeqry).If your CD is populated from a single table, it would be better to create a Master - Detail relationship (as Abdetu) describes.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • How to concatenate multiple records into one

    Hi everybody:
    I want to know if exist some way to concat multiple records into one without using cursors. For example, I have a table named "Authors" like this:
    Lan|Author
    English|Ernest Hemingway
    Spanish|Octavio Paz
    Spanish|Mario Vargas Llosa
    English|Sinclair Lewis
    Spanish|Gabriel García Márquez
    And I want to get this:
    Author
    Octavio Paz, Mario Vargas Llosa, Gabriel García Márquez
    I have worked with SQL Server and I can do something like this:
    CREATE FUNCTION dbo.MyConcat (@lan varchar(10))
    RETURNS varchar(5000) AS
    BEGIN
    declare @retvalue varchar(5000)
    set @retvalue=''
    select @retvalue = @retvalue + Author +',' from Authors where lan = @lan
    return substring(@retvalue,1,len(@retvalue)-1)
    END
    ie, do not use cursors to concatenate records. However, with ORACLE, I have to do someting like this.
    FUNCTION MyConcat(P_Lan IN VARCHAR2) RETURN VARCHAR2 IS
    v_ret VARCHAR2(4000);
    v_element VARCHAR2(4000);
    v_cursor sys_refcursor;
    BEGIN
    OPEN v_cursor FOR SELECT Author FROM Authors where Lan = P_Lan
    LOOP
    FETCH v_cursor INTO v_elemento;
    EXIT WHEN v_cursor%NOTFOUND;
    IF v_ret IS NULL THEN
    v_ret := v_element;
    ELSE
    v_ret := v_ret || ', ' || v_element;
    END IF;
    END LOOP;
    RETURN v_ret;
    END;
    Exist some other way to do this?
    Best Regards
    Jack

    Tks both for answer... I forgot to mention that I am using Oracle 10g. I read about LISTAGG() but this function is available for Oracle 11g release 2.
    I wil read about the other techniques than Hoek mention
    Best Regards.
    Jack

Maybe you are looking for

  • Data Services 4.0 - Batch Job - Export Execution Command - Error

    Hi, I'm new to Data Services and tried to get started with this "how to": http://wiki.sdn.sap.com/wiki/display/BOBJ/HowToUseBusinessObjectsDataServicesinSAPBIstagingprocess Just that I used BW 7.0 instead of BI. But I got stuck at the Export Executio

  • Connection timeout when running web service

    I'm running a desktop application which call an a web service every 10 minutes. Every few calls to this web service it fails. (for example: 4 calls to ws works fine but fifth call failed) When executing the application on: windows xp professional (ph

  • IPhone doesn't recognize some keys

    I bought a 3G (not 3GS) iPhone a couple of weeks ago. After a few days, it stopped recognizing the O and 9 keys on vertical (portrait) keyboards. That problem went away after a couple of days. Now, about a week later, the probelm has returned. Apple

  • Using UITouch as key in NSMutableDictionary?

    I'm storing some information about touches, and am using the fact that the touch objects are the same ones for the same touch. Now I wanted to make this more efficient by using the UITouch as the key in a NSMutableDictionary for faster lookup - but t

  • AdbeRdr710_it_IT.exe problem with RUNAS

    Hi, I'm trying to update Acrobat Reader 7.0.9 to version 7.1.0 on Windows XP SP2. For deploying reason i need to impersonate Administrator before launching AdbeRdr710_it_IT.exe, but i get the error code -529697949. If I log on client with Administrat