IN clause help

Hello,
Could someone please give me an example of how to handle the following with a IN clause:
IN ('Jim O'Grady', 'Vinny D'Esponosso')
The ' in the last name is causing problems in my where clause.
Any help would be greatly appreciated.
Thanks,
Tim
x

To clarify:
You need to escape the encapsulation character. In this case, it's ' (single quote). Unfortunately single quote is also the escape character, which makes it appear more difficult than it is.
' ALWAYS becomes '' (escape the ' with a '). It gets muddy when this is at the begining or end, as you need to escape the character, then add the character itself and finally open/close the encapsulation:
'(open the encapsulation)'(escape)'(the character) or '(escape)'(the character)'(close the encapsulation): '''Dog''' 
But what about when all you want is a single quote? Don't panic, I've got you:
Yep. '(open the encapsulation)'(escape the following character)'(the character)'(close the encapsulation)
Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

Similar Messages

  • Case Statement in a Where clause help

    Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    "CORE     11.2.0.1.0     Production"
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    Hello,
    I have an APEX application that I need to build a SQL statement for a LOV (List of Values). I have a hidden filed that contains the customer type which can be an 'R' or 'B'. The query needs to be able to display two different result sets based on the customer type of 'R' or 'B'.
    If the customer type is 'R' then:
    SELECT drg_descr d, drg_code r
    FROM distance_ranges
    WHERE  drg_min_miles IN (0,5)
    ORDER BY drg_min_milesIf the customer type is 'B' then:
    SELECT drg_descr d, drg_code r
    FROM distance_ranges
    WHERE  drg_min_miles IN (0,5,10,15,20)
    ORDER BY drg_min_milesCan someone help me with what I think needs to be a case statement?
    Thanks,
    Joe

    Hi,
    You can try CASE statement with WHERE clause
    SELECT drg_descr d, drg_code r
    FROM distance_ranges
    WHERE (CASE param_cust_type
    WHEN(param_cust_type='R') THEN (drg_min_miles IN (0, 5)
    WHEN (param_cust_type='B') THEN (drg_min_miles IN (0,5,10,15,20)
    END;
    Please try and let me know if anything wrong.
    Anyone from the forum comment my code if there is any wrong.
    Thanks!
    Naresh

  • Where clause help.

    Hi,
    I have table with a partition on a column of date data type. Each partition has a month's data in it. I use the following query to fetch the data:
    select column1, column2
    from table1 partition(apr2011)
    where trunc(date_column) = '01-APR-11';
    The query works fast when partition has less records(data for 10-15 days). But as the number of records in the partition increases(at month end), the time taken to retrieve the result is much more. Request you to please help me with an alternative for the 'where clause' to get faster data.
    Thanks.

    Thanks Mohamed,
    Finally the coin dropped
    SQL> CREATE TABLE sales_range
    (salesman_id  NUMBER(5),
    sales_date    DATE)
    PARTITION BY RANGE(sales_date)
    PARTITION sales_jan2000 VALUES LESS THAN(TO_DATE('02/01/2000','MM/DD/YYYY')),
    PARTITION sales_feb2000 VALUES LESS THAN(TO_DATE('03/01/2000','MM/DD/YYYY')),
    PARTITION sales_mar2000 VALUES LESS THAN(TO_DATE('04/01/2000','MM/DD/YYYY')),
    PARTITION sales_apr2000 VALUES LESS THAN(TO_DATE('05/01/2000','MM/DD/YYYY'))
    Table created.
    SQL> set autotrace traceonly explain
    SQL> SELECT * FROM   sales_range
    WHERE  sales_date = TO_DATE ( '03/01/2000', 'MM/DD/YYYY');
    no rows selected.
    Execution Plan
       0       SELECT STATEMENT Optimizer Mode=ALL_ROWS (Cost=2 Card=1 Bytes=97)
       1    0    PARTITION RANGE SINGLE (Cost=2 Card=1 Bytes=97)
       2    1      TABLE ACCESS FULL KORT.SALES_RANGE (Cost=2 Card=1 Bytes=97)
    SQL> SELECT * FROM   sales_range
    WHERE  TRUNC (sales_date) = TO_DATE ( '03/01/2000', 'MM/DD/YYYY');
    no rows selected.
    Execution Plan
       0       SELECT STATEMENT Optimizer Mode=ALL_ROWS (Cost=2 Card=1 Bytes=97)
       1    0    PARTITION RANGE ALL (Cost=2 Card=1 Bytes=97)
       2    1      TABLE ACCESS FULL KORT.SALES_RANGE (Cost=2 Card=1 Bytes=97)
    Your explanation If using TRUNC, you don't get partition elimination
    Regards
    Peter

  • WOuld Analytic Windowing Clause help solve this?

    I've been using some basic analytic functions for a little while now. Trying to do something that I don't know if it's syntactically legal...or if maybe I'm just approaching it the wrong way.
    I have a situation like this...
    with t1 as
    (SELECT 1 AS id , 1 AS value_1, 'Y' valid_1 , 12 AS value_2 , 'N' valid_2 , 38 AS value_3 , 'N' valid_3 , 45 AS value_4 , 'Y' valid_4 FROM dual
    UNION ALL
    SELECT 2 AS id , 3 AS value_1, 'N' valid_1 , 7 AS value_2 , 'Y' valid_2 , 13 AS value_3 , 'Y' valid_3 , 19 AS value_4 , 'N' valid_4 FROM dual)
    select
      id,
      pivot,
      pivoted_value,
      pivoted_valid,
      max(pivoted_value) over (partition by id
                               order by pivot
                              ) as analytic_expr
    from (
    select
      t1.id,
      t2.pivot,
      case t2.pivot
        when 1 then t1.value_1
        when 2 then t1.value_2
        when 3 then t1.value_3
        when 4 then t1.value_4
      end as pivoted_value,
      case t2.pivot
        when 1 then t1.valid_1
        when 2 then t1.valid_2
        when 3 then t1.valid_3
        when 4 then t1.valid_4
      end as pivoted_valid
    from t1, (select rownum pivot from dual connect by rownum < 5) t2
            ID      PIVOT PIVOTED_VALUE P ANALYTIC_EXPR
             1          1             1 Y             1
             1          2            12 N            12
             1          3            38 N            38
             1          4            45 Y            45
             2          1             3 N             3
             2          2             7 Y             7
             2          3            13 Y            13
             2          4            19 N            19...which get's me close to what I'm looking to do. But rather than having a running max, I'd need it to increment only when the value is "valid". So for row 2 above, the value of analytic_expr should stay 1 for rows 2,3. Row 5 should be null (or some other defautable value), and the last row should stay at 13.
    Does <where pivot_value = 'Y'> translate into some useable windowing clause, or so I have to do something a little less elegant?

    Mentioning that values 1-4 are always increasing would probably made my statement sensible.
    If pivoted_valid(X) = 'Y' (column name name got copped to "P" for some reason)
    Then pivoted_value(x) ....which will also be the current max if they're ordered in
    Else the max(pivoted_value(<x))
    This is how I would want the results to look...
    ID   PIVOT    VAL   VALID    CURRENT_MAX_VAL
    1     1     1     Y     1
    1     2     12     N     1    --since not valid, no change to prior
    1     3     38     N     1     --since not valid, no change to prior
    1     4     45     Y     45
    2     1     3     N     nulll    --since not valid and no prior row
    2     2     7     Y     7
    2     3     13     Y     13
    2     4     19     N     13   --since not valid, no change to priorI know I could probably do this with a CASE/LAG combo of some sort. I was just wondering how fancy a person could get with windowing.

  • Dynamic query, where clause help

    Hi Folks,
    Using my code below to generate a query.
    When using more than one condition, I'm not sure how to work out where the AND goes.
    Can anyone please help?
    Thankyou
    WHERE
    <cfif stafffilter neq "">
    deviceofficer = #stafffilter#
    </cfif>
    <cfif assetid neq "">
    AND deviceasset = '#assetid#'
    </cfif>
    <cfif isdefined("noasset")>
    AND deviceasset = ''
    </cfif>
      <cfif  isdefined("noserial")>
    AND deviceserial = ''
    </cfif>
    <cfif serial neq "">
    AND deviceserial = '#serial#'
    </cfif>
    <cfif servicearea neq "">
    AND deviceservice = #servicearea#
    </cfif>
    ORDER by locationname

    I do this sort of thing:
    <cfset sWhereAnd = "WHERE">
    <cfif isdefined("colFilter")>
         #sWhereAnd# col = #colFilter#
        <cfset sWhereAnd = "AND">
    </cfif>
    <cfif isdefined("someOtherColFilter")>
         #sWhereAnd# someOtherCol = #someOtherColFilter#
        <cfset sWhereAnd = "AND">
    </cfif>
    [etc]
    (that's pseudocode... I'd never use isDefined() or not use a <cfqueryparam> tag for my parameter values).
    I don't like doing the somewhat popular WHERE 1=1 approach as it can force a full table scan (all rows in the table will match that, and each WHERE filter expression is applied to every row of the table being filtered), unless the DB optimises it out as noise (which is what it is).  To me it's using bad SQL to cut corners.
    To be honest though, I shy away from these generic sort of queries these days.  Most of the genericism never gets used, and more specific requirements are better implemented to meet the precise need.
    Adam

  • SQL with large IN clause - help

    Hi,
    I have a following query. the problem is that the I need to pass 3000+ values in the IN statement. Is there a better way of writing this?
    the pk1 column has 60,000 distinct values and total number or records are in millions.
    I also need the results very quick.
    select * from tablename
    where pk1 in ('a','b','c' ..... 3000 values)
    and pk2 = value2
    thanks

    > I get the values from a file. They are not in a database table.
    I can put them but don't think that is elegant and fast solution.
    Why then use a database at all if you think that values in a file is a more elegant and faster solution?
    Why not put all your data in files? Surely, according to your opinion, that will very much be an elegant and a very fast solution. Not to mention a cheap one too as you do not have to pay for Oracle.
    Or do you perhaps think there are reasons why no-one has been doing this since the days of ISAM files back the early 80's? And why databases have been used since instead?

  • Disable/Hide the Refresh Button in Child report

    Hi All,
    Our Environment is BOXI-R2;
    We have a Master Report calling a Child Report (based on Open Document);
    Our requirement is to hide the" Refresh Button "in the child report Layout
    we tried using "hideRefresh=true"
    but the child report is not responding to the above clause
    Help us in this,
    if this is a BUG in XI R2, let us know the Service Pack details
    Thanks

    Joe , Thanks for your Inputs..
    our master report has the aggregated Measure , when the user clicks on this , it has to open a child report (with paramters from master report).
    We are aware of customizing "viewer.js " file (under BO install home) with "refreshDocIcon = null".
    But is this the only solution to hide the refresh button in the child report ?
    SInce its already a PRODUCTION environment, our customer won't allow to change the standard settings of the product.
    Thanks

  • Using row-wise multi-value GROUP system session variable in report filter

    The title says it all except I am using 10g OBIEE.
    What I want to do is filter on the dynamic system session variable GROUP created in a row-wise initialization block.
    The GROUP vriable is being set up correctly and it shows the user dynamically put into the correct groups in Answers.
    (Using the admin tool and looking at the user session, only the initial authentication block variables show up.)
    But if I want to filter using the value of GROUP it doesn't work.
    The obvious way is to choose the filter icon, then choose Add -> Variable -> Session, enter GROUP, and then display results.
    It comes back with no rows.
    Any idea how to do this? I've tried lots of things but none of them work either producing no rows or an error.
    This is the kind of Answers SQL this report is resulting in, which makes sense to me, but produces no rows.
    SELECT "Package Virtual Group (Dim)"."Package Virtual Group" saw_0, "Contact (Fact)"."Contacts All Count" saw_1 FROM "Case/Transaction/ABC" WHERE "Package Virtual Group (Dim)"."Package Virtual Group" = VALUEOF(NQ_SESSION."GROUP") ORDER BY saw_0

    866038 wrote:
    Errors come from trying things that don't work.
    For example, instead of =, using IN VALUEOF(NQ_SESSION.GROUP) or @{session.GROUP} or lots of other things.
    The question is this:
    how can I filter a column in Answers using the GROUP session variable which had been initialized in a row-wise initialization block?
    I can find no way to do it. Mostly it returns no rows.Hi,
    we had a similar requirement, where we have an external name that has project number values. We used row wise initialization to capture all the projects that a user belongs to. Then, we applied the filters at the RPD level, instead of doing it at the report level. From you requirement I see that you are trying to filter the groups based on user login. When a user logs in, he will see the information about the groups that he only belongs to. Correct me if I am wrong here.
    Assuming I am right about your requirement, providing the filter that you need apply in RPD.
    On all the fact tables are joined to the Package Virtual Group dimension, apply the below filter.
    case when 1=1 then (Dim)"."Package Virtual Group" END = VALUEOF(NQ_SESSION."GROUP");
    The reason for use of case statement here is, it converts the logical sql to IN Clause, helping us acheive the exact query that we would want.
    Please Award points if this helps.
    Thanks,
    -Amith.

  • Re: (forte-users) access violation caught in debugmode

    Eric,
    There has been a problem with Forte debug mode for sometime now when the app
    is silent. If you attempt to inspect the variables when the app is in the
    'silent' mode, i.e., waiting on an event loop for a user input or a system
    event, then you get the "Access violation caught ..." exception message and
    the workspace including the launch server crashes.
    If you are getting this problem in the 'step-through' mode, you should look
    at the lauch server immediately after you get the exception before
    everything disappears. There could be a stack backtrace due to some illegal
    reference. We have faced a similar situation before but the error appeared
    both in the 'debug' and 'run' modes.
    Hope this helps.
    Braja K Chattaraj.
    From: Eric Decossaux <[email protected]>
    To: forte mailing <[email protected]>
    Subject: (forte-users) access violation caught in debug mode
    Date: Thu, 23 Sep 1999 17:31:39 +0200
    Hello,
    I have a problem using Forte in debug mode. If I run my program on my NT
    machine from the partition workshop (distributed run), the program works
    fine except that some object does not display what I'm expecting. So I
    want to use the debug mode to inspect the objets of this window. When I
    choose the "local variables" option to see the content of my window, I
    have a "access violation caught" and forte disappears. If I just let my
    program run without choosing this option, everything is the same than
    with the distributed run.
    Does somebody have an idea what to look for ? I really want to look the
    inside the attributes of this window.
    We recently upgraded from release 30G2 to release 30L2. Could it be the
    problem ?
    Eric Decossaux
    Cliniques Universitaires St Luc
    Informatique des Laboratoires
    av Hippocrate 10 / 1730
    1200 Bruxelles
    +32+2+764 17 53
    For the archives, go to: http://lists.sageit.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: [email protected]

    Eric,
    Another possibility has to do with the repository. You said you recently
    migrated 30G2 to release 30L2.
    Many strange problems have been traced to release migrations with old
    repositories. If the repository was properly migrated another thing you can try
    is to export the project(s) to PEX files, delete them from the repository, and
    then re-import. I know this can be time consuming but I have solved more than
    one unexplained problem in the IDE by doing it.
    ---------------------- Forwarded by Charlie Shell/Bsg/MetLife/US on 09/23/99
    01:19 PM ---------------------------
    "Ajith Kallambella" <[email protected]> on 09/23/99 12:08:54 PM
    To: [email protected], [email protected]
    cc: (bcc: Charlie Shell/Bsg/MetLife/US)
    Subject: Re: (forte-users) access violation caught in debug mode
    Eric,
    Sometimes( 90% ) you can solve this problem by
    checking out the class that is causing the crash
    and force-compiling it.
    If it doesn't help, run through this checklist.
    1. Do you have enough memory resources.?
    2. Is the object you are inspecting held in a lock ?
    ( mutex, transaction lock etc )
    3. Does it work when you wait for sometime at the
    breakpoint before inspecting the values? I mean
    are you interrupting some process thread?
    4. Does it work if you log the attributes using logmgr?
    5. Are you using any call-outs/call-ins? Any external
    systems integration? Sometimes( for reasons beyond
    my comprehension ) the objects allocated outside
    Forte gets corrupted when its passed back and forth.
    6. ...finally...Santa Clause, help me!
    Ajith Kallambella M.
    Forte Systems Consultant.
    From: Eric Decossaux <[email protected]>
    To: forte mailing <[email protected]>
    Subject: (forte-users) access violation caught in debug mode
    Date: Thu, 23 Sep 1999 17:31:39 +0200
    Hello,
    I have a problem using Forte in debug mode. If I run my program on my NT
    machine from the partition workshop (distributed run), the program works
    fine except that some object does not display what I'm expecting. So I
    want to use the debug mode to inspect the objets of this window. When I
    choose the "local variables" option to see the content of my window, I
    have a "access violation caught" and forte disappears. If I just let my
    program run without choosing this option, everything is the same than
    with the distributed run.
    Does somebody have an idea what to look for ? I really want to look the
    inside the attributes of this window.
    We recently upgraded from release 30G2 to release 30L2. Could it be the
    problem ?
    Eric Decossaux
    Cliniques Universitaires St Luc
    Informatique des Laboratoires
    av Hippocrate 10 / 1730
    1200 Bruxelles
    +32+2+764 17 53
    For the archives, go to: http://lists.sageit.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: [email protected]
    For the archives, go to: http://lists.sageit.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: [email protected]

  • ORA-19279 error extracting one-to-many sequence

    I have an xml table built from a registered schema that I'm trying to extract data from using a view. The lowest level is a polygon with multiple vertices -- vertices number, latitude, and longitude. The xml file lists data as
    POLYGON
    SEQ_NUM
    LAT
    LON
    SEQ_NUM
    LAT
    LON
    SEQ_NUM
    LAT
    LON
    /POLYGON
    The method I use to extract the data returns an ORA-19279 error: "XQuery dymanic type mismatch: expected singleton sequence - got multi-item sequence." The error is pointing to the polygon data; however the polygon sequence tag in the xsd file has the attribute of maxOccurs="unbounded".
    Below is the xsd file, a samlpe xml file and the Select statement I use.
    ABC.xsd file:
    &lt;?xml version="1.0"?&gt;
    &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified" attributeFormDefault="unqualified"&gt;
    &lt;xs:element name="A_B_C"&gt;
    &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
    &lt;xs:element name="A"&gt;
    &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
    &lt;xs:element name="B"&gt;
    &lt;xs:simpleType&gt;
    &lt;xs:restriction base="xs:string"&gt;
    &lt;xs:enumeration value="1A"/&gt;
    &lt;xs:enumeration value="1B"/&gt;
    &lt;xs:enumeration value="2A"/&gt;
    &lt;xs:enumeration value="2B"/&gt;
    &lt;xs:enumeration value="2C"/&gt;
    &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;
    &lt;/xs:element&gt;
    &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
    &lt;xs:choice&gt;
    &lt;xs:element name="D" maxOccurs="unbounded"&gt;
    &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
    &lt;xs:element name="D_ID" type="xs:string"&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name="D_UQ_ID" type="xs:string"&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name="D_TIME"&gt;
    &lt;xs:simpleType&gt;
    &lt;xs:restriction base="xs:string"/&gt;
    &lt;/xs:simpleType&gt;
    &lt;/xs:element&gt;
    &lt;xs:choice&gt;
    &lt;xs:element name="F"&gt;
    &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
    &lt;xs:element name="F_TYPE" type="xs:string"&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name="F_SUBTYPE" type="xs:string"&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name="G" minOccurs="0"&gt;
    &lt;xs:complexType&gt;
    &lt;xs:choice&gt;
    &lt;xs:element name="H"&gt;
    &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
    &lt;xs:element name="H_TYPE" type="xs:string" minOccurs="0"&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name="H_MODE" type="xs:string" minOccurs="0"&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name="H_SHAPE" minOccurs="0"&gt;
    &lt;xs:complexType&gt;
    &lt;xs:choice&gt;
    &lt;xs:element name="POLYGON"&gt;
    &lt;xs:complexType&gt;
    {color:#ff0000}*&lt;xs:sequence maxOccurs="unbounded"&gt;*{color}
    &lt;xs:element name="SEQ_NUM" type="xs:unsignedInt"&gt;
    &lt;xs:annotation&gt;
    &lt;xs:documentation&gt;sequence number in the polygon&lt;/xs:documentation&gt;
    &lt;/xs:annotation&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name="LAT" type="xs:float"/&gt;
    &lt;xs:element name="LON" type="xs:float"/&gt;
    &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name="CIRCLE"&gt;
    &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
    &lt;xs:element name="LAT" type="xs:float"/&gt;
    &lt;xs:element name="LON" type="xs:float"/&gt;
    &lt;xs:element name="RAD" type="xs:float"/&gt;
    &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name="ELLIPSE"&gt;
    &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
    &lt;xs:element name="ORIENT"&gt;
    &lt;xs:simpleType&gt;
    &lt;xs:restriction base="xs:float"&gt;
    &lt;xs:minInclusive value="0"/&gt;
    &lt;xs:maxInclusive value="360"/&gt;
    &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name="MAJ_AX" type="xs:float"&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name="MIN_AX" type="xs:float"&gt;
    &lt;/xs:element&gt;
    &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
    &lt;/xs:choice&gt;
    &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
    &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
    &lt;/xs:choice&gt;
    &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
    &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name="E"&gt;
    &lt;xs:complexType/&gt;
    &lt;/xs:element&gt;
    &lt;/xs:choice&gt;
    &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
    &lt;xs:element name="C"&gt;
    &lt;/xs:element&gt;
    &lt;/xs:choice&gt;
    &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
    &lt;/xs:schema&gt;
    abc.xml file:
    &lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;A_B_C&gt;
    &lt;A&gt;
    &lt;B&gt;1B&lt;/B&gt;
    &lt;/A&gt;
    &lt;D&gt;
    &lt;D_ID&gt;D_0001&lt;/D_ID&gt;
    &lt;D_UQ_ID&gt;UQ_D_0001&lt;/D_UQ_ID&gt;
    &lt;D_TIME&gt;2007 FEB 11:11:11.11&lt;/D_TIME&gt;
    &lt;F&gt;
    &lt;F_TYPE&gt;F_TYPE_TEST&lt;/F_TYPE&gt;
    &lt;F_SUBTYPE&gt;SUB_TEST&lt;/F_SUBTYPE&gt;
    &lt;G&gt;
    &lt;H&gt;
    &lt;H_TYPE&gt;Ipod&lt;/H_TYPE&gt;
    &lt;H_MODE&gt;SCANNING&lt;/H_MODE&gt;
    &lt;H_SHAPE&gt;
    &lt;POLYGON&gt;
    &lt;SEQ_NUM&gt;1&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;10.1&lt;/LAT&gt;
    &lt;LON&gt;11.1&lt;/LON&gt;
    &lt;SEQ_NUM&gt;2&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;20.2&lt;/LAT&gt;
    &lt;LON&gt;22.2&lt;/LON&gt;
    &lt;SEQ_NUM&gt;3&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;30.3&lt;/LAT&gt;
    &lt;LON&gt;33.3&lt;/LON&gt;
    &lt;SEQ_NUM&gt;4&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;40.4&lt;/LAT&gt;
    &lt;LON&gt;44.4&lt;/LON&gt;
    &lt;/POLYGON&gt;
    &lt;CIRCLE&gt;
    &lt;LAT&gt;12.3&lt;/LAT&gt;
    &lt;LON&gt;45.6&lt;/LON&gt;
    &lt;RAD&gt;78.9&lt;/RAD&gt;
    &lt;/CIRCLE&gt;
    &lt;ELLIPSE&gt;
    &lt;ORIENT&gt;99.90&lt;/ORIENT&gt;
    &lt;MAJ_AX&gt;111.10&lt;/MAJ_AX&gt;
    &lt;MIN_AX&gt;222.20&lt;/MIN_AX&gt;
    &lt;/ELLIPSE&gt;
    &lt;/H_SHAPE&gt;
    &lt;/H&gt;
    &lt;/G&gt;
    &lt;/F&gt;
    &lt;E&gt;&lt;/E&gt;
    &lt;/D&gt;
    &lt;D&gt;
    &lt;D_ID&gt;D_0002&lt;/D_ID&gt;
    &lt;D_UQ_ID&gt;UQ_D_0002&lt;/D_UQ_ID&gt;
    &lt;D_TIME&gt;2007 FEB 22:22:22.22&lt;/D_TIME&gt;
    &lt;F&gt;
    &lt;F_TYPE&gt;F_TYPE_TEST&lt;/F_TYPE&gt;
    &lt;F_SUBTYPE&gt;SUB_TEST&lt;/F_SUBTYPE&gt;
    &lt;G&gt;
    &lt;H&gt;
    &lt;H_TYPE&gt;Ipod&lt;/H_TYPE&gt;
    &lt;H_MODE&gt;SCANNING&lt;/H_MODE&gt;
    &lt;H_SHAPE&gt;
    &lt;POLYGON&gt;
    &lt;SEQ_NUM&gt;1&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;10.1&lt;/LAT&gt;
    &lt;LON&gt;11.1&lt;/LON&gt;
    &lt;SEQ_NUM&gt;2&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;20.2&lt;/LAT&gt;
    &lt;LON&gt;22.2&lt;/LON&gt;
    &lt;SEQ_NUM&gt;3&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;30.3&lt;/LAT&gt;
    &lt;LON&gt;33.3&lt;/LON&gt;
    &lt;SEQ_NUM&gt;4&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;40.4&lt;/LAT&gt;
    &lt;LON&gt;44.4&lt;/LON&gt;
    &lt;/POLYGON&gt;
    &lt;CIRCLE&gt;
    &lt;LAT&gt;12.3&lt;/LAT&gt;
    &lt;LON&gt;45.6&lt;/LON&gt;
    &lt;RAD&gt;78.9&lt;/RAD&gt;
    &lt;/CIRCLE&gt;
    &lt;ELLIPSE&gt;
    &lt;ORIENT&gt;99.90&lt;/ORIENT&gt;
    &lt;MAJ_AX&gt;111.10&lt;/MAJ_AX&gt;
    &lt;MIN_AX&gt;222.20&lt;/MIN_AX&gt;
    &lt;/ELLIPSE&gt;
    &lt;/H_SHAPE&gt;
    &lt;/H&gt;
    &lt;/G&gt;
    &lt;/F&gt;
    &lt;E&gt;&lt;/E&gt;
    &lt;/D&gt;
    &lt;D&gt;
    &lt;D_ID&gt;D_0003&lt;/D_ID&gt;
    &lt;D_UQ_ID&gt;UQ_D_0003&lt;/D_UQ_ID&gt;
    &lt;D_TIME&gt;2007 FEB 33:33:33.33&lt;/D_TIME&gt;
    &lt;F&gt;
    &lt;F_TYPE&gt;F_TYPE_TEST&lt;/F_TYPE&gt;
    &lt;F_SUBTYPE&gt;SUB_TEST&lt;/F_SUBTYPE&gt;
    &lt;G&gt;
    &lt;H&gt;
    &lt;H_TYPE&gt;Ipod&lt;/H_TYPE&gt;
    &lt;H_MODE&gt;SCANNING&lt;/H_MODE&gt;
    &lt;/H&gt;
    &lt;/G&gt;
    &lt;/F&gt;
    &lt;E&gt;&lt;/E&gt;
    &lt;/D&gt;
    &lt;D&gt;
    &lt;D_ID&gt;D_0004&lt;/D_ID&gt;
    &lt;D_UQ_ID&gt;UQ_D_0004&lt;/D_UQ_ID&gt;
    &lt;D_TIME&gt;2007 FEB 44:44:44.44&lt;/D_TIME&gt;
    &lt;F&gt;
    &lt;F_TYPE&gt;F_TYPE_TEST&lt;/F_TYPE&gt;
    &lt;F_SUBTYPE&gt;SUB_TEST&lt;/F_SUBTYPE&gt;
    &lt;G&gt;
    &lt;H&gt;
    &lt;H_TYPE&gt;Ipod&lt;/H_TYPE&gt;
    &lt;H_MODE&gt;SCANNING&lt;/H_MODE&gt;
    &lt;H_SHAPE&gt;
    &lt;POLYGON&gt;
    &lt;SEQ_NUM&gt;1&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;10.1&lt;/LAT&gt;
    &lt;LON&gt;11.1&lt;/LON&gt;
    &lt;SEQ_NUM&gt;2&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;20.2&lt;/LAT&gt;
    &lt;LON&gt;22.2&lt;/LON&gt;
    &lt;SEQ_NUM&gt;3&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;30.3&lt;/LAT&gt;
    &lt;LON&gt;33.3&lt;/LON&gt;
    &lt;SEQ_NUM&gt;4&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;40.4&lt;/LAT&gt;
    &lt;LON&gt;44.4&lt;/LON&gt;
    &lt;/POLYGON&gt;
    &lt;CIRCLE&gt;
    &lt;LAT&gt;12.3&lt;/LAT&gt;
    &lt;LON&gt;45.6&lt;/LON&gt;
    &lt;RAD&gt;78.9&lt;/RAD&gt;
    &lt;/CIRCLE&gt;
    &lt;ELLIPSE&gt;
    &lt;ORIENT&gt;99.90&lt;/ORIENT&gt;
    &lt;MAJ_AX&gt;111.10&lt;/MAJ_AX&gt;
    &lt;MIN_AX&gt;222.20&lt;/MIN_AX&gt;
    &lt;/ELLIPSE&gt;
    &lt;/H_SHAPE&gt;
    &lt;/H&gt;
    &lt;/G&gt;
    &lt;/F&gt;
    &lt;E&gt;&lt;/E&gt;
    &lt;/D&gt;
    &lt;D&gt;
    &lt;D_ID&gt;D_0005&lt;/D_ID&gt;
    &lt;D_UQ_ID&gt;UQ_D_0005&lt;/D_UQ_ID&gt;
    &lt;D_TIME&gt;2007 FEB 55:55:55.55&lt;/D_TIME&gt;
    &lt;F&gt;
    &lt;F_TYPE&gt;F_TYPE_TEST&lt;/F_TYPE&gt;
    &lt;F_SUBTYPE&gt;SUB_TEST&lt;/F_SUBTYPE&gt;
    &lt;/F&gt;
    &lt;E&gt;&lt;/E&gt;
    &lt;/D&gt;
    &lt;D&gt;
    &lt;D_ID&gt;D_0006&lt;/D_ID&gt;
    &lt;D_UQ_ID&gt;UQ_D_0006&lt;/D_UQ_ID&gt;
    &lt;D_TIME&gt;2007 FEB 66:66:66.66&lt;/D_TIME&gt;
    &lt;F&gt;
    &lt;F_TYPE&gt;F_TYPE_TEST&lt;/F_TYPE&gt;
    &lt;F_SUBTYPE&gt;SUB_TEST&lt;/F_SUBTYPE&gt;
    &lt;G&gt;
    &lt;H&gt;
    &lt;H_TYPE&gt;Ipod&lt;/H_TYPE&gt;
    &lt;H_MODE&gt;SCANNING&lt;/H_MODE&gt;
    &lt;H_SHAPE&gt;
    &lt;POLYGON&gt;
    &lt;SEQ_NUM&gt;1&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;10.1&lt;/LAT&gt;
    &lt;LON&gt;11.1&lt;/LON&gt;
    &lt;SEQ_NUM&gt;2&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;20.2&lt;/LAT&gt;
    &lt;LON&gt;22.2&lt;/LON&gt;
    &lt;SEQ_NUM&gt;3&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;30.3&lt;/LAT&gt;
    &lt;LON&gt;33.3&lt;/LON&gt;
    &lt;SEQ_NUM&gt;4&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;40.4&lt;/LAT&gt;
    &lt;LON&gt;44.4&lt;/LON&gt;
    &lt;/POLYGON&gt;
    &lt;CIRCLE&gt;
    &lt;LAT&gt;12.3&lt;/LAT&gt;
    &lt;LON&gt;45.6&lt;/LON&gt;
    &lt;RAD&gt;78.9&lt;/RAD&gt;
    &lt;/CIRCLE&gt;
    &lt;ELLIPSE&gt;
    &lt;ORIENT&gt;99.90&lt;/ORIENT&gt;
    &lt;MAJ_AX&gt;111.10&lt;/MAJ_AX&gt;
    &lt;MIN_AX&gt;222.20&lt;/MIN_AX&gt;
    &lt;/ELLIPSE&gt;
    &lt;/H_SHAPE&gt;
    &lt;/H&gt;
    &lt;/G&gt;
    &lt;/F&gt;
    &lt;E&gt;&lt;/E&gt;
    &lt;/D&gt;
    &lt;D&gt;
    &lt;D_ID&gt;D_0007&lt;/D_ID&gt;
    &lt;D_UQ_ID&gt;UQ_D_0007&lt;/D_UQ_ID&gt;
    &lt;D_TIME&gt;2007 FEB 77:77:77.77&lt;/D_TIME&gt;
    &lt;F&gt;
    &lt;F_TYPE&gt;F_TYPE_TEST&lt;/F_TYPE&gt;
    &lt;F_SUBTYPE&gt;SUB_TEST&lt;/F_SUBTYPE&gt;
    &lt;G&gt;
    &lt;H&gt;
    &lt;H_TYPE&gt;Ipod&lt;/H_TYPE&gt;
    &lt;H_MODE&gt;SCANNING&lt;/H_MODE&gt;
    &lt;/H&gt;
    &lt;/G&gt;
    &lt;/F&gt;
    &lt;E&gt;&lt;/E&gt;
    &lt;/D&gt;
    &lt;D&gt;
    &lt;D_ID&gt;D_0008&lt;/D_ID&gt;
    &lt;D_UQ_ID&gt;UQ_D_0008&lt;/D_UQ_ID&gt;
    &lt;D_TIME&gt;2007 FEB 88:88:88.88&lt;/D_TIME&gt;
    &lt;F&gt;
    &lt;F_TYPE&gt;F_TYPE_TEST&lt;/F_TYPE&gt;
    &lt;F_SUBTYPE&gt;SUB_TEST&lt;/F_SUBTYPE&gt;
    &lt;G&gt;
    &lt;H&gt;
    &lt;H_TYPE&gt;Ipod&lt;/H_TYPE&gt;
    &lt;H_MODE&gt;SCANNING&lt;/H_MODE&gt;
    &lt;H_SHAPE&gt;
    &lt;POLYGON&gt;
    &lt;SEQ_NUM&gt;1&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;10.1&lt;/LAT&gt;
    &lt;LON&gt;11.1&lt;/LON&gt;
    &lt;SEQ_NUM&gt;2&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;20.2&lt;/LAT&gt;
    &lt;LON&gt;22.2&lt;/LON&gt;
    &lt;SEQ_NUM&gt;3&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;30.3&lt;/LAT&gt;
    &lt;LON&gt;33.3&lt;/LON&gt;
    &lt;SEQ_NUM&gt;4&lt;/SEQ_NUM&gt;
    &lt;LAT&gt;40.4&lt;/LAT&gt;
    &lt;LON&gt;44.4&lt;/LON&gt;
    &lt;/POLYGON&gt;
    &lt;CIRCLE&gt;
    &lt;LAT&gt;12.3&lt;/LAT&gt;
    &lt;LON&gt;45.6&lt;/LON&gt;
    &lt;RAD&gt;78.9&lt;/RAD&gt;
    &lt;/CIRCLE&gt;
    &lt;ELLIPSE&gt;
    &lt;ORIENT&gt;88.80&lt;/ORIENT&gt;
    &lt;MAJ_AX&gt;111.10&lt;/MAJ_AX&gt;
    &lt;MIN_AX&gt;222.20&lt;/MIN_AX&gt;
    &lt;/ELLIPSE&gt;
    &lt;/H_SHAPE&gt;
    &lt;/H&gt;
    &lt;/G&gt;
    &lt;/F&gt;
    &lt;E&gt;&lt;/E&gt;
    &lt;/D&gt;
    &lt;C&gt;TPS Report 4&lt;/C&gt;
    &lt;/A_B_C&gt;
    SELECT statement:
    SELECT a_level.a_class
    , d_level.D_UQ_ID
    , d_level.D_TIME
    , h_level.SEQ_NUM
    , h_level.LAT
    , h_level.LON
    FROM ABC_XML,
    XMLTABLE('/A_B_C'
    PASSING ABC_XML.ABC_SPEC
    COLUMNS
    A_CLASS VARCHAR2(4000 BYTE) PATH '/A_B_C/A/B'
    , D XMLTYPE PATH 'D'
    ) a_level,
    XMLTABLE ('/D'
    PASSING a_level.D
    COLUMNS
    D_UQ_ID varchar2(4000) PATH 'D_UQ_ID'
    , D_TIME varchar2(4000) PATH 'D_TIME'
    , POLYGON XMLTYPE PATH 'F/G/H/H_SHAPE/POLYGON'
    ) d_level
    XMLTABLE('/POLYGON'
    passing d_level.POLYGON
    COLUMNS
    SEQ_NUM NUMBER PATH 'SEQ_NUM'
    , LAT NUMBER PATH 'LAT)'
    , LON NUMBER PATH 'LON'
    ) h_level;
    As you see I need to return data from three levels of data (a, d and h). I can remark out the bottom level (h_level) and the statement runs returning 8 rows from the xml file above (which is correct). The h_level XMLTABLE reference returns the ORA-19279 error. The full statement should return 20 rows of data.

    Yes. I looked at that string.
    Never mind on this one. You helped solve the problem in another string
    XMLTable 'For $i in ... return ROW' clause help needed

  • Update report row wise using row buttons and success message

    Hi Jari,
    Thanks for your reply but i wan't success message in success message region of page and not as popup or alert message.
    for report it is classic report but two columns are text field.
    Thanks
    Manish
    Hi,
    On Demand process you can use HTP.P to output success message after you code.
    Create also exception handler that output error using same HTP.P.
    When you call Ajax in JavaScript
    var ajaxResult=ajaxRequest.get();
    Result you output are in variable ajaxResult.
    You can use e.g. alert
    alert(ajaxResult);
    Refresh report depend lot of what report you have.
    There is lot of posts relating interactive report and classic in this forum.
    It might be good to create sample what you already have done to apex.oracle.com.
    Also creating new post might be good idea as this is answered.
    Regards,
    Jari

    866038 wrote:
    Errors come from trying things that don't work.
    For example, instead of =, using IN VALUEOF(NQ_SESSION.GROUP) or @{session.GROUP} or lots of other things.
    The question is this:
    how can I filter a column in Answers using the GROUP session variable which had been initialized in a row-wise initialization block?
    I can find no way to do it. Mostly it returns no rows.Hi,
    we had a similar requirement, where we have an external name that has project number values. We used row wise initialization to capture all the projects that a user belongs to. Then, we applied the filters at the RPD level, instead of doing it at the report level. From you requirement I see that you are trying to filter the groups based on user login. When a user logs in, he will see the information about the groups that he only belongs to. Correct me if I am wrong here.
    Assuming I am right about your requirement, providing the filter that you need apply in RPD.
    On all the fact tables are joined to the Package Virtual Group dimension, apply the below filter.
    case when 1=1 then (Dim)"."Package Virtual Group" END = VALUEOF(NQ_SESSION."GROUP");
    The reason for use of case statement here is, it converts the logical sql to IN Clause, helping us acheive the exact query that we would want.
    Please Award points if this helps.
    Thanks,
    -Amith.

  • SQL Query help ( On connect By level clause)

    Hi all,
    I have this query developed with data in with clause.
    With dat As
      select '@AAA @SSS @DDD' col1 from dual union all
      select '@ZZZ @XXX @TTT @RRR @ZZA' col1 from dual
    Select regexp_substr( col1 , '[^@][A-Z]+',1,level) Show from dat
    connect by level  <= regexp_count(col1, '@');Current output :-
    SHOW
    AAA
    SSS
    DDD
    RRR
    ZZA
    TTT
    RRR
    ZZA
    XXX
    DDD
    RRR
    SHOW
    ZZA
    TTT
    RRR
    ZZA
    . . .1st row comes fine, But next row data is getting duplicated. And total record count = 30. I tried with some but didn't work.
    Expected output :-
    SHOW
    AAA
    SSS
    DDD
    ZZZ
    XXX
    TTT
    RRR
    ZZAI need some change on my query and I am not able to find that. So anybody can add on that or can also provide some different solution too.
    Thanks!
    Ashutosh

    Hi,
    When you use something like "CONNECT BY LEVEL <= x", then at least one of the following must be true:
    (a) the table has no more than 1 row
    (b) there are other conditions in the CONNECT BY clause, or
    (c) you know what you are doing.
    To help see why, run this query
    SELECT     SYS_CONNECT_BY_PATH (dname, '/')     AS path
    ,     LEVEL
    FROM     scott.dept
    CONNECT BY     LEVEL <= 3
    ;and study the results:
    PATH                                     LEVEL
    /ACCOUNTING                                  1
    /ACCOUNTING/ACCOUNTING                       2
    /ACCOUNTING/ACCOUNTING/ACCOUNTING            3
    /ACCOUNTING/ACCOUNTING/RESEARCH              3
    /ACCOUNTING/ACCOUNTING/SALES                 3
    /ACCOUNTING/ACCOUNTING/OPERATIONS            3
    /ACCOUNTING/RESEARCH                         2
    /ACCOUNTING/RESEARCH/ACCOUNTING              3
    /ACCOUNTING/RESEARCH/RESEARCH                3
    /ACCOUNTING/RESEARCH/SALES                   3
    /ACCOUNTING/RESEARCH/OPERATIONS              3
    /ACCOUNTING/SALES                            2
    /ACCOUNTING/SALES/ACCOUNTING                 3
    84 rows selected.

  • Query help with Model clause

    Hi Gurus,
    Can someone please help me out.
    I've a below tables.
    1) tbl_link --> this table contains information at profile level
    2) tbl_summary --> this table contains summary at parent profile level derived from tbl_link table
    One parent profile contains multiple child profiles and each child profile links to a code (which is B, W, G or P) and the code is linked to a category (i.e. ONL and OFL). In this case code B is linked to category 'ONL' and codes W,G,P linked to OFL category.
    ONL category needs 100 points. If it don't have enough points then i need to borrow from OFL category which i'm doing and populating into tbl_summary table at parent profile level.
    Now i need to insert data into tbl_link table at profile level with howmany points used, expired based on tbl_summary table. Rule is at the end of month if we add points for each profile in tbl_link table it should come as 0.
    with
    tbl_SUMMARY as
    select 1 as ppid,'ONL' as catgcode, 53 as earned_points,47 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
    union
    select 1 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,176 CERT_POINTS,76 DISCARD_POINTS,100 used from dual
    union
    select 2 as ppid,'ONL' as catgcode, 39 as earned_points,61 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
    union
    select 2 as ppid,'OFL' as catgcode, 90 as earned_points,0 BORROWED_POINTS,29 CERT_POINTS,29 DISCARD_POINTS,100 used from dual
    union
    select 3 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
    union
    select 3 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,223 CERT_POINTS,23 DISCARD_POINTS,200 used from dual
    union
    select 4 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
    union
    select 4 as ppid,'OFL' as catgcode, 169 as earned_points,0 BORROWED_POINTS,169 CERT_POINTS,69 DISCARD_POINTS,100 used from dual
    tbl_link as
    select 1 as ppid,1 as pid, 'B' as code,'ONL' as catgcode, 53 as earned_points from dual
    union
    select 1 as ppid,12 as pid, 'W' as code,'OFL' as catgcode, 26 as earned_points from dual
    union
    select 1 as ppid,13 as pid, 'G' as code,'OFL' as catgcode, 87 as earned_points from dual
    union
    select 1 as ppid,14 as pid, 'P' as code,'OFL' as catgcode, 110 as earned_points from dual
    union
    select 2 as ppid,2 as pid, 'B' as code,'ONL' as catgcode, 39 as earned_points from dual
    union
    select 2 as ppid,22 as pid, 'W' ,'OFL' as catgcode, 30 as earned_points from dual
    union
    select 2 as ppid,23 as pid, 'G' ,'OFL' as catgcode, 29 as earned_points from dual
    union
    select 2 as ppid,24 as pid, 'P' ,'OFL' as catgcode, 31 as earned_points from dual
    union
    select 3 as ppid,3 as pid, 'B' as code,'ONL' as tier_catgcode, 109 as earned_points from dual
    union
    select 3 as ppid,32 as pid, 'W' ,'OFL' , 26 as earned_points from dual
    union
    select 3 as ppid,33 as pid, 'G' ,'OFL', 87 as earned_points from dual
    union
    select 3 as ppid,34 as pid, 'P' ,'OFL' , 110 as earned_points from dual
    union
    select 4 as ppid,4 as pid, 'B' as code,'ONL' as catgcode, 109 as earned_points from dual
    union
    select 4 as ppid,42 as pid, 'W' as code,'OFL' , 26 as earned_points from dual
    union
    select 4 as ppid,43 as pid, 'G' as code,'OFL' , 87 as earned_points from dual
    union
    select 4 as ppid,44 as pid, 'P' as code,'OFL' , 56 as earned_points from dual
    final (PARENT_PROFILE_ID,PROFILE_ID,catgcode,EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED)
    as (
    select A.PPID PARENT_PROFILE_ID,B.PID PROFILE_ID,A.catgcode,B.EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED
    from tbl_SUMMARY a,tbl_link b where a.ppid=b.ppid AND A.catgcode=B.catgcode
    ORDER BY PROFILE_ID
    select * from final order by 1;
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED
    1                  1           ONL       53             47               100          0               100
    1                  14          OFL       110            0                176          76              100
    1                  13          OFL       87             0                176          76              100
    1                  12          OFL       26             0                176          76              100
    2                  2           ONL       39             61               100          0               100
    2                  24          OFL       31             0                29           29              100
    2                  23          OFL       29             0                29           29              100
    2                  22          OFL       30             0                29           29              100
    3                  32          OFL       26             0                223          23              200
    3                  33          OFL       87             0                223          23              200
    3                  34          OFL       110            0                223          23              200
    3                  3           ONL       109            0                109          9               100
    4                  42          OFL       26             0                169          69              100
    4                  43          OFL       87             0                169          69              100
    4                  44          OFL       56             0                169          69              100
    4                  4           ONL       109            0                109          9               100
    Need Output as below :
    For parent profile 1, whatever i mentioned above is not correct. Borrowed 47 points from OFL to ONL to make ONL and also from OFL category has 176 points remaining after lending to ONL and using only 100 points, remaining 76 points are discarded. Need to deduct these 76 points also from child profiles. Output will be as below.
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    1                  1           ONL       53             47               100          0               100   -53       0
    1                  12          OFL       26             0                176          76              100   -26       0
    1                  13          OFL       87             0                176          76              100   -74       -13
    1                  14          OFL       110            0                176          76              100   -47       -63
    For parent profile id 2 --> ONL category has 39 points, so borrowed 61 points from OFL category to make ONL points 100.
                                Now need to populate tbl_link table at child profile level (i.e. child profiles 22,23,24).
    Borrowed 61 points from OFL and need to deduct this points from the profile which has highest earned points, in this case deduct from profile 24 which has 31 points, from profile 22 which has 30 points. Need output like below
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    2                  2           ONL       39             61               100          0               100   -39       0
    2                  22          OFL       30             0                29           29              100   -30       0
    2                  23          OFL       29             0                29           29              100   0         -29
    2                  24          OFL       31             0                29           29              100   -31       0
    For parent profile id 3 --> ONL category has 109 points, so no need to borrow points from OFL category
                                Now need to populate tbl_link table at child profile level (i.e. child profiles 32,33,34).
    in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 223 points total. need only 200 points (i.e. mutiple of 100) for our process, 23 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 34. Output :
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    3                  3           ONL       109            0                109          9               100   -100      -9
    3                  32          OFL       26             0                223          23              200   -26       0
    3                  33          OFL       87             0                223          23              200   -87       0
    3                  34          OFL       110            0                223          23              200   -87       -23
    For parent profile id 4 --> ONL category has 109 points, so no need to borrow points from OFL category
                                Now need to populate tbl_link table at child profile level (i.e. child profiles 42,43,44).
    in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 169 points total. need only 100 points (i.e. mutiple of 100) for our process, 69 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 43. Output :
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    4                  4           ONL       109            0                109          9               100   100       9
    4                  42          OFL       26             0                169          69              100   -26       0
    4                  43          OFL       87             0                169          69              100   -18       -69
    4                  44          OFL       56             0                169          69              100   -56       0
    Can someone help with the query. I googled about looping in sql and came to know that Oracle has a feature MODEL to loop in SQL, but i don't have idea on using MODEL clause.
    Appreciate your help!
    Thanks
    Sri

    Hi Gurus,
    Can someone please help me out.
    I've a below tables.
    1) tbl_link --> this table contains information at profile level
    2) tbl_summary --> this table contains summary at parent profile level derived from tbl_link table
    One parent profile contains multiple child profiles and each child profile links to a code (which is B, W, G or P) and the code is linked to a category (i.e. ONL and OFL). In this case code B is linked to category 'ONL' and codes W,G,P linked to OFL category.
    ONL category needs 100 points. If it don't have enough points then i need to borrow from OFL category which i'm doing and populating into tbl_summary table at parent profile level.
    Now i need to insert data into tbl_link table at profile level with howmany points used, expired based on tbl_summary table. Rule is at the end of month if we add points for each profile in tbl_link table it should come as 0.
    with
    tbl_SUMMARY as
    select 1 as ppid,'ONL' as catgcode, 53 as earned_points,47 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
    union
    select 1 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,176 CERT_POINTS,76 DISCARD_POINTS,100 used from dual
    union
    select 2 as ppid,'ONL' as catgcode, 39 as earned_points,61 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
    union
    select 2 as ppid,'OFL' as catgcode, 90 as earned_points,0 BORROWED_POINTS,29 CERT_POINTS,29 DISCARD_POINTS,100 used from dual
    union
    select 3 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
    union
    select 3 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,223 CERT_POINTS,23 DISCARD_POINTS,200 used from dual
    union
    select 4 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
    union
    select 4 as ppid,'OFL' as catgcode, 169 as earned_points,0 BORROWED_POINTS,169 CERT_POINTS,69 DISCARD_POINTS,100 used from dual
    tbl_link as
    select 1 as ppid,1 as pid, 'B' as code,'ONL' as catgcode, 53 as earned_points from dual
    union
    select 1 as ppid,12 as pid, 'W' as code,'OFL' as catgcode, 26 as earned_points from dual
    union
    select 1 as ppid,13 as pid, 'G' as code,'OFL' as catgcode, 87 as earned_points from dual
    union
    select 1 as ppid,14 as pid, 'P' as code,'OFL' as catgcode, 110 as earned_points from dual
    union
    select 2 as ppid,2 as pid, 'B' as code,'ONL' as catgcode, 39 as earned_points from dual
    union
    select 2 as ppid,22 as pid, 'W' ,'OFL' as catgcode, 30 as earned_points from dual
    union
    select 2 as ppid,23 as pid, 'G' ,'OFL' as catgcode, 29 as earned_points from dual
    union
    select 2 as ppid,24 as pid, 'P' ,'OFL' as catgcode, 31 as earned_points from dual
    union
    select 3 as ppid,3 as pid, 'B' as code,'ONL' as tier_catgcode, 109 as earned_points from dual
    union
    select 3 as ppid,32 as pid, 'W' ,'OFL' , 26 as earned_points from dual
    union
    select 3 as ppid,33 as pid, 'G' ,'OFL', 87 as earned_points from dual
    union
    select 3 as ppid,34 as pid, 'P' ,'OFL' , 110 as earned_points from dual
    union
    select 4 as ppid,4 as pid, 'B' as code,'ONL' as catgcode, 109 as earned_points from dual
    union
    select 4 as ppid,42 as pid, 'W' as code,'OFL' , 26 as earned_points from dual
    union
    select 4 as ppid,43 as pid, 'G' as code,'OFL' , 87 as earned_points from dual
    union
    select 4 as ppid,44 as pid, 'P' as code,'OFL' , 56 as earned_points from dual
    final (PARENT_PROFILE_ID,PROFILE_ID,catgcode,EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED)
    as (
    select A.PPID PARENT_PROFILE_ID,B.PID PROFILE_ID,A.catgcode,B.EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED
    from tbl_SUMMARY a,tbl_link b where a.ppid=b.ppid AND A.catgcode=B.catgcode
    ORDER BY PROFILE_ID
    select * from final order by 1;
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED
    1                  1           ONL       53             47               100          0               100
    1                  14          OFL       110            0                176          76              100
    1                  13          OFL       87             0                176          76              100
    1                  12          OFL       26             0                176          76              100
    2                  2           ONL       39             61               100          0               100
    2                  24          OFL       31             0                29           29              100
    2                  23          OFL       29             0                29           29              100
    2                  22          OFL       30             0                29           29              100
    3                  32          OFL       26             0                223          23              200
    3                  33          OFL       87             0                223          23              200
    3                  34          OFL       110            0                223          23              200
    3                  3           ONL       109            0                109          9               100
    4                  42          OFL       26             0                169          69              100
    4                  43          OFL       87             0                169          69              100
    4                  44          OFL       56             0                169          69              100
    4                  4           ONL       109            0                109          9               100
    Need Output as below :
    For parent profile 1, whatever i mentioned above is not correct. Borrowed 47 points from OFL to ONL to make ONL and also from OFL category has 176 points remaining after lending to ONL and using only 100 points, remaining 76 points are discarded. Need to deduct these 76 points also from child profiles. Output will be as below.
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    1                  1           ONL       53             47               100          0               100   -53       0
    1                  12          OFL       26             0                176          76              100   -26       0
    1                  13          OFL       87             0                176          76              100   -74       -13
    1                  14          OFL       110            0                176          76              100   -47       -63
    For parent profile id 2 --> ONL category has 39 points, so borrowed 61 points from OFL category to make ONL points 100.
                                Now need to populate tbl_link table at child profile level (i.e. child profiles 22,23,24).
    Borrowed 61 points from OFL and need to deduct this points from the profile which has highest earned points, in this case deduct from profile 24 which has 31 points, from profile 22 which has 30 points. Need output like below
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    2                  2           ONL       39             61               100          0               100   -39       0
    2                  22          OFL       30             0                29           29              100   -30       0
    2                  23          OFL       29             0                29           29              100   0         -29
    2                  24          OFL       31             0                29           29              100   -31       0
    For parent profile id 3 --> ONL category has 109 points, so no need to borrow points from OFL category
                                Now need to populate tbl_link table at child profile level (i.e. child profiles 32,33,34).
    in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 223 points total. need only 200 points (i.e. mutiple of 100) for our process, 23 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 34. Output :
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    3                  3           ONL       109            0                109          9               100   -100      -9
    3                  32          OFL       26             0                223          23              200   -26       0
    3                  33          OFL       87             0                223          23              200   -87       0
    3                  34          OFL       110            0                223          23              200   -87       -23
    For parent profile id 4 --> ONL category has 109 points, so no need to borrow points from OFL category
                                Now need to populate tbl_link table at child profile level (i.e. child profiles 42,43,44).
    in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 169 points total. need only 100 points (i.e. mutiple of 100) for our process, 69 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 43. Output :
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    4                  4           ONL       109            0                109          9               100   100       9
    4                  42          OFL       26             0                169          69              100   -26       0
    4                  43          OFL       87             0                169          69              100   -18       -69
    4                  44          OFL       56             0                169          69              100   -56       0
    Can someone help with the query. I googled about looping in sql and came to know that Oracle has a feature MODEL to loop in SQL, but i don't have idea on using MODEL clause.
    Appreciate your help!
    Thanks
    Sri

  • Help with SQL MODEL Clause

    I have the privilege of performing a very tedious task.
    We have some home grown regular expressions in our company. I now need to expand these regular expressions.
    Samples:
    a = 0-3
    b = Null, 0, 1
    Expression: Meaning
    1:5: 1,2,3,4,5
    1a: 10, 11, 12, 13
    1b: 1, 10, 11
    1[2,3]ab: 120, 1200, 1201, ....
    It get's even more inetersting because there is a possibility of 1[2,3]a.ab
    I have created two base queries to aid me in my quest. I am using the SQL MODEL clause to solve this problem. I pretty confident that I should be able to convert evrything into a range and the use one of the MODEL clause listed below.
    My only confusion is how do I INCREMENT dynamically. The INCREMENT seems to be a constant in both a FOR and ITERATE statement. I need to figure a way to increment with .01, .1, etc.
    Any help will be greatly appreciated.
    CODE:
    Reference:          http://www.sqlsnippets.com/en/topic-11663.html
    Objective:          Expand a range with ITERATE
    WITH t AS
    (SELECT '2:4' pt
    FROM DUAL
    UNION ALL
    SELECT '6:9' pt
    FROM DUAL)
    SELECT pt AS code_expression
    -- , KEY
    -- , min_key
    -- , max_key
    , m_1 AS code
    FROM t
    MODEL
    PARTITION BY (pt)
    DIMENSION BY ( 0 AS KEY )
    MEASURES (
                        0 AS m_1,
                        TO_NUMBER(SUBSTR(pt, 1, INSTR(pt, ':') - 1)) AS min_key,
                        TO_NUMBER(SUBSTR(pt, INSTR(pt, ':') + 1)) AS max_key               
    RULES
    -- UPSERT
    ITERATE (100000) UNTIL ( ITERATION_NUMBER = max_key[0] - min_key[0] )
    m_1[ITERATION_NUMBER] = min_key[0] + ITERATION_NUMBER
    ORDER BY pt, m_1
    Explanation:
    Line numbers are based on the assupmtion that "WITH t AS" starts at line 5.
    If you need detailed information regarding the MODEL clause please refer to
    the Refrence site stated above or read some documentation.
    Partition-
    Line 18:     PARTITION BY (pt)
                   This will make sure that each "KEY" will start at 0 for each value of pt.
    Dimension-
    Line 19:     DIMENSION BY ( 0 AS KEY )     
                   This is necessary for the refrences max_key[0], and min_key[0] to work.
    Measures-
    Line 21:      0 AS m_1
                   A space holder for new values.
    Line 22:     TO_NUMBER(SUBSTR(pt, 1, INSTR(pt, ':') - 1)) AS min_key
                   The result is '1' for '1:5'.
    Line 23:     TO_NUMBER(SUBSTR(pt, INSTR(pt, ':') + 1)) AS max_key                                        
                   The result is '5' for '1:5'.
    Rules-
    Line 26:     UPSERT
                   This makes it possible for new rows to be created.
    Line 27:     ITERATE (100000) UNTIL ( ITERATION_NUMBER = max_key[0] - min_key[0] )
                   This reads ITERATE 100000 times or UNTIL the ITERATION_NUMBER = max_key[0] - min_key[0]
                   which would be 4 for '1:5', but since the ITERATION_NUMBER starts at 0, whatever follows
                   is repaeted 5 times.
    Line 29:     m_1[ITERATION_NUMBER] = min_key[0] + ITERATION_NUMBER
                   m_1[ITERATION_NUMBER] means m_1[Value of Dimension KEY].
                   Thus for each row of KEY the m_1 is min_key[0] + ITERATION_NUMBER.
    Reference:          http://www.sqlsnippets.com/en/topic-11663.html
    Objective:          Expand a range using FOR
    WITH t AS
    (SELECT '2:4' pt
    FROM DUAL
    UNION ALL
    SELECT '6:9' pt
    FROM DUAL)
    , base AS
    SELECT pt AS code_expression
    , KEY AS code
    , min_key
    , max_key
         , my_increment
    , m_1
    FROM t
    MODEL
    PARTITION BY (pt)
    DIMENSION BY ( CAST(0 AS NUMBER) AS KEY )
    MEASURES (
                        CAST(NULL AS CHAR) AS m_1,
                        TO_NUMBER(SUBSTR(pt, 1, INSTR(pt, ':') - 1)) AS min_key,
                        TO_NUMBER(SUBSTR(pt, INSTR(pt, ':') + 1)) AS max_key,     
                        .1 AS my_increment     
    RULES
    -- UPSERT
              m_1[FOR KEY FROM min_key[0] TO max_key[0] INCREMENT 1] = 'Y'
    ORDER BY pt, KEY, m_1
    SELECT code_expression, code
    FROM base
    WHERE m_1 = 'Y'
    Explanation:
    Line numbers are based on the assupmtion that "WITH t AS" starts at line 5.
    If you need detailed information regarding the MODEL clause please refer to
    the Refrence site stated above or read some documentation.
    Partition-
    Line 21:     PARTITION BY (pt)
                   This will make sure that each "KEY" will start at 0 for each value of pt.
    Dimension-
    Line 22:     DIMENSION BY ( 0 AS KEY )     
                   This is necessary for the refrences max_key[0], and min_key[0] to work.
    Measures-
    Line 24:      CAST(NULL AS CHAR) AS m_1
                   A space holder for results.
    Line 25:     TO_NUMBER(SUBSTR(pt, 1, INSTR(pt, ':') - 1)) AS min_key
                   The result is '1' for '1:5'.
    Line 26:     TO_NUMBER(SUBSTR(pt, INSTR(pt, ':') + 1)) AS max_key                                        
                   The result is '5' for '1:5'.
    Line 27:     .1 AS my_increment     
                   The INCREMENT I would like to use.
    Rules-
    Line 30:     UPSERT
                   This makes it possible for new rows to be created.
                   However seems like it is not necessary.
    Line 32:     m_1[FOR KEY FROM min_key[0] TO max_key[0] INCREMENT 1] = 'Y'
                   Where the KE value is between min_key[0] and max_key[0] set the value of m_1 to 'Y'
    */

    Of course, you can accomplish the same thing without MODEL using an Integer Series Generator like this.
    create table t ( min_val number, max_val number, increment_size number );
    insert into t values ( 2, 3, 0.1 );
    insert into t values ( 1.02, 1.08, 0.02 );
    commit;
    create table integer_table as
      select rownum - 1 as n from all_objects where rownum <= 100 ;
    select
      min_val ,
      increment_size ,
      min_val + (increment_size * n) as val
    from t, integer_table
    where
      n between 0 and ((max_val - min_val)/increment_size)
    order by 3
       MIN_VAL INCREMENT_SIZE        VAL
          1.02            .02       1.02
          1.02            .02       1.04
          1.02            .02       1.06
          1.02            .02       1.08
             2             .1          2
             2             .1        2.1
             2             .1        2.2
             2             .1        2.3
             2             .1        2.4
             2             .1        2.5
             2             .1        2.6
             2             .1        2.7
             2             .1        2.8
             2             .1        2.9
             2             .1          3
    15 rows selected.--
    Joe Fuda
    http://www.sqlsnippets.com/

  • Need help with INSERT and WITH clause

    I wrote sql statement which correctly work, but how i use this statment with INSERT query? NEED HELP. when i wrote insert i see error "ORA 32034: unsupported use of with clause"
    with t1 as(
    select a.budat,a.monat as period,b.vtweg,
    c.gjahr,c.buzei,c.shkzg,c.hkont, c.prctr,
    c.wrbtr,
    c.matnr,
    c.menge,
    a.monat,
    c.zuonr
    from ldw_v1.BKPF a,ldw_v1.vbrk b, ldw_v1.bseg c
    where a.AWTYP='VBRK' and a.BLART='RV' and a.BUKRS='8431' and a.awkey=b.vbeln
    and a.bukrs=c.bukrs and a.belnr=c.belnr and a.gjahr=c.gjahr and c.koart='D'
    and c.ktosl is null and c.gsber='4466' and a.gjahr>='2011' and b.vtweg='01'
    ,t2 as(
    select a.BUKRS,a.BELNR, a.GJAHR,t1.vtweg,t1.budat,t1.monat from t1, ldw_v1.bkpf a
    where t1.zuonr=a.xblnr and a.blart='WL' and bukrs='8431'
    ,tcogs as (
    select t2.budat,t2.monat,t2.vtweg, bseg.gjahr,bseg.hkont,bseg.prctr,
    sum(bseg.wrbtr) as COGS,bseg.matnr,bseg.kunnr,sum(bseg.menge) as QUANTITY
    from t2, ldw_v1.bseg
    where t2.bukrs=bseg.bukrs and t2.belnr=bseg.BELNR and t2.gjahr=bseg.gjahr and BSEG.KOART='S'
    group by t2.budat,t2.monat,t2.vtweg, bseg.gjahr,bseg.hkont,bseg.prctr,
    bseg.matnr,bseg.kunnr
    ,t3 as
    select a.budat,a.monat,b.vtweg,
    c.gjahr,c.buzei,c.shkzg,c.hkont, c.prctr,
    case when c.shkzg='S' then c.wrbtr*(-1)
    else c.wrbtr end as NTS,
    c.matnr,c.kunnr,
    c.menge*(-1) as Quantity
    from ldw_v1.BKPF a,ldw_v1.vbrk b, ldw_v1.bseg c
    where a.AWTYP='VBRK' and a.BLART='RV' and a.BUKRS='8431' and a.awkey=b.vbeln
    and a.bukrs=c.bukrs and a.belnr=c.belnr and a.gjahr=c.gjahr and c.koart='S'
    and c.ktosl is null and c.gsber='4466' and a.gjahr>='2011' and b.vtweg='01'
    ,trevenue as (
    select t3.budat,t3.monat,t3.vtweg, t3.gjahr,t3.hkont,t3.prctr,
    sum(t3.NTS) as NTS,t3.matnr,t3.kunnr,sum(t3.QUANTITY) as QUANTITY
    from t3
    group by t3.budat,t3.monat,t3.vtweg, t3.gjahr,t3.hkont,t3.prctr,t3.matnr,t3.kunnr
    select NVL(tr.budat,tc.budat) as budat,
    NVL(tr.monat,tc.monat) as monat,
    NVL(tr.vtweg,tc.vtweg) as vtweg,
    NVL(tr.gjahr, tc.gjahr) as gjahr,
    tr.hkont as NTS_hkont,
    tc.hkont as COGS_hkont,
    NVL(tr.prctr,tc.prctr) as prctr,
    NVL(tr.MATNR, tc.MATNR) as matnr,
    NVL(tr.kunnr, tc.kunnr) as kunnr,
    NVL(tr.Quantity, tc.Quantity) as Quantity,
    tr.NTS as NTS,
    tc.COGS as COGS
    from trevenue TR full outer join tcogs TC
    on TR.BUDAT=TC.BUDAT and TR.MONAT=TC.MONAT and TR.GJAHR=TC.GJAHR
    and TR.MATNR=TC.MATNR and TR.KUNNR=TC.KUNNR and TR.QUANTITY=TC.QUANTITY
    and TR.VTWEG=TC.VTWEG and TR.PRCTR=TC.PRCTR
    Edited by: user13566113 on 25.03.2011 5:26

    Without seeing what you tried it is hard to say what you did wrong, but this is how it would work
    SQL> create table t ( n number );
    Table created.
    SQL> insert into t
      2  with test_data as
      3    (select 1 x from dual union all
      4     select 2 x from dual union all
      5     select 3 x from dual union all
      6     select 4 x from dual)
      7  select x from test_data;
    4 rows created.
    SQL>

Maybe you are looking for

  • Problem with BSP Application

    Hi all, We have three BSP applications running on Production Environment, but after applying Support Patches only two are running , and the third one is not running. But all three applications are running fine in Development, and Consolidation. Here

  • GOS - Questions.

    Hi,     I have few questions regarding GOS.    1) What is the use of Business Objects? Why is it required to create a BO and to link it with GOS object?   2) I have a z-table. For every entry there will be some documents uploaded by using GOS.. Now,

  • How Can I Get My Toolbars Back?

    This is really a strange problem.  The tool bar with Edit, File, etc....that goes across the top is there, but dark and the icons are not visible.  It is black and if I click along there the icons show but all the options under each one is grayed out

  • FR Studio: Type mismatch error

    What could be the cause of an type mismatch error, when trying to open certain reports in FR Studio after it was exported from 9.3 and imported into 11.1.2.1 (patch 600)? These reports are running fine in Workspace as a PDF doc, but we are unable to

  • Does iPhone4 (Verizon) automatically DISABLE 3G when in WiFi?

    I know that when in WiFi, the iPhone4 will prefer / use the WiFi network instead of the 3G network.  However, my question is whether the iPhone automatically disables the 3G radio when in WiFi.  I have unlimited 3G data, but WiFi is faster and is als