Query for Multiple Rows as XML

Ok I've seen this topic in the forums, but have failed to get this to work within my process. Basically I have a process that has a user fill out a form, and upon submittal the form writes it's information to a database (via a data connection within the form that invokes a separate process upon submittal.), once this is done the main process is invoked and it's first step is to query that same database and bring back the data in a lower (now exposed) portion of the form that contains certain fields that track the issue history. The query brings back the xml document and I store it in an xml variable (xml_output). I then take this information and use the Set Value object to assign the returned nodes values to the location fields in the form. This works if the query returns only one row. But once the form is moved beyond the initial Task Assignment, (first user), and query returns more than just one row, the added nodes to not show up on the form, i.e I still just get information about the first row in my form. From what I've read the form should be able to recognize the xpath expression, and bring back all the nodes, by in a sense using instance manager to create an instance for each node on the form. My question is how can I get this to work. Jasmin if your still out there... Help!
Also We're using Adobe LiveCycle ES 8.0
created the process using Workbench
the form was reader enabled and saved as a dynamic PDF.
Thanks
Mike

Ok have done the binding of the schema to the form, and I'm getting the information to flow as it's supposed to.  The problem I'm having now, (I know I'm having a bunch.) is that once I've placed the form into my process, and I use the set value operation to pre-fill information I get the form to flow, but the rest of the information that was previously filled in is blank.  So I have checked the variable and nothing wrong there.  It appears the problem is how I'm using the set value operation.  If I don't use the set value operation, the form retains it's information.  And if I use the set value by trying to set the subform value, the form retains it's information, but no pre-fill.  I'm going to try to be a little more detailed here.  The xml that is returned looks like this:
        0016-03-30
        Mike
        Public Works
        alone in the dark
        Type sleep
        -1
        Council
        FYI
        Important
