How to return multiple tags (based on different checks) in a for loop?

Hi,
I'm trying to return multiple elements, based on different checks that are done in the XQuery, within a for loop. But I'm getting syntax errors at any attempt to do this.
This is the structure of what I'm trying to do:
          <ActionList>
     <ACtion>
let $total := count(...)
for $x in (1 to $total)
     let $lineItems := $someVariable/*:Items/*:Item[$x]
     return
          if(...)
                    <Qty1>{...}</Qty1>
                         else     ""
                    if(...)
                    <Qty2>{...}</Qty2>
                         else ""
               {                                       if(...)
          <Qty3>{...}</Qty3>
                         else ""
          <LinesList>
                         let $totalcount(...)
                         for $y in (1 to $totalcount(...)
                              let $DTL := $someVariable*:DTL[$y]
                         return
                         <Line>
                              <Carrier>{...}</Carrier>
                              <Path>{...}</Path>
                              <CA>{
                                   if(...)
                                        data($$someVariable/*:CA)
                                   else
                              }</CA>
                              <RE>{
                                   if(...)
                                        data($someVariable*:CA[@XX="RG"])
                                   else
                              }</RE>
                              <Time>{
                                   if(...)
                                        data($someVariable*:CA[@XX="BN"])
                                   else
                                                                 </Time>
                              </Line>
                    </LinesList>
                                             </ACtion>
                                             </ActionList>
I'm not able to return elements without having their father being returned as well, I just want to iterate over those fields and, based on that verification, decide whether they should be returned or not.
Can someone please advise?

An example anyway...
Input document ($d) :
<ns0:Items xmlns:ns0="http://my.company.org/my-namespace">
  <ns0:Item type="A">
    <ns0:Qty>2</ns0:Qty>
    <ns0:UnitPrice>10.00</ns0:UnitPrice>
    <ns0:DTL>
      <ns0:Article>ART001</ns0:Article>
      <ns0:DispatchDate>2012-01-20</ns0:DispatchDate>
      <ns0:Destination direct="1">Location1</ns0:Destination>
    </ns0:DTL>
    <ns0:DTL>
      <ns0:Article>ART002</ns0:Article>
      <ns0:DispatchDate>2012-01-21</ns0:DispatchDate>
      <ns0:Destination direct="1">Location2</ns0:Destination>
    </ns0:DTL>
  </ns0:Item>
  <ns0:Item type="B">
    <ns0:Mass>5</ns0:Mass>
    <ns0:Unit>kg</ns0:Unit>
    <ns0:DTL>
      <ns0:Article>ART003</ns0:Article>
      <ns0:DispatchDate>2012-01-20</ns0:DispatchDate>
      <ns0:Destination direct="1">Location3</ns0:Destination>
    </ns0:DTL>
    <ns0:DTL>
      <ns0:Article>ART004</ns0:Article>
      <ns0:DispatchDate>2012-01-21</ns0:DispatchDate>
      <ns0:Destination direct="1">Location4</ns0:Destination>
    </ns0:DTL>
    <ns0:DTL>
      <ns0:Article>ART005</ns0:Article>
      <ns0:DispatchDate>2012-01-22</ns0:DispatchDate>
      <ns0:Destination direct="2">Location5</ns0:Destination>
    </ns0:DTL>
  </ns0:Item>
</ns0:Items>XQuery :
declare namespace ns0 = "http://my.company.org/my-namespace";
<DispatchInfo>
  for $i in $d/ns0:Items/ns0:Item
  return
  <Parcel>
    if ($i/@type = "A")
      then <Amount>{xs:decimal($i/ns0:Qty * $i/ns0:UnitPrice)}</Amount>
      else <Weight>{concat($i/ns0:Mass, " ", $i/ns0:Unit)}</Weight>
  , for $j in $i/ns0:DTL
    return
    <Article>
      <Num>{data($j/ns0:Article)}</Num>
    , <Dt>{data($j/ns0:DispatchDate)}</Dt>
    , if ($j/ns0:Destination/@direct = "1")
        then <Dest>{data($j/ns0:Destination)}</Dest>
        else ()
    </Article>                 
  </Parcel>
</DispatchInfo>Output :
<DispatchInfo>
  <Parcel>
    <Amount>20</Amount>
    <Article>
      <Num>ART001</Num>
      <Dt>2012-01-20</Dt>
      <Dest>Location1</Dest>
    </Article>
    <Article>
      <Num>ART002</Num>
      <Dt>2012-01-21</Dt>
      <Dest>Location2</Dest>
    </Article>
  </Parcel>
  <Parcel>
    <Weight>5 kg</Weight>
    <Article>
      <Num>ART003</Num>
      <Dt>2012-01-20</Dt>
      <Dest>Location3</Dest>
    </Article>
    <Article>
      <Num>ART004</Num>
      <Dt>2012-01-21</Dt>
      <Dest>Location4</Dest>
    </Article>
    <Article>
      <Num>ART005</Num>
      <Dt>2012-01-22</Dt>
    </Article>
  </Parcel>
</DispatchInfo>

Similar Messages

  • [UIX] How To: Return multiple values from a LOV

    Hi gang
    I've been receiving a number of queries via email on how to return multiple items from a LOV using UIX thanks to earlier posts of mine on OTN. I'm unfortunately aware my previous posts on this are not that clear thanks to the nature of the forums Q&A type approach. So I thought I'd write one clear post, and then direct any queries to it from now on to save me time.
    Following is my solution to this problem. Please note it's just one method of many in skinning a cat. It's my understanding via chatting to Oracle employees that LOVs are to be changed in a future release of JDeveloper to be more like Oracle Forms LOVs, so my skinning skills may be rather bloody & crude very soon (already?).
    I'll base my example on the hr schema supplied with the standard RDBMS install.
    Say we have an UIX input-form screen to modify an employees record. The employees record has a department_id field and a fk to the departments table. Our requirement is to build a LOV for the department_id field such that we can link the employees record to any department_id in the database. In turn we want the department_name shown on the employees input form, so this must be returned via the LOV too.
    To meet this requirement follow these steps:
    1) In your ADF BC model project, create 2 EOs for employees and departments.
    2) Also in your model, create 2 VOs for the same EOs.
    3) Open your employees VO and create a new attribute DepartmentName. Check “selected in query”. In expressions type “(SELECT dept.department_name FROM departments dept WHERE dept.department_id = employees.department_id)”. Check Updateable “always”.
    4) Create a new empty UIX page in your ViewController project called editEmployees.uix.
    5) From the data control palette, drag and drop EmployeesView1 as an input-form. Notice that the new field DepartmentName is also included in the input-form.
    6) As the DepartmentName will be populated either from querying existing employees records, or via the LOV, disable the field as the user should not have the ability to edit it.
    7) Select the DepartmentId field and delete it. In the UI Model window delete the DepartmentId binding.
    8) From the data controls palette, drag and drop the DepartmentId field as a messageLovInput onto your page. Note in your application navigator a new UIX page lovWindow0.uix (or similar) has been created for you.
    9) While the lovWindow0.uix is still in italics (before you save it), rename the file to departmentsLov.uix.
    10) Back in your editEmployees.uix page, your messageLovInput source will look like the following:
    <messageLovInput
        model="${bindings.DepartmentId}"
        id="${bindings.DepartmentId.path}"
        destination="lovWindow0.uix"/>Change it to be:
    <messageLovInput
        model="${bindings.DepartmentId}"
        id="DepartmentId"
        destination="departmentsLov.uix"
        partialRenderMode="multiple"
        partialTargets="_uixState DepartmentName"/>11) Also change your DepartmentName source to look like the following:
    <messageTextInput
        id=”DepartmentName”
        model="${bindings.DepartmentName}"
        columns="10"
        disabled="true"/>12) Open your departmentsLov.uix page.
    13) In the data control palette, drag and drop the DepartmentId field of the DepartmentView1 as a LovTable into the Results area on your page.
    14) Notice in the UI Model window that the 3 binding controls have been created for you, an iterator, a range and a binding for DepartmentId.
    15) Right click on the DepartmentsLovUIModel node in the UI Model window, then create binding, display, and finally attribute. The attribute binding editor will pop up. In the select-an-iterator drop down select the DepartmentsView1Iterator. Now select DepartmentName in the attribute list and then the ok button.
    16) Note in the UI Model you now have a new binding called DCDefaultControl. Select this, and in the property palette change the Id to DepartmentName.
    17) View the LOV page’s source, and change the lovUpdate event as follows:
    <event name="lovSelect">
        <compound>
            <set value="${bindings.DepartmentId.inputValue}" target="${sessionScope}" property="MyAppDepartmentId" />
            <set value="${bindings.DepartmentName.inputValue}" target="${sessionScope}" property="MyAppDepartmentName" />
        </compound>
    </event>18) Return to editEmployees.uix source, and modify the lovUpdate event to look as follows:
    <event name="lovUpdate">
        <compound>
            <set value="${sessionScope.MyAppDepartmentId}" target="${bindings.DepartmentId}" property="inputValue"/>
            <set value="${sessionScope.MyAppDepartmentName}" target="${bindings.DepartmentName}" property="inputValue"/>     
        </compound>
    </event>That’s it. Now when you select a value in your LOV, it will return 2 (multiple!) values.
    A couple things to note:
    1) In the messageLovInput id field we don’t use the “.path” notation. This is mechanism for returning 1 value from the LOV and is useless for us.
    2) Again in the messageLovInput we supply “_uixState” as an entry in the partialTargets.
    3) We are relying on partial-page-refresh functionality to update multiple items on the screen.
    I’m not going to take the time out to explain these 3 points, but it’s worthwhile you learning more about them, especially the last 2, as a separate exercise.
    One other useful thing to do is, in your messageLovInput, include as a last entry in the partialTargets list “MessageBox”. In turn locate the messageBox control on your page (if any), and supply an id=”MessageBox”. This will allow the LOV to place any errors raised in the MessageBox and show them to the user.
    I hope this works for you :)
    Cheers,
    CM.

    Thanks Chris,
    It took me some time to find the information I needed, how to use return multiple values from a LOV popup window, then I found your post and all problems were solved. Its working perfectly, well, almost perfectly.
    Im always fighting with ADF-UIX, it never does the thing that I expect it to do, I guess its because I have a hard time letting go of the total control you have as a developer and let the framework take care of a few things.
    Anyway, I'm using your example to fill 5 fields at once, one of the fields being a messageChoice (a list with countries) with a LOV to a lookup table (id , country).
    I return the countryId from the popup LOV window, that works great, but it doesn't set the correct value in my messageChoice . I think its because its using the CountryId for the listbox index.
    So how can I select the correct value inside my messageChoice? Come to think of it, I dont realy think its LOV related...
    Can someone help me out out here?
    Kind regards
    Ido

  • How to return Multiple ResultSets Using Callable Statement

    hi everybody,
    while i was working with callable statements i came across a problem of how to fetch Multiple Resultsets by means of Stored Procedures written for tables in Oracle.
    If any one can help me, pls do help me with a detailed explanation, and if possible do get me a example source code too.
    khumaar

    I have a similar problem with oracle and jdbc:
    I want to send a sql query like:
    sqlQuery = "select n1, n2 from table1; select n1, n2
    from table2"
    I used a prepared statement, but when I call
    .execute(sqlQuery)
    oracle doesn't like this,
    can someone help on this?Try putting a begin/end around it. Play with the syntax first in sqlplus.
    You do realize that you MUST extract using the syntax for extracting multiple result sets correct? It will NOT work as one result set.

  • LOVs again!  How to return multiple fields to calling form

    Hi
    Newbie question, any help GREATLY appreciated :)
    Is there a simple and easy way to return more than one field from a LOV.
    I need this as I have a composite fk comprised of 2 fields, and as such need to return 2 fields from the LOV to the calling form.
    (My environment: JDeveloper 9.0.5.2 build 1618)
    CM

    Thanks, you put me on the right track here. Further investigations show the following sample provided by OTN shows how to use both the session request/response values or a JavaBean to do this:
    http://www.oracle.com/technology/sample_code/products/jdev/10g/ADF_UIX_UserInput.zip
    As such I post my solution to my original post. Hopefully it's useful to someone beside myself. I have to write up my notes anyhow so it's no fuss to submit them to the forum. I must admit I'm a newbie and slightly demented Forms programmer so such solutions aren't so obvious to me. With this in mind please include the "standard disclaimer" here, with the addition "mileage may vary" warranty.
    For these notes I've used the "HR" demo Oracle schema. In particular the tables departments and employees. As you know there is a master-detail relationship between these 2 tables, where each department may have one or more employees.
    We have the requirement on a webpage to:
    1) Provide an input-form-with-navigation to edit the employees.
    2) Display the relating department_name field, rather than just showing the department_id which is meaningless to the user. For example if the employees.department_id = 40, we wish to show the department name "Human Resources" on the employees record.
    3) Provide a LOV for the department ID field to allow the user to change the underlying department_id to a different master departments record.
    4) Update 2) given a change via 3).
    To do this do the following:
    Entity Objects
    1) Create default EO/VOs on both tables.
    2) In the employees EO, create a new field "DepartmentName" to represent the derived department name field.
    3) Set the new EO attribute's selected-in-query field.
    4) In the query-column-expression field, enter a query to derive the department name field for each record in the detail-employees-EO.
    eg. (SELECT dpt.department_name FROM departments dpt WHERE dpt.department_id = employees.department_id)
    Ensure to include the brackets.
    5) Apply the changes and accept the warning to create default data-type settings for the new attribute.
    View Object
    6) In the employees VO, include the new field DepartmentName as a selected attribute from the EO.
    7) Apply the changes and accept the warning to create default data-type settings for the new attribute.
    8) Test the model by running the ADF BC tester. Once running select the employees VO and step through the records, making sure the DepartmentName field has a value and changes appropriately according to the relating parent department_id.
    UIX input-only-form
    9) Create a new UIX web page employeesEdit.
    10) From the data-control pallete, drag in the employees VO as an input-form-with-navigation.
    11) For testing purposes it is also useful to have a create, delete, commit and rollback button, so includes these too.
    12) Within the employees VO data-control, also drag across a messageLovInput for the DepartmentId. Position it under the existing DepartmentId messageTextInput within the UIX page. We'll remove the existing messageTextInput later, but it's useful to leave it in for testing purposes initially when the LOV returns values.
    UIX LOV
    13) Navigate to the default LOV page that has just been created for you.
    14) Within the data-control pallete, expand the departments VO, select department ID then LOV-table from the drop-down, and drag this item onto the LOV page.
    15) Save your changes.
    16) Run your application. For an existing employee, invoke the department LOV and select an alternative department. Note on returning to the employees page the DepartmentID (both the messageTextInput and messageLovInput fields) are updated, but the DepartmentName is not. To do this we need to create a JavaBean to return multiple fields from the LOV to the original form.
    JavaBean
    17) Within your ViewController project, expand the ApplicationSources-View node.
    18) Select the new button, and create a standard JavaBean.
    19) Name the bean DepartmentsLov.
    20) Via the class editor, add 2 private scope fields DepartmentId and DepartmentName with String data-types, ensuring the create get/set method checkboxes are checked.
    21) Make and save your changes.
    22) From the navigator drag the newly created java file into the data-control palette.
    UIX LOV
    23) Return to the LOV webpage.
    24) Your LOV page will have a lovSelect event handler something like the following:
    <event name="lovSelect">
    <set property="inputValue"
    value="${bindings.DepartmentId.inputValue}"
    target="${data.employeesEdit.DepartmentId}"/>
    25) Change the lovSelect as follows:
    <event name="lovSelect">
    <compound>
    <set property="inputValue"
    value="${bindings.DepartmentId.inputValue}"
    target="${data.employeesEdit.DepartmentId}"/>
    <set value="${bindings.DepartmentId.inputValue}"
    property="inputValue"
    target="${bindings.JavaBeanDepartmentId}"/>
    <set value="${bindings.DepartmentName.inputValue}"
    property="inputValue"
    target="${bindings.JavaBeanDepartmentName}"/>
    </compound>
    26) Within the UI model navigator, right-click on the top node, then create-binding, input, text field.
    27) Select the AppModuleDataControl, then DepartmentView, then the DepartmentName field, and then the ok button.
    28) In the UI model select the new field, then in the structure pane rename the field to DepartmentName.
    29) Within the UI model navigator, right-click on the top node, then create-binding, data, iterator.
    30) Select the DepartmentsLovDataControl and name the new iterator DepartmentsJavaBeanIterator.
    31) Again in the UI model navigator, right-click on the top node, then create-binding, input, text field.
    32) Select the DepartmentsLovDataControl then departmentId field, then the ok button.
    33) In the UI model select the new field, then in the structure pane rename the field to JavaBeanDepartmentId.
    34) Again in the UI model navigator, right-click on the top node, then create-binding, input, text field.
    35) Select the DepartmentsLovDataControl then departmentName field, then the ok button.
    36) In the UI model select the new field, then in the structure pane rename the field to JavaBeanDepartmentName.
    UIX input-only-form
    37) Return to the main employeesEdit UIX form.
    38) Your UIX page will have a lovUpdate event handler something like the following:
    <event name="lovUpdate">
    <null/>
    39) Change the lovUpdate as follows:
    <event name="lovUpdate">
    <compound>
    <set value="${bindings.JavaBeanDepartmentId.inputValue}"
    property="inputValue"
    target="${bindings.DepartmentId}"/>
    <set value="${bindings.JavaBeanDepartmentName.inputValue}"
    property="inputValue"
    target="${bindings.DepartmentName}"/>
    </compound>
    </event>
    40) Repeat steps 29 through 36 for this page.
    41) Within the UIX page find the entries for the departmentId LOV, and the DepartmentName. They should look something like the following:
    <messageLovInput id="${bindings.DepartmentId.path}"
    model="${bindings.DepartmentId}"
    destination="lovWindow1.uix"/>
    <messageTextInput model="${bindings.DepartmentName}"
    columns="10"/>
    42) Modify these 2 entries as follows:
    <messageLovInput id="DepartmentId"
    model="${bindings.DepartmentId}"
    destination="lovWindow1.uix"
    partialRenderMode="multiple"
    partialTargets="DepartmentId DepartmentName"/>
    <messageTextInput id="DepartmentName"
    model="${bindings.DepartmentName}"
    columns="10"/>
    43) Finally delete the original DepartmentId messageTextInput field, leaving the DepartmentId messageLovInput.
    Testing
    44) Open your UIX input-only-form.
    45) Call the LOV and change the department for an existing employee record.
    46) Return to the employees page and note that the department ID and name have changed.
    47) Commit your changes.
    48) With your favourite data inspection tool (a'la Toad), check that the employee record's department ID has been appropriately saved to the database.
    <The End>
    Phew!

  • How to return multiple values from dialog popup

    hi all
    I'm using ADF 10g. I have a requirement that I have to return multiple values from a dialog.
    I have a page containing a table with a button which calls the dialog. The dialog contains a multi-select table where i want to select multiple records and add them to the table in the calling page.
    In the backing bean of the calling page, I have the returnListener method.
    I am thinking that I have to store the selected rows from dialog in an array and return that array to the returnListener...but I don't know how to go about it with the code.
    Can someone help me out with it?
    thanks

    Hi Frank,
    I'm trying to implement your suggestion but getting comfused.
    AdfFacesContext.getCurrentInstance().returnFromDialog(null, hashMap) is called in ActionListener method, from what I understood.
    ReturnListener method already calls it, so no need to call explicitly.
    Okay here's what i'm doing.
    command button launches the dialog on the calling page.
    In the dialog page, there is a button "select", which when i click, closes the dialog and returns to calling page. I put a af:returnActionListener on this button, which logically should have a corresponding ReturnListener() in the calling page backing bean.
    Now I have 3 questions:
    1. do i have to use ActionListener or ReturnListener?
    2. where do I create the hashMap? Is it in the backing bean of the dialog or in the one of calling page?
    3. how do I retrieve the keys n values from hashmap?
    please help! thanks
    This is found in the backing bean of calling page:
    package mu.gcc.dms.view.bean.backing;
    import com.sun.java.util.collections.ArrayList;
    import com.sun.java.util.collections.HashMap;
    import com.sun.java.util.collections.List;
    import java.io.IOException;
    import java.util.Map;
    import javax.faces.application.Application;
    import javax.faces.application.ViewHandler;
    import javax.faces.component.UIViewRoot;
    import javax.faces.context.FacesContext;
    import javax.faces.el.ValueBinding;
    import javax.faces.event.ActionEvent;
    import mu.gcc.dms.model.services.DMSServiceImpl;
    import mu.gcc.dms.model.views.SiteCompaniesImpl;
    import mu.gcc.dms.model.views.SiteCompaniesRowImpl;
    import mu.gcc.dms.model.views.lookup.LkpGlobalCompaniesImpl;
    import mu.gcc.util.ADFUtils;
    import mu.gcc.util.JSFUtils;
    import oracle.adf.model.BindingContext;
    import oracle.adf.model.binding.DCBindingContainer;
    import oracle.adf.model.binding.DCIteratorBinding;
    import oracle.adf.view.faces.context.AdfFacesContext;
    import oracle.adf.view.faces.event.ReturnEvent;
    import oracle.adf.view.faces.model.RowKeySet;
    import oracle.binding.AttributeBinding;
    import oracle.binding.BindingContainer;
    import oracle.binding.OperationBinding;
    import oracle.jbo.AttributeDef;
    import oracle.jbo.Key;
    import oracle.jbo.Row;
    import oracle.jbo.RowIterator;
    import oracle.jbo.RowSetIterator;
    import oracle.jbo.domain.Number;
    import oracle.jbo.server.java.util.Iterator;
    public class CompanyList {
    private BindingContainer bindings;
    private Map hashMap;
    DMSServiceImpl service =(DMSServiceImpl)ADFUtils.getDataControlApplicationModule("DMSServiceDataControl");
    SiteCompaniesImpl siteCompanyList = service.getSiteCompanies();
    LkpGlobalCompaniesImpl globalCompanyList = service.getLkpGlobalCompanies();
    public CompanyList() {
    public BindingContainer getBindings() {
    return this.bindings;
    public void setBindings(BindingContainer bindings) {
    this.bindings = bindings;
    *public void setHashMap(Map hashMap) {*
    *// hashMap = (Map)new HashMap();*
    this.hashMap = hashMap;
    *public Map getHashMap() {*
    return hashMap;
    public String searchCompanyButton_action() {
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding =
    bindings.getOperationBinding("Execute");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    return null;
    *public void addCompanyActionListener(ActionEvent actionEvent){*
    AdfFacesContext.getCurrentInstance().returnFromDialog(null, hashMap);
    public void addCompanyReturnListener(ReturnEvent returnEvent){
    //how to get hashmap from here??
    public String addCompanyButton_action() {
    return "dialog:globalLovCompanies";
    }

  • How to returns multiple data with function in varray?

    Hi!
    I have 3 rows in my table and i want the return in VARRAY, but
    in my function bottom it works for only one row of my table.
    I don't know how to have the return of values in 3 rows of my table,
    it's possible to have multiple dimension in varray? Or another way for
    having that? Because i read after in java code this result.
    Now my result are :
    RetVal(1)= 504053
    RetVal(2)= 135058
    RetVal(3)= 206734
    I want like :
    RetVal(1)= 504053 Melanie Brown California
    RetVal(2)= 135058 John Smith Boston
    RetVal(3)= 206734 Roy Smith New York
    CREATE TYPE GPDEV.EMPARRAY is VARRAY(100) OF NUMBER
    CREATE FUNCTION MyName RETURN EMPARRAY
    AS
    l_data EmpArray := EmpArray();
    CURSOR c_emp IS SELECT MyTable
    FROM MyRow
    WHERE clientnumber is not null;
    BEGIN
    FOR MyTable IN c_emp LOOP
    l_data.extend;
    l_data(l_data.count) := MyTable.MyRow
    END LOOP;
    RETURN l_data;
    END;
    Thanks in advance for your help!
    Melanie

    Here is one approach...
    CREATE TYPE testType AS OBJECT (test_letter VARCHAR2(2), test_number NUMBER);
    DECLARE
    CURSOR cAAA IS
    select 'a' test_letter, 1 test_number FROM DUAL UNION ALL
    select 'b' test_letter, 2 test_number FROM DUAL UNION ALL
    select 'c' test_letter, 3 test_number FROM DUAL;
    TYPE vArray_testType is VARRAY(100) OF testType;
    testArray vArray_testType:=vArray_testType();
    y number:=0;
    BEGIN
    dbms_output.put('Adding items to varray...');
    FOR rec in cAAA LOOP
    y:=y+1;
    testArray.extend;
    testArray(y):= testType(
    test_letter => rec.test_letter,
    test_number=> rec.test_number);
    END LOOP;
    dbms_output.put_line('Done. ');
    dbms_output.put_line('Print contents of varray...');
    LOOP EXIT WHEN y = 0;
    dbms_output.put_line(testArray(y).test_letter||' '||testArray(y).test_number);
    y := y-1;
    END LOOP;
    dbms_output.put_line('END');
    END;

  • How to return multiples values useing functions

    Hi to all,
    I am using functions to return multiple values of two rows or multiple rows.
    For example emp id = 100 and i need to return the value for this(empid) input and output of this first_name and salary.
    I am tried in this way below but got errors (ORA-00932: inconsistent datatypes: expected NUMBER got HR.EMP_TYPE)
    create or replace type emp_type as object(first_name varchar2(20),salary number);
    create or replace function f1(empid in number)
    return emp_type
    as
    emp_record emp_type;
    begin
    select first_name,salary into emp_record.first_name,emp_record.salary from employees where employee_id = empid ;
    return emp_record;
    end;
    select f1(100) from dual;

    Sql is Sql and plsql is plsql. Though we can almost use all the sql objects inside a plsql code but vice versa is not always possible. Since plsql is tightly integrated with sql , if you return a number/date/varchar2 datatype values from plsql code to sql code,there is nothing wrong .Sql acknowledges this return type and knows well about how to handle it .But plsql record is a plsql specific datatype ,oracle was not built keeping in mind the fact that people will be creating difference types of records in plsql .So if you return a plsql datatype into a sql statement (which is processed by a sql engine) ,you need to tell oracle that I have written a plsql code which is going to return a record type so that sql engine can interpret it well.
    So all you need to do is create record in sql (known as object in sql ),when you make one, the entry is going to be shown in user_types views. Now use it like any other data type. I assume that the forum link provided in the above post is the best one to understand.
    Thanks,
    Rahul

  • Get Variant Attribute Should Search for and return multiple values based on RegEx

    I am using Variants as lookup tables (see this article):
    Using Variant Attributes to Build a Dictionary or Look-up Table
    I would like to be able to use some sort of wildcard to return multiple results from the Get Variant Attribute VI (all results are of the same type, and I don't know the exact names of all the results - those two points make this idea distinct from this idea: Set/Get Variant Attribute for Multiple Attributes).
    Ideally the wildcard would be RegEx.  If it were, the means by which you specify what to return is standardized.
    In the above example, there would be some ambiguity in terms of whether or not you would want to return a result or an array of results given an input, and I doubt you could detect and assume RegEx is what the programmer desires to use.  So I think this means a new input would be required to specify whether or not the "name" input of the Get Variant Attribute VI should be interpreted as a RegEx query.
     

    Why RegEx? Why not SQL query? Why not filename wildcard matching?
    I don't see anything that makes RegEx special. For this kind of functionality, the code that you've written seems like exactly the right way to do it rather than bolting a RegEx parser or any other system into the primitives or clouding the palette with a bunch of primitives to support various search functions. I could see a primitive that takes a VI refnum that has a conpane of string in/boolean out that you would pass in to supply the filter functionality that you want for any given application, but even that I'd lean toward just letting that be a library that someone writes on top of the primitives. Yes, there is some memory reduction that can be done if it is internal to the primitives, no question about that. But there are so many variations in how to do that filtration/sorting/etc that I'm not confident that any prim would cover a sufficient use case to be worth it. I could be wrong here ... let's see what other comments come in.

  • UpdateXML : How to update EmployeeName tag based on EmployeeID value

    Hi All,
    My XMLType (EMP_DOCUMENT) field in a table stores the following simple XML structure:
    <DEPARTMENT>
         <DEPARTMENT_ID>1</DEPARTMENT_ID>
         <DEPARTMENT_NAME>Finance</DEPARTMENT_NAME>
         <EMPLOYEE>
              <EMPLOYEE_ID>1</EMPLOYEE_ID>
              <FIRST_NAME>ABC</FIRST_NAME>
              <EMAIL>ABC</EMAIL>
    </EMPLOYEE>
         <EMPLOYEE>
              <EMPLOYEE_ID>2</EMPLOYEE_ID>
              <FIRST_NAME>xyz</FIRST_NAME>
              <EMAIL>xyz</EMAIL>
    </EMPLOYEE>
         <EMPLOYEE>
              <EMPLOYEE_ID>3</EMPLOYEE_ID>
              <FIRST_NAME>zzzz</FIRST_NAME>
              <EMAIL>zzz</EMAIL>
    </EMPLOYEE>
         <EMPLOYEE>
              <EMPLOYEE_ID>4</EMPLOYEE_ID>
              <FIRST_NAME>yyyy</FIRST_NAME>
              <EMAIL>yyyy</EMAIL>
    </EMPLOYEE>
    </DEPARTMENT>
    Employee_ID is unique and Employee_Name is not unique.
    I have a requirement to update the Employee_Name tag where i have the Employee_ID and the value to be updated.I tried the following but it updates all Employee_Names instead of updating the record i want:
    UPDATE EMPLOYEE_DOCUMENTS p
    SET p.EMP_DOCUMENT = updateXML(p.EMP_DOCUMENT,
                   '/DEPARTMENT/EMPLOYEE/FIRST_NAME/text()',
              'Scott')
    WHERE DOCUMENT_ID = 1
    AND existsNode(p.EMP_DOCUMENT,'/DEPARTMENT/EMPLOYEE[EMPLOYEE_ID = 2')=1
    I can see that updateXML essentially acts as 'ReplaceXML' where one tag can be searched and replaced with the new value.But is it possible to UPDATE a tag based on other tag at the same level (like update the employee_name based on employee_id)
    Thanks,
    Srihari
    Edited by: srihari manian on Jul 15, 2009 7:19 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I believe this is what you are looking for
    WITH employee_documents AS
    (SELECT XMLTYPE('<DEPARTMENT>
    <DEPARTMENT_ID>1</DEPARTMENT_ID>
    <DEPARTMENT_NAME>Finance</DEPARTMENT_NAME>
    <EMPLOYEE>
    <EMPLOYEE_ID>1</EMPLOYEE_ID>
    <FIRST_NAME>ABC</FIRST_NAME>
    <EMAIL>ABC</EMAIL>
    </EMPLOYEE>
    <EMPLOYEE>
    <EMPLOYEE_ID>2</EMPLOYEE_ID>
    <FIRST_NAME>xyz</FIRST_NAME>
    <EMAIL>xyz</EMAIL>
    </EMPLOYEE>
    <EMPLOYEE>
    <EMPLOYEE_ID>3</EMPLOYEE_ID>
    <FIRST_NAME>zzzz</FIRST_NAME>
    <EMAIL>zzz</EMAIL>
    </EMPLOYEE>
    <EMPLOYEE>
    <EMPLOYEE_ID>4</EMPLOYEE_ID>
    <FIRST_NAME>yyyy</FIRST_NAME>
    <EMAIL>yyyy</EMAIL>
    </EMPLOYEE>
    </DEPARTMENT>') emp_document
      FROM DUAL
    SELECT updateXML(p.EMP_DOCUMENT,
    '/DEPARTMENT/EMPLOYEE[EMPLOYEE_ID = 2]/FIRST_NAME/text()',
    'Scott')
      FROM employee_documents pwhich just updates the name for employee id 2.

  • How to return multiple record with Oracle Native Web Service?

    Dear all,
    I would like to know that the oracle native web service can be able to return multiple records to client or not?
    I successfully developed the oracle native web service for returning single record but the next challenge is to develop web service in order to return multiple record (like Employees data base on each department)
    Thank and Regards,
    Zenoni

    I successfully developed the oracle native web service for returning single record but the next challenge is to develop web service in order to return multiple record (like Employees data base on each department)You could return a list (multiple values/records) in XML format (using XMLType or CLOB), or CSV, or JSON, or whatever.
    function get_employees (p_department_id in number) return clob
    as
    begin
      return 'your_xml_string_here';
    end get_employees;It would be up to the client (the caller of the web service) to extract the values from whatever format you decide upon, of course.
    - Morten
    http://ora-00001.blogspot.com

  • How to return multiple values in a single field in oracle 10g reports

    I have written a formula column using cursor for loop which returns 3 values. But whenever i am assigning the formula column as the source of a field which is inside a repeating frame the field in only showing the first value returned from the formula column. The rest two values are not shown. Please help what to do.

    User11238124 (please include your name)
    If I understand your issue, you should set the vertical elasticity of the repeating frame to 'Variable' or 'Expand'. It is likely set to 'Fixed'.
    Hope this helps,
    Monty

  • How to generat multiple invoices based on per employee/contractor/services?

    Hello Experts / Dina,
    I am in situation where customer is in business of body shopping and charges to his final customer based on individual invoice / per employee /contracor & customer services. This was happening in legacy system but after the implementation of Oracle Project costing and Oracle Project billing, customer is not able to generate invoices per employee services. Rather consolidated invoices are getting generated.
    How to achieve this functionality in oracle project billing?
    Lets take example - On Project P1 for customer ABC, 3 below employees are working on different task for 3 months.
    Now after one month employees have been billed as shown below.
    Emp 1 - 1000 USD - for 100 Hrs
    Emp 2 - 2000 USD - for 200 Hrs
    Emp 3 - 1000 USD - for 50 hrs
    Now @ end of the month when invoice is getting generated is 1 invoice including 3 lines of amount total 4000 USD. There is problem; customer wants that there should be 3 different invoices per employee shoud generated based on above mentiond 3 diff lines for customer ABC.
    I guess with oracle projects billing - You can split the invoice based on Accrue through date ( which is not possible in this case ) and agreement ( which is also not possible in this case ) and different currency ( which is again not possible in this case) - I may be wrong when saying it is not possible. plz correct me if I am wrong.
    even I guess billing extension wont work. So is there any way to achive this?
    Right now only option i am thinking is let single invoice of 4000 USD with 3 different lines should pass to AR and while priniting the invoice customer can create 3 diff prints which includes individual lines. and while applying receipts on the single invoice in the system, customer can apply the receipts to indivual lines.
    but I am not sure about AUDIT issues.. Can some one think about any AUDIT issues comes to this approch or issues with TAX rounding amount issues ?
    Infact I would like to solve this issue with the help of Oracle Projects billing and not with custom invoice print program. I guess someone from you experts can figure it out to generate muiltple invoice based on employees / suppliers / contractors / materials etc.
    A suggestion on Extension / customization / seeded functionality of Oracle Project billing on thi issue would be gr8 help.
    Please help.
    Thanks
    Edited by: oracle_samba on Jan 7, 2013 1:06 AM
    Edited by: oracle_samba on Jan 7, 2013 1:07 AM

    Hi Dina,
    First of all thanks for your update :-) Your solution looks much promising.
    I thought of using billing extension but rejected on the ground that I would end up in generating events based on employee for their corsponding billig amounts so finally generating a consolidated invoice only in One GDI run. But what i was missing was pre-processing extension and running the extention in loop based on employee count.
    I am fully sure business would not have any issues of auto approving and releasing invoice upon generation. But my question is "is it possible to just approve the invoice & not release it using auto approve and release extension?" The reason is I think when GDI runs it only deletes Unapproved invoice & spare Approve invoices. - So please suggest.
    Also please validate my understanding about your solution with an existing example -
    As with the current example, there are 3 EMP presents so need to run GDI 3 times and develop pre-processing ext in a such a way that at each time it will put on hold on all the billable items except EMP1, and EMP2 and EMP3 on each consecutive run respectivly. And ensure that Auto Approve and release extension should be used in order to avoid overriding previously generated invoice? Am I right ?
    Many Many thanks for solution !!!
    Regards,
    :-)

  • How to return multiple values from a getProperty method

    Hi All,
    Even though I understand that getPropprty can return only one value. I just have a doubt. Is it possible to use a getProperty method of a bean like
    public String getemp_Info(){
    return emp_Id;
    return emp_Name;
    }also can any one explain me where and how to use private variables and public variables in a bean.
    R.Ramesh.

    I already have it I just wanted to know that is there any usage like the one I asked, anyway thanks for your suggestion.
    I have already used another getProperty method as balusc quoted.

  • How to store multiple counts based on creation date

    Hi,
    I want to retrieve the count of number of risk  for each date and render it on line graph. I am retrieving data from sharepoint list where the number of risk counts increase with its creation and decreases after it is closure which maintained in another
    column. Like if a risk is created on 02/02/2015 and closes on 03/03/2015 and an another risk is created on 17/02/2015  and closes on 14/03/2015. Then the count of the risk from 02/02/2015 to 16/02/2015 is 1 and from 17/02/2015 to 03/03/2015 is 2  and
    then again till 14/03/2015 is 1. I want to retrieve the count based on the dates rendered dynamically on X-axis that is from current date back to past 24 days. I tried to create two datasets with one storing the risks after being queried based on creation
    date and closure date and retrieving the count from Graph Y values but it is returning me count 0.
    Please help.
    Thanks in advance. 

    Hi,
    I want to retrieve the count of number of risk  for each date and render it on line graph. I am retrieving data from sharepoint list where the number of risk counts increase with its creation and decreases after it is closure which maintained in another
    column. Like if a risk is created on 02/02/2015 and closes on 03/03/2015 and an another risk is created on 17/02/2015  and closes on 14/03/2015. Then the count of the risk from 02/02/2015 to 16/02/2015 is 1 and from 17/02/2015 to 03/03/2015 is 2  and
    then again till 14/03/2015 is 1. I want to retrieve the count based on the dates rendered dynamically on X-axis that is from current date back to past 24 days. I tried to create two datasets with one storing the risks after being queried based on creation
    date and closure date and retrieving the count from Graph Y values but it is returning me count 0.
    Please help.
    Thanks in advance. 

  • How to unify multiple iPhoto libraries from different Mac OS versions?

    I am pretty good with the Mac itself and have been a long time user. I knew full well acumulating multiple iphoto libraries in older backups (intead of building up on one) was not a great idea but for several reasons I have had to live that way. Now is the time to clean it all up once and for all and I need some wisdom;
    -I got my external drive as my new iphoto library now. It's being used, there are already albums in it and it's ready to accept older libraries.
    -What I want is that the older libraries (about 10 of them from different Mac OS versions) to show up in the new external drive as they looked in iphot back then. As albums in other words.
    -I do not want them imported in a single folder that's full of photos.
    Any help is much appreciated,
    Cheers.
    M

    If you imported a previous iphoto library into your new one, it created a folder inside the iphoto called "imported".
    That was the problem. One should never import one library into another.  Only iPhoto 6 libraries and earlier can be imported into a library now.  With the introduction of iPhoto 7 the library was changed from a folder to a package which can't be imported by the current iPhoto version.
    To use an older library with a new iPhoto version one just opens that library with iPhoto and lets iPhoto update it as necessary.  No importing necessary.
    Also you can use the paid verson of  iPhoto Library Manager  to merge those additional libraries into your current working library (be sure to have a current backup of your current library before merging).  What will be included are albums, Events, keywords, titles, descriptions, places.  Books, slideshows, calendars in the other libraries will be copied over as just albums.
    OT

Maybe you are looking for

  • How to develop a single form for multiple Layouts in Adobe

    Hi experts, I have Developed an AdobeForm in Letter Layout. Is there any settings in ADS/Layout in SFP, for giving print in both Letter and A4 Pages without developing new Page Layout? We are facing allignment issues, if print is given in A4. Thanks

  • How to download files in jsp code {through save dialog}

    can you help me to download files in jsp code {through save dialog} i use the following code but it saves the jsp page instead of the downloaded file but with the name of the wanted file to be downloaded response.setHeader("Pragma", "public"); respon

  • How to organize photos in iPhoto on Mac?

    I always had my photos on my mac go in order January 2001 Feb 2001 January 2012, but after importing photos from my phone. My photos don't go in order. November 2012-January 2013-December 2012. It really bugs me. Help please.

  • How can I read from a file line by line?

    Hi! Could someone post some code or explain how can I read from a file, and want I to read a line each time. How can I go to line number N? Thanks

  • Adjusting the image denisty

    I have had this issue a few times on Photoshop. When Opening a Greyscale or a bitmap image & making adjustment to the density & saturation. The changes are not saved & the image goes back to its original condition right away. I have started this proc