SQL Query to fetch a specific field in xml

Hi,
Below is my sample Xml file.
<?xml version = "1.0" encoding = "UTF-8"?>
<methodCall xmlns = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd Schema_new.xsd">
<methodName>rBatchFile </methodName>
<params>
<param>
<value>
<struct>
<member>
<name>filename</name>
     <value>
     D:\test.txt
     </value>
</member>
<member>
<name>batchId</name>
<value>
     L1
</value>
</member>
</struct>
</value>
</param>
</methodName>
</methodCall>
I want to query a "value" field based on the "name" field. I tried with the following query which didnt work.
SELECT a.extract('//value/text()' , 'xmlns:="http://www.tibco.com/schemas/CS4_new1/Schema.xsd" ')
FROM ( SELECT t.customerinfo.extract('//member[name="filename"]','xmlns:="http://www.tibco.com/schemas/CS4_new1/Schema.xsd" ')
FROM cust_order t ) a;
Please do provide the SQL query ASAP.

with tab as (
select xmltype('<?xml version = "1.0" encoding = "UTF-8"?>
<methodCall xmlns = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd Schema_new.xsd">
<methodName>rBatchFile </methodName><params>
<param>
<value>
<struct>
<member>
<name>filename</name>
<value>
D:\test.txt
</value>
</member>
<member>
<name>batchId</name>
<value>
L1
</value>
</member>
</struct>
</value>
</param>
</params>
</methodCall>
') a from dual
--end of sample data
SELECT
  extractvalue(column_value,'/member/name') name,
  extractvalue(column_value,'/member/value') value
from tab t,xmltable('xmlns = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd Schema_new.xsd"','for $i in //member return $i' passing t.a)An example...but i tweaked the xml...check the xml namespace once before executing...
without adding the namespaces...code will be like...
with tab as (
select xmltype('<?xml version = "1.0" encoding = "UTF-8"?>
<methodCall >
<methodName>rBatchFile </methodName><params>
<param>
<value>
<struct>
<member>
<name>filename</name>
<value>
D:\test.txt
</value>
</member>
<member>
<name>batchId</name>
<value>
L1
</value>
</member>
</struct>
</value>
</param>
</params>
</methodCall>
') a from dual
--end of sample data
SELECT
  extractvalue(column_value,'/member/name') name,
  extractvalue(column_value,'/member/value') value
from tab t,xmltable('for $i in //member return $i' passing t.a)Ravi Kumar

Similar Messages

  • SQL query to fetch WIP jobs agains a customer

    Hi All,
    Can anyone please help me with a SQL query to fetch WIP jobs agains a customer.
    Regards,
    Shruti

    If you are using ATO functionality and if you are reserving sales orders to work orders, you can link them as follows
    Using customer name, identify the open sales order headers and lines.
    For each line, query reservations (mtl_reservations) using demand id fields.
    For those reservations where supply = wip job, use the supply id fields and get wip_entity_id.
    Using wip_entity_id, get wip_entity_name(job#) from wip_entities table.
    Once a job is completed, this link is lost.
    Sandeep Gandhi

  • SQL query to fetch records  from  26 onwards

    Want to know SQL query to fetch records from 26 onwards.

    See the fifth entry on the FAQ page:
    Re: How to attach a java bean in forms6i

  • How will write SQL query to fetch data from  each Sub-partition..

    Hi All,
    Anyone does have any idea about How to write SQL query to fetch data from Sub-partition.
    Actually i have one table having composite paritition(Range+list)
    Now if i want to fetch data from main partition(Range) the query will be
    SELECT * FROM emp PARTITION(q1_2005);
    Now i want to fetch data at sub-partition level(List) .But i am not able to get any SQL query for that.
    Pls help me to sort out.
    Thanks in Advance.
    Anwar

    SELECT * FROM emp SUBPARTITION(sp1);

  • Sql query to fetch session id

    Hi,
    I am to trying to fetch session id of a previously submitted process of a search button......so that i can display the search results in a different page.....so is there any sql query or pl/sql procedure to fetch the session id.

    >
    Please update your forum profile with a real handle instead of "968337".
    I am to trying to fetch session id of a previously submitted process of a search button......It's not all clear what you are trying to do. The documentation describes an APEX session and its ID thus:
    >
    A session is a logical construct that establishes persistence (or stateful behavior) across page views. Each session is assigned a unique identifier. The Application Express engine uses this identifier (or session ID) to store and retrieve an application's working set of data (or session state) before and after each page view.
    >
    This means that each page view and page submission does not have its own session ID, but uses the session ID established when the user's current session began (which is usually through logon and authentication).
    Given this definition of session and session ID, are you therefore referring to the ID of some previous user session in which a page was submitted by a search button? Or some private meaning that you have yet to fully explain?
    so that i can display the search results in a different page.....so is there any sql query or pl/sql procedure to fetch the session id.The session ID of the current session is available using the the built-in substitution string<tt>APP_SESSION</tt> built-in substitution string.
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
    Following the guidelines in these documents will also help to explain the problem in much more detail and with sufficient background for it to be understood:
    <li>+How to ask questions+
    <li>+{message:id=9360002}+
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.

  • SQL Query if or case omit fields but not line.

    I have the below SQL Query my goal is to not show Aging or Storage Date if QTY is greater than 0. 
    I know I can omit the line but I still want to show just not those two fields is this possible?
    Select sl.SKU, sl.LOC, (editdate) AS "Storage Date", CAST(sysdate-editdate AS DECIMAL(10,2)) AS Aging, sl.QTY, sl.QTYALLOCATED
    From skuxloc sl
    Where sl.SKU in ('315A6112-29','315A6112-33')
    This is what I'm looking for:
    Work Smarter Not Harder

    Are you working with OracleSQL, There is no sysdate in SQL Server.
    Select sl.SKU, sl.LOC,
    case when sl.QTY =0 then '' else editdate end AS 'Storage Date',
    case when sl.QTY =0 then '' else CAST(sysdate-editdate AS DECIMAL(10,2)) END
    AS Aging,
    sl.QTY, sl.QTYALLOCATED
    From skuxloc sl
    Where sl.SKU in ('315A6112-29','315A6112-33')
    If you are working with Oracle, You can try decode.
    http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions040.htm
    http://www.dba-oracle.com/t_decode_function.htm
    --Prashanth

  • SQL query to fetch approximately 9000 rows

    Hi,
    I am using the following SQL query in a java class. Using JDBC to connect to an Oracle database using JRUN app server connection pooling.
    SELECT PT.ACCOUNT_NUMBER,PAYMENT_REF_ID, TO_CHAR (PT.DATE_CREATED, 'MM/DD/YYYY'),
    PT.AMOUNT_PAID, DECODE(STATUS_VALUE,'Cancelled','Canceled',STATUS_VALUE)
    FROM EPAY_PAYMENT_TRANSACTIONS PT, EPAY_STATUS_LOOKUP SL
    WHERE
    PT.CLIENT_NAME = 'someclientname'
    AND TO_CHAR(DATE_PAYMENT_SCHEDULED,'MM/DD/YYYY') = '08/28/2006'
    AND PT.PAYMENT_STATUS = SL.STATUS_CODE
    ORDER BY PT.DATE_CREATED DESC
    EPAY_PAYMENT_TRANSACTIONS is a huge table consisting of thousands of rows. There are 4 indexes defined on this table but not on the columns used in the join condition of the query.
    EPAY_STATUS_LOOKUP is a much smaller table mainly used for lookup consisting of some 100 rows.
    The above query fetches approx 9000 records and takes a very long time to execute. Is there any way it can be optimized or we can change some attributes on the tables involved for speeding up the query?
    Thanks in advance,
    Nisha.

    So the task is to avoid FTS on EPAY_PAYMENT_TRANSACTIONSWell, maybe...
    But I believe that we have yet to hear more details about data distribution, execution plans and so on.
    Because it all depends...
    Consider simple testcase:
    SQL> select * from v$version where rownum = 1;
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
    SQL> -- Create "small" table
    SQL>
    SQL>  create table build_t as
      2   select rownum x,
      3          rpad('*', 200, '*') padding
      4     from dual
      5  connect by level <= 100;
    Table created.
    SQL> -- Create "large" table - initially, add 9000 rows which satisfy join criteria
    SQL>
    SQL>  create table probe_t as
      2   select mod(rownum - 1, 100) + 1 x,
      3          dbms_random.value y,
      4          rpad('*', 200, '*') padding
      5     from dual
      6  connect by level <= 9000;
    Table created.
    SQL> -- Now, add some extra rows to large table - "thousands of rows"
    SQL>
    SQL>  insert into probe_t
      2   select rownum + 100,
      3          0,
      4          rpad('*', 200, '*') padding
      5     from dual
      6  connect by level <= 100000;
    100000 rows created.
    SQL> exec dbms_stats.gather_table_stats(user, 'BUILD_T')
    PL/SQL procedure successfully completed.
    SQL> exec dbms_stats.gather_table_stats(user, 'PROBE_T')
    PL/SQL procedure successfully completed.
    SQL> -- Ok, let's measure ...
    SQL>
    SQL> set autot traceonly
    SQL>
    SQL> select a.*, b.*
      2    from build_t a,
      3         probe_t b
      4   where a.x = b.x
      5   order by b.y;
    9000 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=1387 Card=109 Bytes=45017)
       1    0   SORT (ORDER BY) (Cost=1387 Card=109 Bytes=45017)
       2    1     HASH JOIN (Cost=1386 Card=109 Bytes=45017)
       3    2       TABLE ACCESS (FULL) OF 'BUILD_T' (Cost=5 Card=100 Bytes=20400)
       4    2       TABLE ACCESS (FULL) OF 'PROBE_T' (Cost=1355 Card=109000 Bytes=22781000)
    Statistics
              0  recursive calls
              0  db block gets
           3280  consistent gets
              0  physical reads
              0  redo size
         360756  bytes sent via SQL*Net to client
           7096  bytes received via SQL*Net from client
            601  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
           9000  rows processedOn my server, this query finished in less that second and took 3280 LIO to complete.
    Now, which index did you mean to build? I guess it's and index on join column, isn't it?
    If so - let's build it and measure again:
    SQL> create index idx_probe_t on probe_t(x);
    Index created.
    SQL> select /*+ ORDERED USE_NL(a b) */
      2         a.*, b.*
      3    from build_t a,
      4         probe_t b
      5   where a.x = b.x
      6   order by b.y;
    9000 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=211 Card=109 Bytes=45017)
       1    0   SORT (ORDER BY) (Cost=211 Card=109 Bytes=45017)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'PROBE_T' (Cost=3 Card=1 Bytes=209)
       3    2       NESTED LOOPS (Cost=210 Card=109 Bytes=45017)
       4    3         TABLE ACCESS (FULL) OF 'BUILD_T' (Cost=5 Card=100 Bytes=20400)
       5    3         INDEX (RANGE SCAN) OF 'IDX_PROBE_T' (NON-UNIQUE) (Cost=2 Card=1)
    Statistics
              0  recursive calls
              0  db block gets
           9124  consistent gets
             21  physical reads
              0  redo size
         360756  bytes sent via SQL*Net to client
           7096  bytes received via SQL*Net from client
            601  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
           9000  rows processedLook at this - 9124 consistent gets, almost three times larger than in case of hash join.
    Full table scan is not something to be avoided at all cost.
    Indexing - sometimes it is good,
    sometimes it's just useless,
    sometimes it only makes things worse...
    It all depends on underlying data distribution. That's why I asked user527580 to tell us more.
    Kind regards.

  • SQL QUERY updateable report with APEX_ITEM fields to update hidden columns

    Here is my SQL query:
    select
    "EMPLOYEE_ID",
    "PUBLICATION_ID",
    "TITLE",
    '<NOBR>1. ' || APEX_ITEM.TEXT(101,CODE1,2,3) || '  ' ||
    APEX_ITEM.TEXT(102,CODE1_PCT,2,3) || ' %</NOBR><BR>' ||
    '<NOBR>2. ' || APEX_ITEM.TEXT(103,CODE2,2,3) || '  ' ||
    APEX_ITEM.TEXT(104,CODE2_PCT,2,3) || ' %</NOBR><BR>' ||
    '<NOBR>3. ' || APEX_ITEM.TEXT(105,CODE3,2,3) || '  ' ||
    APEX_ITEM.TEXT(106,CODE3_PCT,2,3) || ' %</NOBR>' rfcd_codes,
    APEX_ITEM.DISPLAY_AND_SAVE(100,CODE1) hidden_rfcd1,
    mycomments
    from "#OWNER#".mytable
    I have 3 code fields with their percentages (_pct). I have concatinated them so I can format them nicely on the page.
    I have create a process 'on-submit and before computations and validations' where I was hoping to assign my table columns (eg the code and pct columns) from the APEXITEMs in my select statement.
    I can get the values from these (APEX_ITEM) fields by referencing APEX_APPLICATION.G_F10(i) etc.... so thats cool.
    But my problem is how do I reference the table columns so I can assign them.
    I am using a 'Multi Row Update' process to perform the update to the database.
    P.S. mycomments column is working fine. It gets updated nicely but its just those other APEX_ITEM fields.

    I don't have the apex_application.g_f01(i) referenced in the page source...In the page source you wouldn't find anything by that name
    Identify the tabular form's checkbox column in the page(firebug/chrome developer panel makes this easy)
    It should be like
    &lt;input id=&quot;...&quot; value=&quot;&quot; type=&quot;checkbox&quot; name=&quot;fXX&quot; &gt;we are interested in the name attribute , get that number (between 01 and 50)
    Replace that number in the code, for instance if it was f05 , the code would use
    apex_application.g_f05
    --i'th checked record' primary keyWhen you loop through a checkbox array, it only contains the rows which are checked and it is common practice to returns the record's primary key as the value of the checkbox(available as the the i'th array index as apex_application.g_f05(i) , where i is sequence position of the checked row) so that you can identify the record.

  • SQL query to fetch the catalog category for a PLM item

    Hi All,
    Can anyone help me with a sql query of how we can fetch the catalog category for a PLM item.
    Regards,
    Shruti

    Hi,
    You could monitor the SMSProv.log when you check the category of an application. It shows that SQL query the SCCM provider used is related to function fn_ListCategoryInstances.
    Best Regards,
    Joyce

  • Sql query to fetch data based on date conditons

    Hi All,
    We have to schedule a script that runs at 1:00 AM from Monday to Friday.
    The script will run a  sql query  ,that will fetch the data from sql database 2008 based on the below conditions.
    Case 1: If date = current Date then retrieve the data of the previous Date.
    Case 2: If date = Monday then retrieve the entries of Friday ,Saturday and Sunday.
    Please help us on how we can achieve this.
    Thanks

    Hi,
    Are you asking about Patrick's
    solution?
    If so I highly recommend NOT to use this solution. PLease read LMU92's
    and
    Visakh16's responses.
    Why not to use it?
    1. This solution is not deterministic!
    A deterministic algorithm is an algorithm which, given a particular input, will always produce the same output. This solution give different values for different setting! It is depending for example on "SET LANGUAGE" value
    As mentioned above if you try to use any other languge then English then this query will not work since you will never get the value "Sunday"
    2. Moreover! Even if you are using "SET LANGUAGE 'English'" then this
    solution depend on "SET DATEFIRST" and only take into consideration that the value can be 1 or 7, using any other value you will get that @weekendDateMod is null!
    What can you use?
    let's test some value first to get the solution yourself. We know that we don't care about "SET LANGUAGE" since I will not use any language dependency but we need to examine "SET DATEFIRST". Try to change the value from 1 to 7 and check
    the value of this query
    SET DATEFIRST 1 -- Change this value from 1 to 7!
    DECLARE @Sunday DATE = '2014-08-03' -- This is Sunday
    DECLARE @Munday DATE = '2014-08-04' -- This is Munday
    SELECT DATEPART(DW,@Sunday),DATEPART(DW,@Munday), @@DATEFIRST
    Can you see the behavior ?
    The results are hidden here (select the text and you will see them)
    DATEFIRST___Sunday_______Monday
    1___________7___________1
    2___________6___________7
    3___________5___________6
    4___________4___________5
    5___________3___________4
    6___________2___________3
    7___________1___________2
    assuming you did the exercise above yourself, then  you can now think now what is the filter that you need...
    You can use a filter on those two parameters together using "where DATEPART... and @@DATEFIRST...) or using one combine check. Can you think how?
    Notice that this value is always 2 on Monday! Regarding our setting
    (DATEPART(DW,@CurrentDate) + @@DATEFIRST) % 7
    Please Don't Go Down Before YOu Understand!
    Now we can go to the solution
    * I really hope that you read all and did the small exercise yourself! You can not become a developer by copy answers, and this is the reason that from the start I only gave you tha way and not the final query!
    DECLARE @CurrentDate DATE = '2007-08-20' -- This is only for testing since you should use the function GETDATE() instead
    DECLARE @MinDateToFilter DATE
    SET @MinDateToFilter = CASE
    WHEN ((DATEPART(DW,@CurrentDate) + @@DATEFIRST) % 7) = 2 THEN DATEADD(DAY,-4,@CurrentDate)
    ELSE DATEADD(DAY,-1,@CurrentDate)
    END
    SELECT *
    FROM sales.salesOrderHeader
    WHERE orderDate > @MinDateToFilter
    I hope this was useful :-)
    [Personal Site] [Blog] [Facebook]

  • SQL query to fetch Online Payslip Details

    Hi All,
    First of all "Happy Diwali" to you all and sorry for asking too much. Actually I need to develope an SQL query which will fetch all the details that appears in online payslip(employee self service) including employee details, earning and deduction elements their value, TAX deducted, absence details etc. And the details should match exactally to our online payslip details.
    I am sure many of you have come across this requirement and have developed this already. If you still have that query could you please pass it to me. I know expecting a readymade sql query would be too much and therefore just let me know all the tables I need use for this so that I can start writting query by my own. Actually any help in this regard will be much appreciated.
    P.S. We are still using 11i :-(
    Thank you all once again,
    Avinash

    Hi All,
    Thank you all for your help on this. The forum was really helpful to get answer of my question. I have almost got answer to all my question. Hence marking this "Answered" :-) I have prepared some sql which fetches the information from PAY_ACTION_INFORMATION for Australia legislation and would like to share it with you all so that you can utalize it if needed.
    ------------ For Employee Details ---------------------------------------
    select pai.action_information1 "Employee"
    ,pai.action_information18 "Employer Name"
    ,pai.action_information10 "Employee Number"
    ,pai.action_information19 "Position"
    ,pai.action_information14 "Assignment Number"
    ,pai.action_information17 "Job"
    ,pai.action_information7 "Grade Step"
    from apps.pay_action_information pai
    where 1 = 1
    and pai.action_information_category = 'EMPLOYEE DETAILS'
    and action_context_id = &action_context_id
    ------------ for IBN Number ----------------------------------------------
    select pai.action_information21 "Employer ABN"
    from apps.pay_action_information pai
    where 1 = 1
    and pai.action_information_category = 'AU EMPLOYEE DETAILS'
    and action_context_id = &action_context_id
    ------- For Balances ------------------------------------------------------
    select pai.action_information1 "Description"
    ,pai.action_information4 "YTD"
    ,pai.action_information5 "This Pay"
    from apps.pay_action_information pai
    where 1 = 1
    and pai.action_information_category = 'APAC BALANCES'
    and action_context_id = &action_context_id
    --------- Taxable Earning ------------------------------
    select pai.action_information1 "Description"
    ,pai.action_information9 "Rate"
    ,pai.action_information5 "This Pay"
    from apps.pay_action_information pai
    where 1 = 1
    and pai.action_information_category = 'APAC ELEMENTS'
    and action_information4 = 'Taxable Earnings'
    and action_context_id = &action_context_id
    ----------- Pre Tax Deduction -------------
    select pai.action_information1 "Description"
    ,pai.action_information5 "This Pay"
    from apps.pay_action_information pai
    where 1 = 1
    and pai.action_information_category = 'APAC ELEMENTS'
    and action_information4 = 'Pre Tax Deductions'
    and action_context_id = &action_context_id
    --------------- Non Taxable Earnings -----------
    select pai.action_information1 "Description"
    ,pai.action_information9 "Rate"
    ,pai.action_information5 "This Pay"
    from apps.pay_action_information pai
    where 1 = 1
    and pai.action_information_category = 'APAC ELEMENTS'
    and action_information4 = 'Non Taxable Earnings'
    and action_context_id = &action_context_id
    --------- for Tax Deductions ----------------------
    select pai.action_information1 "Description"
    ,pai.action_information5 "This Pay"
    from apps.pay_action_information pai
    where 1 = 1
    and pai.action_information_category = 'APAC ELEMENTS'
    and action_information4 = 'Tax Deductions'
    and action_context_id = &action_context_id
    ---------- Post Tax Deductions -----------------
    select pai.action_information1 "Description"
    ,pai.action_information5 "This Pay"
    from apps.pay_action_information pai
    where 1 = 1
    and pai.action_information_category = 'APAC ELEMENTS'
    and action_information4 = 'Post Tax Deductions'
    and action_context_id = &action_context_id
    --------- Employer Superannuation Contributions ----------------------
    select pai.action_information1 "Superannuation Fund Name"
    ,pai.action_information5 "This Pay"
    from apps.pay_action_information pai
    where 1 = 1
    and pai.action_information_category = 'APAC ELEMENTS'
    and action_information4 = 'Employer Superannuation Contributions'
    and action_context_id = &action_context_id
    ----------- Payments -----------------------------
    select pai.action_information18 "Payment Method"
    ,pai.action_information6 "Account Number"
    ,pai.action_information16 "Payment Amount"
    from apps.pay_action_information pai
    where 1 = 1
    and pai.action_information_category = 'EMPLOYEE NET PAY DISTRIBUTION'
    and action_context_id = &action_context_id
    ------------- Other Pay Advice Information ------------
    select pai.action_information14 "Description"
    ,pai.action_information6 "Value"
    from apps.pay_action_information pai
    where 1 = 1
    and pai.action_information_category = 'EMPLOYEE OTHER INFORMATION'
    and action_information2 = 'ELEMENT'
    and action_context_id = &action_context_id
    -------------------- Other Balance Information -----------
    select pai.action_information14 "Description"
    ,pai.action_information6 "Value"
    from apps.pay_action_information pai
    where 1 = 1
    and pai.action_information_category = 'EMPLOYEE OTHER INFORMATION'
    and action_information2 = 'BALANCE'
    and action_context_id = &action_context_id
    ------------------- Pay Period and Salary ------------
    select pai.action_information28 "Annual Salary"
    from apps.pay_action_information pai
    where 1 = 1
    and pai.action_information_category = 'EMPLOYEE DETAILS'
    --and action_information2 = 'BALANCE'
    and action_context_id = &action_context_id
    --------------- Annual Leave Information ------------
    select pai.action_information1 "Name"
    ,decode(pai.action_information5,'D','Day','H','Hours') "Unit"
    ,pai.action_information4 "Balance"
    from apps.pay_action_information pai
    where 1 = 1
    and pai.action_information_category = 'APAC ACCRUALS'
    and action_context_id = &action_context_id
    ----------- Message to Employee -----------
    select pai.action_information6 "Message to Employee"
    from apps.pay_action_information pai
    where 1 = 1
    and action_information_category = 'EMPLOYEE OTHER INFORMATION'
    and action_information2 = 'MESG'
    and action_context_id = &action_context_id
    ---------------- Leave Taken -------------
    select pai.action_information2 "Name"
    ,pai.action_information4 "Start Date"
    ,pai.action_information5 "End Date"
    ,pai.action_information6 "Amount Taken"
    ,pai.action_information8 "This Pay"
    from apps.pay_action_information pai
    where 1 = 1
    and action_information_category = 'APAC ABSENCES'
    and action_context_id = &action_context_id
    Thanks,
    Avinash

  • SQL query requested to pull one field out of multiple records

    Post Author: ralph.devlin
    CA Forum: Data Connectivity and SQL
    We use Track IT to manage our ticket base. We have parent work orders and child assignments that I am trying to report on. What I want to do is create a view, or even if this can be done in a formula, is pull data from the main work order, which in our scnerio and accorindg to the database diagrapm is WORKORDERTYPEID = 0, It will pull the TASKS.RESPONS field from that WO. Then it will compare the TASKS.PARETNWOID to WOID and if WORKORDERTYPEID = 1 then it needs to return the TASKS/RESPONS field of that record, and there may be three records or so. Then What I may need it to do is organize it maybe into seperate columns so I can add each one to Crystal keeping in mind that it will need to link those records to main WOID of the parent so it will display on one line. Any ideas
    Ralph

    Post Author: ralph.devlin
    CA Forum: Data Connectivity and SQL
    Ok I tried that and it seemed to work fine, here is an aexample of the data returned
    168458
    Lane, Carrie
    Ralph Devlin
    Ralph Devlin
    168458
    PHX - Training Room
    SM - 8th Fl Conf Room
    NULL
    NULL
    168458
    6/20/2008 3:30:00 PM
    Video Conference
    0
    168458
    Lane, Carrie
    Ralph Devlin
    Luis Estrada
    168458
    PHX - Training Room
    SM - 8th Fl Conf Room
    NULL
    NULL
    168458
    6/20/2008 3:30:00 PM
    Video Conference
    1
    Using the last column which is the workordertypeid, I was able to elimate the first row of data, which is the parent work order, but see how it is returning the technician name twice, where the second row returns me as the primary and then the technician on the assignment WO as well, which I want. In Crystal I have it only selecting the rows with the 1 is the last column, since those rows have the data arranged how I want them to be.
    Once issue that just arose, is what if we only had one work order that we wanted to report on in the subreport. since the WO will get a 0 in the last column, it will never be selected in the report. Is there a way to either us a statement that selects it if it is the only WO listed compared by the WOID field, or if there is a way in SQL, to get what is showing in row 2 to be the only row returned back so I can then show all work orders regardless if they are an assignment
    Here is my current SQL query
    SELECT     T1.WOID, T1.REQUEST, T1.RESPONS, T2.RESPONS AS Addtech, T2.PARENTWOID, T1.LOOKUP2, T1.TaskLookup3, T1.TaskLookup4, T1.TaskLookup5,                       T1.WO_NUM, T1.DUEDATE, T1.WOTYPE3, T2.WorkOrderTypeIdFROM         dbo.TASKS AS T1 LEFT OUTER JOIN                      dbo.TASKS AS T2 ON T2.PARENTWOID = T1.WOID

  • SQL Query to Fetch 500 Rows at once

    Hi,
      Due to performance issue of the SQL query takes lot of time to execute. I tried modifying the code as mentioned below but it is not working to fetch when search is implemented. Actually data is more than 1 Million Records so it takes lot of time to query the data.
    SELECT DISTINCT
    IMV.*,
      nvl(imv.party_name,imv.bill_to_name) "Bill To Name",
      Imv.Ship_To_City "Reseller City",
      Imv.Ship_To_State "Reseller State",
      Edb2_Global.Country_Name_Theater(Imv.Ship_To_Country ,'COUNTRY') "Reseller Country",
      Edb2_Global.Country_Name_Theater(Imv.Ship_To_Country ,'THEATER') "Reseller Theater",
      Cl.City "Customer City",
      Cl.State "Customer State",
      EDB2_GLOBAL.COUNTRY_NAME_THEATER(CL.COUNTRY,'COUNTRY') "Customer Country",
      EDB2_GLOBAL.COUNTRY_NAME_THEATER(CL.COUNTRY,'THEATER') "Customer Theater"
    FROM IB_SUPPORT_CONTRACTS_MV IMV,
      customer_products cp,
      customer_locations cl
    WHERE
    UPPER(TRIM(IMV.SERIAL_NUMBER)) = UPPER(TRIM(CP.PRODUCT_SERIAL_NUMBER(+) ) )
    AND CP.LOCATION_ID                     = CL.LOCATION_ID(+)
    AND ROWNUM <= 501
    Please suggest me how to improve the performance of the query.
    Thanks
    Sudhir

    Hi,
    As mentioned already, this condition is really hurting performance:
    UPPER(TRIM(IMV.SERIAL_NUMBER)) = UPPER(TRIM(CP.PRODUCT_SERIAL_NUMBER(+) ) )
    Could you trim and capitalize the serial numbers before storing them?  Do you really need to remember exactly how the serial numbers were entered?  If you really do, then store it in one column, and store UPPER (TRIM (serial_number)) in a different column.  Starting in Oracle 11, this could be a virtual column; in any version (7 or higher), it could be maintained by a trigger.  Failing that, create a function-based index on UPPER (TRIM (serial_number)).

  • SQL query to fetch as count manytimes

    Hi All,
    greetings for the day.
    i am using 10g details herewith:
    Version
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod
    PL/SQL Release 10.2.0.2.0 - Production,CORE 10.2.0.2.0 Production,TNS for 32-bit Windows: Version 10.2.0.2.0 - Production
    create table bsl_citi ( col_1 number primary key,
    col_2 varchar2(10) not null,
    col_3 number
    insert into bsl_citi values (1,'india',3);
    insert into bsl_citi values (2,'USA',2);
    insert into bsl_citi values (3,'USSR',1);
    insert into bsl_citi values (4,'NEPAL',0);
    insert into bsl_citi values (5,'NwYrk',2);
    commit;
    OUTPUT
    COL_1 COL_2 COL_3
    1 india 3
    2 USA 2
    3 USSR 1
    4 NEPAL 0
    5 NwYrk 2
    Expected Output
    COL_1 COL_2 COL_3
    1 india 3
    1 india 3
    1 india 3
    2 USA 2
    2 USA 2
    3 USSR 1
    5 NwYrk 2
    5 NwYrk 2
    (i.e., the number in COL_3 that many times should repeat)
    thanks in advance

    Can you please explain me your query
    SELECT *
    FROM (SELECT b.*,
    ROW_NUMBER () OVER (PARTITION BY col_1 ORDER BY col_1) r
    FROM bsl_citi b
    CONNECT BY 1 = 1 AND LEVEL <= col_3)
    WHERE r <= col_3
    in-line-view which consider the level inside the query. the value in the COL_3 less than or equal many times we have to fetch that was he wrote.
    i guess kiran will respond somewhat clear than this,
    thanks

  • SQL Query CASE statement using two fields

    Hi,
    I have two fields. One is called rescategory1, the other is called rescategory2.
    I'm not sure if its a CASE statement I need or some sort of WHERE clause but I want to create a query that does the following or something similar:
    CASE rescategory2
    WHEN rescategory1 = '44' AND rescategory2 = '1' THEN 'Backup'
    WHEN rescategory1 = '44' AND rescategory2 = '2' THEN 'Hardware'
    END AS [Resolution Sub Category]
    Basically, I'm looking to give rescategory2 a value based on that of rescategory1 and rescategory2 combined.
    How do I write this?
    Cheers
    Paul

    do you mean this?
    rescategory2 = CASE
    WHEN rescategory1 = '44' AND rescategory2 = '1' THEN 'Backup'
    WHEN rescategory1 = '44' AND rescategory2 = '2' THEN 'Hardware'
    END
    ie assigning value for rescategory2
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Maybe you are looking for

  • Spry Conditional Validation

    Hello, I am using Spry Pre-Release 1.6.1. Here is what I am trying to do: A user makes some input. Based on that input I am showing 5 additional fields that now must be required. I can get this to work on the first field( spryselect4) but not on any

  • Disable Clamshell Mode?

    Currently, I have a 3rd generation MacBook Pro hooked up to an external TV via the DVI output. When I close the laptop lid, the external TV becomes the primary (and only) active monitor, while the laptop stays awake. I believe this is called Clamshel

  • Why can't I log in to my aol email

    I keep getting the message my password is wrong but I know it is not

  • Return to the caller

    Dear My program consists of several sub-vi(s) for serial communication. Could you let me know how can I remove the "return to a caller" button without stopping the sub-vi? (see my attachment, I have never seen the button in my labview programming.) T

  • Custom tranparent folder icons

    Hi. I was wondering how I get folders to support custom transparent icons. I know how to copy an image to the clipboard and paste it to the destination icon it the Get Info window. What I want to do now is incorporate transparent pixels so I can make