Flowed and positioned are actual subforms on the form that have their properties set as their names indicates.  The entire path is /form1/Page1/flowed/positioned .  The way I was able to get the form to flow correctly upon the injection of this xml data, was to bind the subforms in the form in this manner, positioned[*].  Designer didn't place the [*] for me so I had to do this myself.  But once I previewed the document, the form pre-populated and created the necessary number of subforms and placed information into the fields correctly.
Now on the process side, I have created an xfaform variable that stores the form (bound to xsd.)  information, and another xml variable that stores the query return that looks like the xml listed above (has an xsd associated with it for navigating xpath).  My first operation performs the query (JDBC- Query Multiple Rows as XML) and stores it into the xml variable.  The next step of the process is the Set Value operation which is supposed to inject the xml data retrieved from the query into the form.  Initially I tried the an xpath similar to the following:
/process_data/object/data/form1/page1/flowed/positioned = /xml_data/flowed/positioned.
No dice.  On this one the form retains the information filled out by the user (didn't explain this earlier, the form is filled out first, and upon submittal the process starts.), but doesn't pre-populate the bottom part of the form.  Next I tried the following xpath:
/process_data/object/data/form1/page1/flowed = /xml_data/flowed/positioned.
This time it retained the form information which was filed in by the user, but the bottom part is becomes hidden!  Didn't understand this.  But I started to kinda think that I had to navigate he xpath in order to correctly inject the xml into the form.  That being said my next attempt was:
/process_data/object/data/form1/page1 = /xml_data
My thinking was that if on location, I stop at page1, the xml in the variable will allow it to navigate correctly through the form.  Well it worked, but too well.  The top part of the form is blank, but the bottom portion is pre-populated correctly.  Now I'm stuck.  Not sure how to get the rest of the information in the form.  I thought about creating variables form each of the fields and then re-populating them after the injection of xml, but that didn't seem practical.  I'm almost positive it's something I'm not doing correctly with xpath.  Anyway, thanks for all your help on this.
Mike

Similar Messages

  • Return Code - Query for Multiple Rows as XML

    Hi,
    I'm executing an MSSQL stored procedure through the "Query for Multiple Rows as XML" activity in LiveCycle ES. I do this through a call statement such as this:
    { call MyStoredProc(?) }
    This works great, the stored procedure always returns a record set (with or without records). I use this activity rather than "Call Stored Procedure" because I can transform the record set into XML right away within this activity. Unfortunately any exception arising from invoking this stored procedure cannot be handled within the workflow as this activity does not have an exception handler (lightning bolt). In an attempt to handle at least some exceptions we have decided to use try/catches within the stored procedures and return different error codes. Now the problem I am faced with is that there is no way to retrieve the returned code within any of the SQL activities. We don't want to have to write an execute script for each of these SQL calls. Is there any way to do this? Seems like I'm 95% there.
    Thanks
    Nic

    Thanks for the offer, unfortunately we would need something certified by Adobe.
    Nic

  • Query for Multiple Rows as XML 'NULL' question

    There are two fields in the database.
    Foo = null (real null)
    Foo1 = '' (blank string)
    In my return xml the nodes are as follows:
    <Foo>null</Foo>
    <Foo1/>
    Why is it that if there is a null in the database, that it puts the string null, and then when there is a blank string, the node is empty?
    How can I get the null value to act like the blank value?
    Cheers

    SELECT COALESCE(Foo,''),COALESCE(Foo1,'') FROM mytable;
    The above query will return '' (empty string) if the columns has NULL value.
    This is another solution.
    Third solution is to apply XSL and remove NULL value.

  • Query for multiple row to single

    Hi All,
    Need help in Multiple row to single row
    create table cust_tranc_track
    (id number,
    payment_dt date ,
    emi_dt date,
    appr_dt date
    SET DEFINE OFF;
    Insert into CUST_TRANC_TRACK
       (ID, APPR_DT)
    Values
       (425, TO_DATE('11/12/2012 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into CUST_TRANC_TRACK
       (ID, PAYMENT_DT, EMI_DT)
    Values
       (425, TO_DATE('11/01/2012 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('11/13/2012 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;
    Output :
    ID     PAYMENT_DT     EMI_DT              APPR_DT
    425     11/1/2012     11/13/2012     11/12/2012thanks
    ajr

    *> g2500 wrote:**> Hi All,*
    *>*
    *> Need help in Multiple row to single row*
    *>*
    *> *
    *>*
    *>*
    **_+Hi,+_**
    **_+I cant clear about ur question. I m giving the solution wat i can understand.to get multiple row inti single u can use listagg function.+_**
    **_+use hr.employees+_**
    **_+select department_id,listagg(first_name,',') WITHIN GROUP (ORDER BY first_name) AS employeename+_**
    **_+from employees+_**
    **_+group by department_id;+_**
    **_+u [http://dba-oracle.com/t_oracle_listagg_function.htm]+_**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Formula to calculate SUM of multiple sheets of excel and the result to be stored in another excel sheet and pop up alerts for multiple rows

    I have a excel with multiple
         sheets with data as shown below
    SHEET 1
    A 1
    B 2
    C 3
    SHEET 2
    B 1
    C 2
    A 3
    SHEET 3
    C 1
    A 2
    B 3
    My
    query is splitted into 3 categories
    I want to have a formula to do math calculation such that data of "A" of SHEET 1 is  calculated with "A" of SHEET2 irrespective of the location of "A".
    When I include SHEET3, the formula should automatically identify the location of "A" or "B" or "C" and give the result corresponding to A, B or C. Since I want to bifurcate daily report and output printed. I want to use another
    excel for output. How to link multiple sheets of one excel and print the output of above in
         another excel?
    Assume, I have 4 SHEETS,  "SHEET 1", "SHEET 2", "SHEET 3" and "SHEET 4". Math calculation need to be done using all 4 sheets. If
    I include "SHEET 5", the formula should ignore SHEET 1  automatically and give the results of SHEETS 2 to 5. Similarly, if I include SHEET 6, SHEET 1 and 2 need to be ignored for further calculation and SHEET 3-6 need to be used. How to write
    such formula?
    How to get pop up alert for multiple rows, if a specific condition is hit?

    Maybe VBA Code should be a good option for you. I suggest you post you issue to
    Excel for Developers forum.
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.
    Thanks for your understanding.
    Best Regards,
    Wind

  • How to use the same POWL query for multiple users

    Hello,
    I have defined a POWL query which executes properly. But if I map the same POWL query to 2 portal users and the 2 portal users try to access the same page simultaneously then it gives an error message to one of the users that
    "Query 'ABC' is already open in another session."
    where 'ABC' is the query name.
    Can you please tell me how to use the same POWL query for multiple users ?
    A fast reply would be highly appreciated.
    Thanks and Regards,
    Sandhya

    Batch processing usually involves using actions you have recorded.  In Action you can insert Path that can be used during processing documents.  Path have some size so you may want to only process document that have the same size.  Look in the Actions Palette fly-out menu for insert path.  It inserts|records the current document work path into the action being worked on and when the action is played it inserts the path into the document as the current work path..

  • Can I use Concatenate function for multiple rows?

    I have a lead list that contains 5000 leads. The format of this list contains address data that is saved in separate columns (ie: address, address 2, city, state, zip). I need this data in 1 column. I tried to use the concatenate function to combine the data for 1 row and it worked perfectly. I tried to do this for multiple rows and the function is greyed out. Is there a work around or way that I can combine this data for all 5000 rows without doing it 1 by one?

    Look at this table;
    In B9, the formula is;
    =B2&" "&C2&" "&D2&" "&E2&" "&B3&" "&C3&" "&D3&" "&E3
    Yvan KOENIG (VALLAURIS, France) dimanche 18 octobre 2009 20:51:47

  • Query for multiple invoice numbers.

    Hi,
    My question is if I can add multiple invoice numbers in the search field "invice number"?
    For example when I receive a balance confirmation request from a supplier and their list contains 10 invoices. Can I do a search for all 10 at the same time or I can olny do a search one by one?
    Thank you!
    Angie

    Hi,
    there's no direct possibility to query for multiple Invoice number in terms of entering e.g. 5 number for a query.
    But you can work with placeholders '_' and '%' to find multiple invoices at one time. Underscore sign stands
    for exactly one character which can have multiple value, percentage sign for multiple ones.
    Example (assuming you are using letters and numbers for invoice numbering):
    When entering 'A12_' as search String, invoices from 'A120' to 'A12z' would be found.
    When using 'A12_01_' all invoices from 'A120010' to 'A12z01z' would be found.
    When using 'A12%' all invoices starting with 'A12' - no matter about the rest would be found.
    These are only a few examples but i think when using a clever combination of wildcards and parts of the
    invoices - which often share a common component, if the invoices come from the same vendor - you'll get
    at least a small step farther.
    Regards

  • Page wise total for multiple pages in xml template

    Hi all,
    I need to display page wise total for multiple pages in xml layout.I have tried with add-page-total and show-page-total tags but it is not working in my case.Anyone please provide me a solution to this. Thanks in Advance..It is urgent issue..
    Thanks
    Swapna

    This issue has been resolved.
    We had a call to the method "makeOutputFlat(true)" before the call to "FormProcessor.process()" that was corrupting the PDF template file.Once we took that off , the PDF is now printing multiple pages.

  • Oracle Query failing for multiple rows:

    Hey Guys,
    I have been given a task to produce an ad-hoc report based on the following conditions (I will give you the structure of the table and details in the table below the requirements)
    Requirements: Adhoc Report for Audit on CIT Income Allocation
    1. Select from the RETURNS table:
    • Id > 3600000 and
    • Prog_program_cd = '01' and
    • Return_status in ('ASSESSED', 'DU") and
    • Tax year ending in 2009 (i.e. year portion of the Period_end_date is in 2009)
    2. Retrieve the following fields from the RETURNS table :
    • Id
    • Entp_abn
    • Acct_id
    • Prog_program_cd
    • Period_start_date
    • Period_end_date
    • Amend_ind
    • Return_status
    • Status_date
    • Loctr_nbr
    3. If there are multiple entries from the same account and tax year, only retain the latest record: From the records selected in step 2, if there are multiple records with the same Acct_Id and Period_end_date, only retain the record with the most recent Status_date (i.e. MAX value on the date).
    4. Using the results from step 3, link to the applicable RETURN_LINE_ITEMS table where:
    • RETURNS.Id = RETURN_LINE_ITEMS.Rtrn_Id
    5. From the selected return on RETURN_LINE_ITEMS table, retrieve records where (value on Sch 000 Line 062 > 500,000) and (value on Sch 000 Line 066 < value on Sch 000 Line 062) :
    • Sched_nbr = '000', and Litm_line_item_nbr = '062', and Active_ind = 'Y', get Revise_val_amt as 'ab_taxable_income'
    • Sched_nbr = '000', and Litm_line_item_nbr = '066', and Active_ind = 'Y', get Revise_val_amt as 'amt_taxable_in_ab'
    • Retain the return only if (ab_taxable_income > 500,000) and (amt_taxable_in_ab < ab_taxable_income)
    The tables used in this are : RETURNS and RETURN_LINE_ITEMS
    Structure of RETURNS table is:
    ID
    PROG_PROGRAM_CD
    ACCT_ID
    ACPE_ID
    JENT_ID
    PREV_RTRN_ID
    ENTP_ABN
    ACCT_OCCURNC_NBR
    SOURCE_TYPE
    RECEIVE_DATE
    AMEND_IND
    CMPLT_IND
    PENALTY_OR_IND
    RETURN_STATUS
    STATUS_DATE
    STATUS_USERID
    PERIOD_START_DATE
    PERIOD_END_DATE
    NOTICE_STATUS
    NOTICE_STATUS_DATE
    NOTE_TEXT
    PENALTY_OR_BY
    PENALTY_OR_TMST
    FILING_ID
    CASE_ID
    DOC_CONTRL_NBR
    LOCTR_NBR
    STATUTE_BARRED_DATE
    MEDIA_TYPE
    DISPSTN_TYPE
    AMEND_TYPE
    CALC_MODE
    PROCESS_PASS_CNT
    CONVRTD_IND
    LOSS_PERIOD_END_DATE
    MF_SYNC_CD
    CREATED_BY
    CREATED_TMST
    MODIFIED_BY
    MODIFIED_TMST
    Structure of RETURN_LINE_ITEMS is:
    ID
    RTSC_ID
    RTRN_ID
    SCLI_ID
    LITM_ID
    ENTP_ABN
    PROG_PROGRAM_CD
    ACCT_OCCURNC_NBR
    ACPE_END_DATE
    SCHED_NBR
    SCHD_VERSION_YR
    SCHD_VERSION_NBR
    RTSC_OCCUR_NBR
    LITM_LINE_ITEM_NBR
    SLIN_LINE_ITEM_ID
    OCCUR_NBR
    PREV_VAL_MOD_IND
    VIABLE_IND
    ACTIVE_IND
    ACTION_CD
    PREV_VAL_AMT
    REVISE_VAL_AMT
    PREV_VAL_TEXT
    REVISE_VAL_TEXT
    DISPLAY_SEQ_NBR
    SYS_VAL_AMT
    LITM_INNER_PASS_SEQ_NBR
    CREATED_BY
    CREATED_TMST
    MODIFIED_BY
    MODIFIED_TMST
    So scripts to create the able tables are:
    RETURNS
    CREATE TABLE RETURNS
    ID NUMBER(12),
    PROG_PROGRAM_CD VARCHAR2(2 BYTE),
    ACCT_ID NUMBER(12),
    ACPE_ID NUMBER(12),
    JENT_ID NUMBER(12),
    ENTP_ABN NUMBER(9),
    ACCT_OCCURNC_NBR NUMBER(4),
    SOURCE_TYPE VARCHAR2(30 BYTE) DEFAULT 'BLANK',
    RECEIVE_DATE DATE,
    AMEND_IND VARCHAR2(1 BYTE) DEFAULT 'N',
    CMPLT_IND VARCHAR2(1 BYTE) DEFAULT 'N',
    PENALTY_OR_IND VARCHAR2(1 BYTE) DEFAULT 'N',
    RETURN_STATUS VARCHAR2(12 BYTE),
    STATUS_DATE DATE,
    STATUS_USERID VARCHAR2(8 BYTE),
    PERIOD_START_DATE DATE,
    PERIOD_END_DATE DATE,
    NOTICE_STATUS VARCHAR2(12 BYTE),
    NOTICE_STATUS_DATE DATE,
    LOCTR_NBR NUMBER(10),
    MEDIA_TYPE VARCHAR2(30 BYTE),
    DISPSTN_TYPE VARCHAR2(30 BYTE),
    CONVRTD_IND VARCHAR2(1 BYTE) DEFAULT 'N')
    RETURN_LINE_ITEMS
    CREATE TABLE RETURN_LINE_ITEMS
    ID NUMBER(12),
    RTSC_ID NUMBER(12),
    RTRN_ID NUMBER(12),
    LITM_ID NUMBER(12),
    ENTP_ABN NUMBER(9),
    PROG_PROGRAM_CD VARCHAR2(2 BYTE),
    ACCT_OCCURNC_NBR NUMBER(4),
    ACPE_END_DATE DATE,
    SCHED_NBR VARCHAR2(3 BYTE),
    SCHD_VERSION_YR NUMBER(4) DEFAULT 0,
    SCHD_VERSION_NBR NUMBER(3),
    RTSC_OCCUR_NBR NUMBER(3),
    LITM_LINE_ITEM_NBR VARCHAR2(3 BYTE),
    SLIN_LINE_ITEM_ID NUMBER(12),
    OCCUR_NBR NUMBER(3) DEFAULT 1,
    PREV_VAL_MOD_IND VARCHAR2(1 BYTE) DEFAULT 'N',
    VIABLE_IND VARCHAR2(1 BYTE) DEFAULT 'N',
    ACTIVE_IND VARCHAR2(1 BYTE) DEFAULT 'Y',
    PREV_VAL_AMT NUMBER(15,2),
    REVISE_VAL_AMT NUMBER(15,2),
    DISPLAY_SEQ_NBR NUMBER(3),
    SYS_VAL_AMT NUMBER(15,2),
    LITM_INNER_PASS_SEQ_NBR NUMBER(3)
    So when you run the scripts above, the tables are created (I have tested it in TOAD)
    Now let's feed data into both the tables
    RETURNS table:
    insert into RETURNS
    VALUES
    (3602448 , '01' ,288151,3876821,9345370 , 403232531, 1, 'TAXPAYER' ,12/4/2008 ,'N', 'Y','N','ASSESSED', 2/18/2009,'SANDEEP',1/2/2008,1/2/2009,
    'PRINTED','2/18/2009, 6043073664,'PAPER', 'NOTICE','N');
    insert into RETURNS
    VALUES
    (4117092 , '01' ,57794,3864551,10566221 , 400571410, 1, 'TAXPAYER' ,6/30/2010 ,'N', 'Y','N','ASSESSED', 2/18/2009,'SANDEEP',1/2/2008,1/2/2009,
    'PRINTED','2/18/2009, 6043073664,'PAPER', 'NOTICE','N');
    RETURN_LINE_ITEMS table:
    INSERT INTO RETURN_LINE_ITEMS
    VALUES
    (266000770,7749234,3602448,1603,403232531, 01, 1, 1/1/2009, 000, 1998, 1,1, '062', 40,1, 'N','Y', -5440, -5440, 200,-5440,130);
    INSERT INTO RETURN_LINE_ITEMS
    VALUES
    (266000773,7749234,3602448,1539,403232531, 01, 1, 1/1/2009, 000, 1998, 1,1, '066', 43,1, 'N','Y', NULL, 0, 215,0,200);
    INSERT INTO RETURN_LINE_ITEMS
    VALUES
    (319820233,9028477,4117092,1603,400571410, 01, 1, 1/1/2009, 000, 1998, 1,1, '062', 40 ,1, 'N','Y', 790068, 790068, 200,790068,130);
    INSERT INTO RETURN_LINE_ITEMS
    VALUES
    (319820236,9028477,4117092,1539,400571410, 01, 1, 1/1/2009, 000, 1998, 1,1, '062', 40 ,1, 'N','Y', NULL, 790, 215,790068,200);
    This completes the test data.
    Now based on the question posed by the Business Analyst, until "5 b" i.e where it's said:
    Sched_nbr = '000', and Litm_line_item_nbr = '066', and Active_ind = 'Y', get Revise_val_amt as 'amt_taxable_in_ab'
    I am able to retrieve data perfectly fine and the query for that is:
    SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd, r1.period_start_date, r1.period_end_Date, r1.amend_ind, r1.return_status, r1.status_date, r1.loctr_nbr,
    rtlnms.sched_nbr, rtlnms.litm_line_item_nbr,
    decode(rtlnms.litm_line_item_nbr, '062', RTLNMS.REVISE_VAL_AMT)AB_TAXABLE_INCOME,
    decode(rtlnms.litm_line_item_nbr, '066', RTLNMS.REVISE_VAL_AMT)AMT_TAXABLE_IN_AB
    from returns r1, return_line_items rtlnms
    where r1.id = rtlnms.rtrn_id
    and r1.id > 3600000
    AND r1.prog_program_cd = '01'
    AND r1.return_status in ('ASSESSED', 'DU')
    and r1.period_end_Date between to_date('01-01-2009','DD-mm-YYYY') and to_date ('31-12-2009', 'DD-mm-YYYY')
    and r1.status_date = (select max (status_date) from returns r2 where r2. acct_id= r1.acct_id and r2.period_end_date = r1.period_end_date)
    and rtlnms.sched_nbr = '000'
    and RTLNMS.LITM_LINE_ITEM_NBR IN('062', '066')
    and rtlnms.active_ind = 'Y' and r1.id in(4117092, 3602448)
    The out put is : 4 rows returned which has litm_line_item_nbrs for all the returns in question (4117092, 3602448) and that is - 066,062,062, 066 with their respective amounts.
    However against the business analyst's question 5 "C" which is - Retain the return only if (ab_taxable_income > 500,000) and (amt_taxable_in_ab < ab_taxable_income)
    I should be getting 2 rows(one with '062' and '066') with return -4117092
    So I am applying the logic as mentioned by business analyst's "5C" and run the following query:
    SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd, r1.period_start_date, r1.period_end_Date, r1.amend_ind, r1.return_status, r1.status_date, r1.loctr_nbr,
    rtlnms.sched_nbr, rtlnms.litm_line_item_nbr,
    decode(rtlnms.litm_line_item_nbr, '062', RTLNMS.REVISE_VAL_AMT)AB_TAXABLE_INCOME,
    decode(rtlnms.litm_line_item_nbr, '066', RTLNMS.REVISE_VAL_AMT)AMT_TAXABLE_IN_AB
    from returns r1, return_line_items rtlnms
    where r1.id = rtlnms.rtrn_id
    and r1.id > 3600000
    AND r1.prog_program_cd = '01'
    AND r1.return_status in ('ASSESSED', 'DU')
    and r1.period_end_Date between to_date('01-01-2009','DD-mm-YYYY') and to_date ('31-12-2009', 'DD-mm-YYYY')
    and r1.status_date = (select max (status_date) from returns r2 where r2. acct_id= r1.acct_id and r2.period_end_date = r1.period_end_date)
    and rtlnms.sched_nbr = '000'
    and RTLNMS.LITM_LINE_ITEM_NBR IN('062', '066')
    and rtlnms.active_ind = 'Y' and r1.id in(4117092, 3602448)
    and r1.id in (select rtrn2.id
    from returns rtrn2, return_line_items rtlnms2
    where rtrn2.id= rtlnms2.rtrn_id
    and rtrn2.id=r1.id
    and nvl(decode(rtlnms.litm_line_item_nbr, '062', RTLNMS.REVISE_VAL_AMT),0) > 500000 or rtlnms2.litm_line_item_nbr='066') and (
    nvl(decode(rtlnms.litm_line_item_nbr, '066', RTLNMS.REVISE_VAL_AMT),0) < nvl(decode(rtlnms.litm_line_item_nbr, '062', RTLNMS.REVISE_VAL_AMT),0))
    order by r1.acct_id , r1.period_end_date desc
    I am only getting one row with for RETURN = 4117092 with litm_line_item_nbr (line item number) '062' where as I should also be getting line item number '066' along with '062'
    Could any one of you please help me out. I am stuck and have tried everything at the office with no luck.
    Many Many Thanks in Advance!
    Sandeep

    Hi there,
    I agree that without test case it's a bit complicated for you folks to solve. However I just could not. Anyways this is the query that I had to use to come to my solution and that is:
    SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd, r1.period_start_date, r1.period_end_Date, r1.amend_ind, r1.return_status, r1.status_date, r1.loctr_nbr,
    rtlnms.sched_nbr, rtlnms.litm_line_item_nbr,
    decode(rtlnms.litm_line_item_nbr, '062', RTLNMS.REVISE_VAL_AMT)AB_TAXABLE_INCOME,
    decode(rtlnms.litm_line_item_nbr, '066', RTLNMS.REVISE_VAL_AMT)AMT_TAXABLE_IN_AB
    from returns r1, return_line_items rtlnms
    where
    r1.id = rtlnms.rtrn_id and
    r1.prog_program_cd = rtlnms.prog_program_cd and
    r1.entp_abn = rtlnms.entp_abn and
    r1.id > 3600000 AND r1.prog_program_cd = '01' AND r1.return_status in ('ASSESSED', 'DU')
    and r1.period_end_Date between to_date('01-01-2009','DD-mm-YYYY') and to_date ('31-12-2009', 'DD-mm-YYYY')
    and r1.status_date = (select max (status_date) from returns r2 where r2. acct_id= r1.acct_id and r2.period_end_date = r1.period_end_date)
    and rtlnms.sched_nbr = '000'
    and rtlnms.active_ind = 'Y'
    and r1.id in (4117092,3715944,4382179,3691435)
    and RTLNMS.LITM_LINE_ITEM_NBR IN('062')
    AND nvl(decode(litm_line_item_nbr, '062', REVISE_VAL_AMT),0) > 500000
    and NVL(RTLNMS.REVISE_VAL_AMT,0) >( select NVL(RTLNMS2.REVISE_VAL_AMT,0)
    FROM RETURN_LINE_ITEMS RTLNMS2
    WHERE RTLNMS2.RTRN_ID=RTLNMS.RTRN_ID
    AND RTLNMS2.LITM_LINE_ITEM_NBR = '066'
    AND SCHED_NBR='000'
    UNION
    SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd, r1.period_start_date, r1.period_end_Date, r1.amend_ind, r1.return_status, r1.status_date, r1.loctr_nbr,
    rtlnms.sched_nbr, rtlnms.litm_line_item_nbr,
    decode(rtlnms.litm_line_item_nbr, '062', RTLNMS.REVISE_VAL_AMT)AB_TAXABLE_INCOME,
    decode(rtlnms.litm_line_item_nbr, '066', RTLNMS.REVISE_VAL_AMT)AMT_TAXABLE_IN_AB
    from returns r1, return_line_items rtlnms
    where r1.id = rtlnms.rtrn_id
    AND r1.prog_program_cd = rtlnms.prog_program_cd
    AND r1.entp_abn = rtlnms.entp_abn
    AND r1.id > 3600000 AND r1.prog_program_cd = '01'
    AND r1.return_status in ('ASSESSED', 'DU')
    and r1.period_end_Date between to_date('01-01-2009','DD-mm-YYYY') and to_date ('31-12-2009', 'DD-mm-YYYY')
    and r1.status_date = (select max (status_date) from returns r2 where r2. acct_id= r1.acct_id and r2.period_end_date = r1.period_end_date)
    and rtlnms.sched_nbr = '000'
    and rtlnms.active_ind = 'Y'
    and r1.id in (4117092,3715944,4382179,3691435)
    and RTLNMS.LITM_LINE_ITEM_NBR IN('066')
    and NVL(RTLNMS.REVISE_VAL_AMT,0) <( select NVL(RTLNMS2.REVISE_VAL_AMT,0)
    FROM RETURN_LINE_ITEMS RTLNMS2
    WHERE RTLNMS2.RTRN_ID=RTLNMS.RTRN_ID
    AND RTLNMS2.LITM_LINE_ITEM_NBR = '062'
    and NVL(RTLNMS2.REVISE_VAL_AMT,0)>500000
    AND SCHED_NBR='000'
    order by ID
    This above query works fine. No worries.
    One more question and that is:
    I need to find out details of another condition. However what happens is using the same query above, when I try to add "and RTLNMS.LITM_LINE_ITEM_NBR IN('066' ,029')" (in the bold part),
    it does give me another extra value for row 029 and that's something that I don't want. Based on the above results, I get 4 rows ; 2 each for 062 and 069.
    The question asked by business is based on the above results, bring out even values for 029, so which in this case should be 2 rows, making it overall 6, but then I get 7, is there any way to get rid of extra row
    or rather : is there any way to retrieve additional row based on results from a query?

  • Looking for a best query for multiple IF Else statement in a single select

    Hi
    I want to run multiple IF Else statements in a single select SQL, each statement is one SQL operating on the same table, what is the best way to write this select SQL query ?
    If it is PL/SQL, when i get the result from the first IF statement I will skip the remaining execution, and so on... Can any one help me on this.
    Thanks in advance !!

    965818 wrote:
    I Apologize, the information i have given might not be enough.
    This is my scenario,
    I am selecting set of rows from the table for the employee id. After selecting those records,
    i need to go through the result list and check the condition 1, if it is met, i will return that employee record.
    If that condition 1 is not met, then i need to go through the condition 2. If that is met, i will return that record.
    Like wise, i have four conditions.
    I am trying to achieve this in a single sql. If i am not clear, please let me know.Not fully clear yet, but the picture is better already. The thing with SQL is that you should stop thinking procedurally. Instead think in data sets.
    For example if the task is:
    Find all managers that work in sales.
    Procedural thinking would work like this:
    pseudo code
    Loop over all employees that work in sales
       for each row
           check if it is a manager
               if manager
                  then return record
               else
                  do nothing
               end
    end loopThinking in datasets will result in a different logic
    pseudo code
    select all employees
    where department = SALES
    and job = MANAGERThis advantage here is that all the "Do nothing" loops are not needed. Those are already eliminated by the database.
    So what is needed to help you? Give the full picture. What is your task that you try to solve. From a business perspective.

  • Oracle query - Merging multiple rows into a single row output

    Hi All,
    I have to have a multiple row output to be converted into a single row output.My current output looks as follows:
    ID YR INC_CODE OFFN SCHOOLNO
    8006 2002 00175 SC03 12
    8006 2002 00175 DC06 12
    8006 2002 00175 DC03 12
    8006 2002 00175 DC02 12
    ID,INCIDENT CODE,OFFENSE are all Primary keys
    So I need the output as follows:(IN ONE ROW)
    ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 SCHOOLNO
    8006 2002 00175 SC03 DC06 DC03 DC02 12
    Can you help me on this since have been spinning the wheel and this has to be a query since will have couple of tables join to produce a materialized view.
    Thanks in advance

    Hi Nigel,
    Thanks for the reply I tested out the portion having the decode and I get the output as follows:
    ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 OFFN5
    8982 2002 2175 DOC01 -----------------------
    8982 2002 2175 DOC02-------------------
    8982 2002 2175 DOC03------------
    8982 2002 2175 DOC06-------
    8982 2002 2175 SCV03
    There is no value as max for OFFN and each INC_CODE MAY HAVE UP TO A MAX OF 5 OFFN.My query is as follows:
    select distinct STU_STUDENT_ID, INC_BEG_SCH_YR,INC_INCIDENT_CODE
    , decode(rank() over (partition by INC_CODE order by OFFN),1,OFFN,null) as offn1
    , decode(rank() over (partition by INC_CODE order by OFFN),2,OFFN,null) as offn2
    , decode(rank() over (partition by INC_CODE order by OFFN),3,OFFN,null) as offn3
    , decode(rank() over (partition by INC_CODE order by OFFN),4,OFFN,null) as offn4
    , decode(rank() over (partition by INC_CODE order by OFFN),5,OFFN,null) as offn5
    from stu_offn where
    stu_offn.ID = '8982' and stu_offn.INC_CODE = '2175'
    (****Where clause is just given to just check a value)
    So as you know I need to just have all the OFFN in a single row ie as follows:
    ID YR INC_CODE OFFN1 OFFN2 OFFN3 OFFN4 OFFN5
    8982 2002 2175 DOC01 DOC02 DOC03 DOC06 SCV03
    Can you just give me a step by step procedure to go through this and the table in this case is just 'STU_OFFN'
    Thanks for the earlier reply appreciate it!
    ****Sending this again to show the exact way the output is coming

  • Query on  Multiple-Row subqueries

    Multiple-row subqueries:
    -->"They should not be used with the NOT IN operator in the main query if NULL is likely to be part of the result of the subquery "
    -->"They can be used to retrieve multiple rows from a single table only"
    But i checked the following example
    select a.n1
    from t1 a
    where a.n1 not in (Select *
                 from t2 b)Where t2 contains null values
    And query is giving no error
    So the second option is correct i feel.
    Could you suggest me
    Edited by: josh1612 on Mar 7, 2010 10:38 PM

    -->"They should not be used with the NOT IN operator in the main query if NULL is likely to be part of the result of the subquery "Here is a simple example, there is no value in T2 for the column No as 1 but still you dont get any row. That is because NULL means UNKNOWN. You cant use it in comparison.
    create table t1(no integer)
    create table t2(no integer)
    insert into t1 values(1)
    insert into t2 values (null)
    insert into t2 values (2)
    select *
      from t1
    where t1.no not in (select no from t2)
    /Now delete the null value and try
    delete from t2 where no is null
    select *
      from t1
    where t1.no not in (select no from t2)
    /

  • Password Masking & Background Color for Multiple Rows in Tabular Form

    Hi all,
    I have a requirement of making a column in Tabular form, having multiple rows, masked(password field). I also want to give bg color to this field indicating that its a mandatory field.
    I am unable to accomplish both at a time in my page. I am using Apex 3.2.
    Waiting for your valuable comments. Thanks,
    Regards,
    Sandeep

    APEX_ITEM API doesnot have a password function, but input fields of type password are available in HTML.
    So you would have to change the field type to password in JS
    That is from :
    <input type="text" ...change it to
    <input type="password" ...If you were using jQuery it would have been simpler, but to do it in native JS it is a bit more hard work.
    Anyway here goes (a quick check in a tabular form seens to work fine)
    var password_array=document.getElementsByName("f04");
    for(var i=0;i<password_array.length;i++)
       password_array.type = 'password';
    password_array[i].style.backgroundColor = 'RED';
    +Replace the "f04" with your password field's array name(use firebug to identify the field name)+
    Does that solve your problem ?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • [Oracle 8i] Query for N rows by column value?

    I was just wondering if what I want to do is possible within my query (rather than programmatically)...
    I want to return the N most recent records for each unique value in a particular column.
    Here's a sample table:
    CREATE TABLE     orders
    (     order_no     numeric(10)
         part_no          varchar(5)
         close_date     date
         order_qty     numeric(10)
         scrap_qty     numeric(10)
         CONSTRAINT order_pk PRIMARY KEY (order_no)
    );And some sample data....
    INSERT INTO     orders     VALUES
    (0000012345,'ABC-1',TO_DATE('01-01-2010','mm-dd-yyyy'),10,1);
    INSERT INTO     orders     VALUES
    (0000013498,'ABC-1',TO_DATE('01-05-2010','mm-dd-yyyy'),12,2);
    INSERT INTO     orders     VALUES
    (0000033452,'ABC-1',TO_DATE('01-10-2010','mm-dd-yyyy'),5,0);
    INSERT INTO     orders     VALUES
    (0000001468,'ABC-1',TO_DATE('01-15-2010','mm-dd-yyyy'),15,1);
    INSERT INTO     orders     VALUES
    (0000022349,'BR723',TO_DATE('01-03-2010','mm-dd-yyyy'),8,1);
    INSERT INTO     orders     VALUES
    (0000069581,'BR723',TO_DATE('01-05-2010','mm-dd-yyyy'),5,0);
    INSERT INTO     orders     VALUES
    (0000436721,'BR723',TO_DATE('01-10-2010','mm-dd-yyyy'),14,1);
    INSERT INTO     orders     VALUES
    (0000213446,'A5001',TO_DATE('01-06-2010','mm-dd-yyyy'),5,1);
    INSERT INTO     orders     VALUES
    (0000327987,'A5001',TO_DATE('01-08-2010','mm-dd-yyyy'),5,0);
    INSERT INTO     orders     VALUES
    (0000041353,'A5001',TO_DATE('01-14-2010','mm-dd-yyyy'),12,1);
    INSERT INTO     orders     VALUES
    (0000011241,'A5001',TO_DATE('01-15-2010','mm-dd-yyyy'),5,1);In this example, what I want to return are the 2 most recent orders (by close_date) for each part number.
    Here is a table with the results I want to get, based on the scenario above:
    order_no     part_no          close_date     order_qty     scrap_qty
    0000001468     'ABC-1'          '01-15-2010'     15          1
    0000033452     'ABC-1'          '01-10-2010'     5          0
    0000436721     'BR723'          '01-10-2010'     14          1
    0000069581     'BR723'          '01-05-2010'     5          0
    0000011241     'A5001'          '01-15-2010'     5          1
    0000041353     'A5001'          '01-14-2010'     12          1Is it possible to write a query to get these results, or am I going to have to query for all available data, and find the 2 most recent rows programmatically?
    Thanks in advance!

    Hi,
    user11033437 wrote:
    I'm going to test that out right now. I think if it works, I may need to use dense_rank() rather than rank(), because it is possible that two orders for the same part number could have the same close date, and according to what I've looked up on the rank() and dense_rank() functions, rank() can give non-consecutive results if the values are the same.What's wrong with non-consecutive values?
    Use RANK, DENSE_RANK or ROW_NUMBER depending on what you want.
    For example; say a certain part has been ordered 8 times:
    3 times with close_date January 29, 2010 (all at exactly the same time),
    4 times with close_date January 28, 2010 (all at exactly the same time), and
    1 time with close_date January 27, 2010.
    If you ask for the last 2 rows:
    RANK will give you the 3 rows from January 29. (All 3 have an equal claim to being in the top 2.)
    DENSE_RANK will give you the 7 rows from January 28-29 (the last two values , regardless of how many rows have them).
    ROW_NUMBER will give you 2 rows from January 29. (Which 2? It's arbitrary unless you add a tie-breaker to the ORDER BY clause.)
    All these functions are available in Oracle 8.1.

Maybe you are looking for

  • How do I configure the Airport utility to allow more than one rule per port?

    How do I configure the Airport Utility (AU) to allow more than one rule per port? I am on a home network, with broadband cable modem.  I have my airport extreme connected to the broadband modem.  I have 2 servers in my home that need to be accessed r

  • File-to-file or File-to-RFC for Automatic PO creation and GR creation

    Hi, We are on XI 3.0 and the following has been put to me: We will receive a .CSV file from FTP server, into XI and then need to create Purchase Orders followed by the Goods Receipt documents in R/3 based on the incoming data. Further to this, the re

  • Selection screen drop down

    Hi,   How can I define the dropdown in selection screen. I want to give 4 options for file download 1. comma dilimited 2. tab 3. colon 4. space parameter : p_dilimit (here i want to define as dropdown list on selection screen). Thanks.

  • XI to read the action xml file and create a SAP notification in PM

    Hi All I am new to XI world can you please help me in doing this scenario. I have to read an XML file and create a Notification in PM module of SAP. Step by Step help would be great. Thanks in Advance Sai

  • Is there something called N80?????

    why you do that nokia??? N80 3Mb but in fact less than 1Mb "7610 can take better photo"? many bugs and problems with the frameware and what nokia guys do? release Nokia N80ie without fixing any of the problems with the previous on I'm sorry to say it