CASE with DATE_SUB and SELECT

Hello again,
im looking for some help again.
I have a table TAB_EVENT where some dates are stored to some events.
An event can have more than one date of course.
Im trying to code a SELECT statement and it looks like this by now:
,CASE
WHEN (to_date(TEST_DATE)) in (SELECT to_date(ev.EVENT_DATE) FROM TAB_L2EVENT ev, TAB_LINK lnk, TAB_TREE tr WHERE ev.EVENT_ID = 1 AND ev.OBJ_ID = lnk.OBJ_ID AND lnk.LINK_ID = tr.NEXT_ID AND tr.NEXT = BM_NUMBER) 
THEN 'YES'
ELSE 'NO'
END as F_EVENTMy problem now is, that TEST_DATE can also be in a plus/minus 30-days interval inside the in-line query.
I searched forum and found something like
DATE_SUB(TEST_DATE, INTERVAL 30 DAY)but im getting errors, if I just replace TEST_DATE with the code above.
Maybe some1 can help?
Thank you and regards
Chris

Hi,
If ev.event_date stores dates, then its datatype should be DATE. You'll avoid lots of problems if you make that change.
If it already is a DATE, don't use TO_DATE.
At any rate, you can get the results you want by changing the IN sub-query to an EXISTS sub-query:
,   CASE
          WHEN  EXISTS ( SELECT 1
                            FROM   TAB_L2EVENT ev, TAB_LINK lnk, TAB_TREE tr
               WHERE  ev.EVENT_ID = 1 AND ev.OBJ_ID = lnk.OBJ_ID AND lnk.LINK_ID = tr.NEXT_ID AND tr.NEXT = BM_NUMBER
               AND    TO_DATE (ev.event_date, 'DD-Mon-YYYY') - TO_DATE (test_date, 'DD-Mon-YYYY')
                                  BETWEEN  -30
                           AND     30
     THEN  'YES'
     ELSE  'NO'
    END as F_EVENTWhenever you do use TO_DATE, always specify the format in the second argument. (I used 'DD-Mon-YYYY' above, but I don't know if that's actually how your strings are formatted.)
I'm not familiar with DATE_SUB. What is it?

Similar Messages

  • CASE vs DECODE - CASE with SUM and All in Page Item is non aggregable

    Hi,
    I'm using Discoverer 9.0.4.
    After switching calculations from DECODE to CASE
    I found out that case gives a non aggregable result when using a Page Item and selecting <All>.
    The calculations
    (SUM x) / (SUM y)
    or
    (x SUM) / (y SUM)
    where x and y are variables, work fine with page item <All>.
    But for example:
    CASE WHEN 1=2 THEN 1 ELSE (SUM x) / (SUM y) END
    gives non-aggregable.
    The same code works with DECODE:
    DECODE(1,2,1,(SUM x) / (SUM y))
    and is aggregable.
    Does anyone know a reason or a way to make it work with CASE?
    Thanks,
    Joao Noronha
    P.S.: I wanted <= comparisons and CASE is the best in simplicity,
    but now I know I can do it with DECODE, still looking ok using LEAST instead of ABS of the difference.

    Hi there
    I think therefore you have answered your own question and determined that using CASE in aggregations is not a good idea. I only threw out the two CASE options as ideas not as solutions, just in case (pardon the pun) one of these worked in your situation.
    Your comment I must say that if it worked it would give a wrong result (the sum of the divisions is not the same as the division of the sums) may give the wrong answer in your case but may be correct in others. It just depends how the items in the folder have been set up. I agree though that SUM(x) / SUM(y) will more often than not give the right answer.
    This discussion about DECODE vs CASE has been going on ever since Oracle introduced CASE as a means of placating a younger breed of user who needed an IF..THEN...ELSE construct and could not get their minds around the intricacies of DECODE. The DECODE is a much more reliable function than CASE because it has been around for a long time allowing Oracle plenty of opportunity to iron the bugs out of it. If I get a chance I will always use a DECODE whenever aggregations are required. However, when no aggregations are in use then I'll use CASE, simply because it's easier for users to work with.
    Unfortunately, users need to work with aggregations and so I don't see any alternative to Plus users having to learn DECODE. Whenever I teach Plus I always teach the users both CASE and DECODE but point out that DECODE has fewer issues that CASE. Oh, and talking of issues, try getting the THEN and ELSE components to return a different datatype. CASE has a fit and will not compile.
    Best wishes and glad you got your issue solved - you did right?
    Regards
    Michael

  • Problem with focus and selecting text in jtextfield

    I have problem with jtexfield. I know that solution will be very simple but I can't figure it out.
    This is simplified version of situation:
    I have a jframe, jtextfield and jbutton. User can put numbers (0-10000) separated with commas to textfield and save those numbers by pressing jbutton.
    When jbutton is pressed I have a validator which checks that jtextfield contains only numbers and commas. If validator sees that there are invalid characters, a messagebox is launched which tells to user whats wrong.
    Now comes the tricky part.
    When user presses ok from messagebox, jtextfield should select the character which validator said was invalid so that user can replace it by pressing a number or comma.
    I have the invalid character, but how can you get the focus to jtextfield and select only the character which was invalid?
    I tried requestFocus(), but it selected whole text in jtextfield and after that command I couldn't set selected text. I tried with commands setSelectionStart(int), setSelectionEnd(int) and select(int,int).
    Then I tried to use Caret and select text with that. It selected the character I wanted, but the focus wasn't really there because it didn't have keyFocus (or something like that).
    Is there a simple way of doing this?

    textField.requestFocusInWindow();
    textField.select(...);The above should work, although read the API on the select(...) method for the newer recommended approach on how to do selection.
    If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",
    see http://homepage1.nifty.com/algafield/sscce.html,
    that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    Don't forget to use the "Code Formatting Tags",
    see http://forum.java.sun.com/help.jspa?sec=formatting,
    so the posted code retains its original formatting.

  • Problem with align and Selection Tool.

    This is a weird problem which I cannot explain at all.
    I am using AI CS3 with Windows XP.
    I am having this completely random problem with the selection tool and align pallette I cannot explain.
    I have a group of objects and groups of objects I am trying to use the align pallette on.
    Sometimes when I select all of the items I want to align, either by shift-clicking each one, or by drag-selecting them I am getting a random behavior where sometimes the align button will move all of the objects COMPLETELY off of the artboard, all the way to the edge of the working area and beyond into the grey area you cannot see.
    Normally, this would be caused by a stray point somewhere way off-screen or some other cleanup oriented thing on my part. However in this case, the behavior is random and does not happen every time I hit the align button.
    Sometimes it takes items within my grouped objects (lines of text) and moves THEM completely off the work area, leaving the other items in the groups in place. Sometimes the bounding box when I drag-select the items will stretch extremely far off of the work area.
    I have even dragged the extra large bounding box, bringing the edge that was once way off screen onto the work area, in outline view, in hopes of finding the stray point or object that could be causing this. However NOTHING appears that can be causing the align to throw all of my objects off-screen.
    The random nature of this behavior and the way it sometimes affects my text objects inside of groups leads me to believe it is a program bug and nothing I am doing.
    The behavior takes place regardless if I select by dragging or by shift-clicking, and is happening in more than one file, also randomly.
    Also, choosing "align to art board" vs. "align to crop area" does nothing to change this behavior.
    It is quite irritating. I've been using illustrator since v.88 so I have enough experience to know this is not normal.
    Any help with this one would be greatly appreciated.

    When this behaviour occurs, are perhaps guides included in your selection?

  • Simple test case with NL and table order .

    Hi,
    did some tests on my 9.2.0.8 and got few questions:
    SQL> select count(*)  from p;
      COUNT(*)
          2000
    SQL> select count(*)  from c;
      COUNT(*)
          1000
    SQL> select count(*) , id from p group by id having count(*) > 1;
    no rows selected
    SQL> select count(*) , id from c group by id having count(*) > 1;
      COUNT(*)         ID
           100         10
    SQL> desc p
               Name
        1      ID number
        2      FILLER varchar2(100)
    SQL> desc c
               Name
        1      ID number
        2      FILLER varchar2(100)
    Got 10046 traces:
    case A
    select /*+ use_nl(p) leading(c) */ *
    from
    p , c where p.id = c.id and c.id in (10)
    Rows     Row Source Operation
        100  TABLE ACCESS BY INDEX ROWID P
        201   NESTED LOOPS
        100    TABLE ACCESS BY INDEX ROWID C
        100     INDEX RANGE SCAN C_ID (object id 411255)
        100    INDEX RANGE SCAN P_ID (object id 411256)
    Case B optimal
    select /*+ use_nl(c) leading(p) */ *
    from
    p , c where p.id = c.id and c.id in (10)
    Rows     Row Source Operation
        100  TABLE ACCESS BY INDEX ROWID C
        102   NESTED LOOPS
          1    TABLE ACCESS BY INDEX ROWID P
          1     INDEX RANGE SCAN P_ID (object id 411256)
        100    INDEX RANGE SCAN C_ID (object id 411255)So its simple nested loop with postponed inner table access .
    Why in row source operation we have got 102 rows (NL level) ? (It means NL was executed 102 times ?)
    And why 201 in other case ?
    Regards
    GregG

    I am not sure about the calculation/reason for those A-ROWS figures but the NL operation executes only once (but accesses inner rowsource 100 times in case one and once in second case) in both cases (which is as expected).
    A closer test case (to OP) is
    SQL> select * from v$version ;
    BANNER                                                                                                                                                                    
    Oracle Database 10g Release 10.2.0.5.0 - Production                                                                                                                       
    PL/SQL Release 10.2.0.5.0 - Production                                                                                                                                    
    CORE     10.2.0.5.0     Production                                                                                                                                                
    TNS for Linux: Version 10.2.0.5.0 - Production                                                                                                                            
    NLSRTL Version 10.2.0.5.0 - Production                                                                                                                                    
    SQL> create table p nologging as select level as id, cast(dbms_random.string('a', 100) as varchar2(100)) as filler from dual connect by level <= 2000 ;
    Table created.
    SQL> exec dbms_stats.gather_table_stats(user, 'P') ;
    PL/SQL procedure successfully completed.
    SQL> create index p_id on p(id) nologging ;
    Index created.
    SQL> select count(*)  from p;
      COUNT(*)                                                                                                                                                                
          2000                                                                                                                                                                
    SQL> select count(*) , id from p group by id having count(*) > 1;
    no rows selected
    SQL> create table c nologging as select level as id, cast(dbms_random.string('a', 100) as varchar2(100)) as filler from dual connect by level <= 900 union all select 10, cast(dbms_random.string('a', 100) as varchar2(100)) as filler from dual connect by level <= 99 ;
    Table created.
    SQL> select count(*) , id from c group by id having count(*) > 1;
      COUNT(*)         ID                                                                                                                                                     
           100         10                                                                                                                                                     
    SQL> exec dbms_stats.gather_table_stats(user, 'C') ;
    PL/SQL procedure successfully completed.
    SQL> create index c_id on c(id) nologging ;
    Index created.
    SQL> select /*+ use_nl(p) leading(c) gather_plan_statistics */ * from p , c where p.id = c.id and c.id in (10) ;
            ID FILLER                                                                                                       ID                                                
    FILLER                                                                                                                                                                    
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    zrGZSmUFXNyNMOViUYSvPDdfznSlMvaFnQakopPtcBvXQkWmMlWCnrPyeZLfhuLLeYyAEkcwZNSfoASLYpoAnpESqlQWkaEGatXV                                                                      
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    hKtrWPCfAmWWLGMXfwHCusSwVpehEnZdxYPLouIuBlMMiSKlIJWwklZCAXZaCbIxKlhzBVRhhTPdLcheyAdoYyfxwomqWRrMXuMk                                                                      
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    ncSqclZvOGgyXDPaaouGaUqXmJtFNbNyFzUalDknEMvTsBRwGmTxOCIalLvqMnuTFBZJGzNfBqaSVHUtvNDceVZqKQQyqeGKOUdz                                                                      
    100 rows selected.
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST')) ;
    PLAN_TABLE_OUTPUT                                                                                                                                                         
    SQL_ID  1f55m4rabtu3h, child number 0                                                                                                                                     
    select /*+ use_nl(p) leading(c) gather_plan_statistics */ * from p , c where p.id = c.id and                                                                              
    c.id in (10)                                                                                                                                                              
    Plan hash value: 2553281496                                                                                                                                               
    | Id  | Operation                     | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |                                                                 
    |   0 | SELECT STATEMENT              |      |      0 |        |      0 |00:00:00.01 |       0 |      0 |                                                                 
    |   1 |  TABLE ACCESS BY INDEX ROWID  | P    |      1 |      1 |    100 |00:00:00.01 |     112 |      2 |                                                                 
    |   2 |   NESTED LOOPS                |      |      1 |      1 |    201 |00:00:00.02 |     110 |      2 |                                                                 
    |   3 |    TABLE ACCESS BY INDEX ROWID| C    |      1 |      1 |    100 |00:00:00.01 |       7 |      1 |                                                                 
    |*  4 |     INDEX RANGE SCAN          | C_ID |      1 |      1 |    100 |00:00:00.01 |       3 |      1 |                                                                 
    |*  5 |    INDEX RANGE SCAN           | P_ID |    100 |      1 |    100 |00:00:00.01 |     103 |      1 |                                                                 
    Predicate Information (identified by operation id):                                                                                                                       
       4 - access("C"."ID"=10)                                                                                                                                                
       5 - access("P"."ID"=10)                                                                                                                                                
    24 rows selected.
    SQL> select /*+ use_nl(c) leading(p) gather_plan_statistics */ * from p , c where p.id = c.id and c.id in (10) ;
            ID FILLER                                                                                                       ID                                                
    FILLER                                                                                                                                                                    
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    zrGZSmUFXNyNMOViUYSvPDdfznSlMvaFnQakopPtcBvXQkWmMlWCnrPyeZLfhuLLeYyAEkcwZNSfoASLYpoAnpESqlQWkaEGatXV                                                                      
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    hKtrWPCfAmWWLGMXfwHCusSwVpehEnZdxYPLouIuBlMMiSKlIJWwklZCAXZaCbIxKlhzBVRhhTPdLcheyAdoYyfxwomqWRrMXuMk                                                                      
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    ncSqclZvOGgyXDPaaouGaUqXmJtFNbNyFzUalDknEMvTsBRwGmTxOCIalLvqMnuTFBZJGzNfBqaSVHUtvNDceVZqKQQyqeGKOUdz                                                                      
    100 rows selected.
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST')) ;
    PLAN_TABLE_OUTPUT                                                                                                                                                         
    SQL_ID  7hvf1zvsvfhdp, child number 0                                                                                                                                     
    select /*+ use_nl(c) leading(p) gather_plan_statistics */ * from p , c where p.id =                                                                                       
    c.id and c.id in (10)                                                                                                                                                     
    Plan hash value: 2133717140                                                                                                                                               
    | Id  | Operation                     | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |                                                                          
    |   0 | SELECT STATEMENT              |      |      0 |        |      0 |00:00:00.01 |       0 |                                                                          
    |   1 |  TABLE ACCESS BY INDEX ROWID  | C    |      1 |      1 |    100 |00:00:00.01 |      11 |                                                                          
    |   2 |   NESTED LOOPS                |      |      1 |      1 |    102 |00:00:00.01 |       7 |                                                                          
    |   3 |    TABLE ACCESS BY INDEX ROWID| P    |      1 |      1 |      1 |00:00:00.01 |       4 |                                                                          
    |*  4 |     INDEX RANGE SCAN          | P_ID |      1 |      1 |      1 |00:00:00.01 |       3 |                                                                          
    |*  5 |    INDEX RANGE SCAN           | C_ID |      1 |      1 |    100 |00:00:00.01 |       3 |                                                                          
    Predicate Information (identified by operation id):                                                                                                                       
       4 - access("P"."ID"=10)                                                                                                                                                
       5 - access("C"."ID"=10)                                                                                                                                                
    24 rows selected.
    SQL> drop table p purge ;
    Table dropped.
    SQL> drop table c purge ;
    Table dropped.
    SQL> spool offEdited by: user503699 on Jan 18, 2012 11:49 PM

  • Anonymous Block with Variable and SELECT

    Hi Guys,
    I am struggling to connect the material I am learning. I read about anonymous blocks and variables so I want to write a
    nice and neat select with all the fancy stuff (variables, exceptions) to get it right and to it as I read in the book.
    DECLARE
    MYSTRING VARCHAR(10);
    MYSTIRNG := 'X';     
    BEGIN
    SELECT * FROM DUAL WHERE DUMMY = MYSTRING
    END;
    but....this causes one error after the other. Am I getting the concept wrong here or is it a syntax error?

    cant I just get the result without using variable to store the result in the first place???Perhaps you're better off using a REF CURSOR (a.k.a. cursor variable).
    That way you'll pass a resultset to the caller and you don't need any variables to select into.
    You can read about them here:
    http://www.oracle-base.com/articles/misc/UsingRefCursorsToReturnRecordsets.php
    Re: PL/SQL 101 : Understanding Ref Cursors
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10766/tdddg_subprograms.htm#TDDDG99939

  • HTC 8X Case with Stand and Inductive Charging compatible?

    I know this may be a stretch, but I've come very accustom to using my inductive charging on my 8x. I find it very nice to just be able to set it down and be on my way. I have another case that has a stand built in that it very useful.
    Has anyone come across a case that can do both? Built in stand and is still inductive compatible??
    Any suggestions would be appreciated.
    Thanks.

    The one I know of is Otterbox 8x case. But that is too bulky. However the stand is only horizontal. Here take a look at their video http://www.youtube.com/watch?v=hpRE06PezbY  (2:20)
    I have the blue rubberized 8x case. Usually the 8x can wireless charge through any case. So since you already have a case, all you need is a wireless charging stand. You are in luck because Nokia makes one for their Lumia 920 and it also works for any Qi inductive wireless charging phone .Its called the Nokia Wireless Charging stand. Unfortunately since Verizon  only sells the plate, not also the stand, the cheapest one I have found is at an ATT store. In ATT store they are running for $69 and in most places for $80.
    http://www.att.com/shop/wireless/accessories/chargers/sku6290329.html#fbid=TZuI3jsemTV
    Great part about this charger, is that it also comes with built in NFC. So you can run some apps in NFC from your phone. For example like leaving the alarm clock on while charging overnight or listening to music while the phone is charging. Take look at the review of this video so you have an idea.
    http://www.youtube.com/watch?v=ns8Hm8H4MAQ

  • Help with IF and SELECT

    Greetings,
    I have a program where some users can request awards for themselves or other users. Only approved people can request for others.
    I have a table called OnBehalf that has the UserID of approved users.
    I have a vaiable called same, if it is = 0 it means the person is requesting on behalf of someone else.
    The problem is, everytime I make a request on behalf of someone else, even if the name is in the table as an approved requester, I get a message saying that I am not approved (msg=4)
    What am I doing wrong?
    'If requesting for someone else, check if authorized to request on behalf
    if same = 0 Then
         dim aa
         dim bb
         aa="SELECT * FROM OnBehalf WHERE UserID = '"& Requester&"' "
         set bb= conn.Execute(aa)
         'response.write (aa)
         if Not bb.EOF Then
              response.redirect "noAuth.asp?msg=4"
              response.end
         end if
    end if
    Thanx in advance

    I think your NOT in the IF shouldn't be there
    bb.EOF will be true if the user is not a valid use
    if bb.EOF = false Then
    response.write "Welcome valid user : " & bb.Fields(0).Value
    else
    response.redirect "noAuth.asp?msg=4"
    response.end
    end if
    Despite my c++ upbringing I always prefer = false and =true as its easier to read than IF NOT

  • Reading videos with iphoto and select iphoto in the screen saver

    Since I've upgraded my mac with mavericks, I can not read videos in iphoto'09.
    I have an other proble: I can't select iphoto in the screen saver module.
    Can you help me? thanx

    About videos in iphoto'09: before upgrading my mac with mavericks, in order to read videos I just click on it. Now, itunes don't find the good software to read the video in iphoto.
    About selecting a new screen saver: my mac can not find the iphoto library in the right place when I'm in the screen saver module

  • Program with list and select button

    Hi,
    is there a program module that displays a list and when user selects an item and clicks on some button the program returnes selected item.
    I just want to use that kind of program as a template.
    Thank you.

    Hi,
    Try this program BCALV_GRID_02
    Cheers.
    ...Reward if useful

  • Dynamic LOV with dates and selected default value

    Hello,
    I have a dynamic lov with dates. Query looks like this:
    select distinct concat(to_char(b.send_day_time,'YYYY.MM.DD HH24'),':00') display_value, to_char(b.send_day_time,'YYYY.MM.DD HH24') return_value
    from ...
    No I want to select a specific date as the default value. I put the following code for the default value:
    declare
    begin
    return to_char ('2008.02.19 10:00');
    end;
    But it doesn't work.The date (string) exists in the lov but it is not selected.
    Can someone tell me where the problem is?
    Thx in advance.
    Greetings,
    hamburger

    Hi hamburger,
    As return value you specified to_char(b.send_day_time,'YYYY.MM.DD HH24'),
    so your default value should be like to_char('2008.02.19 10'). Also pay attention to select the "Default Value Type".
    Hope this helps.
    chrissy

  • Sales return with warranty and without!

    Hi,
    I have a scenario like sales return,
    2 cases, with warranty and without warranty
    I need your guidance on controls,
    1st case with warranty,
    Stock has been taken in to the plant with respect to sale return order.
    I generate service order SM01 (Non revenue generated)
    Maintain operations and material
    goods issue and operation confirmation
    technical completion.
    Now I run DP90 for resource related billing. And need to control that service order cost does not go to billing document. But I don't want to bill the customer.
    Please correct me, I only settle my service order and leave it. How should I go about it. Please help me.
    2nd case, when there is no warranty,
    I create a service order SM02 (revenue posting allowed)
    Maintain operations and material
    Then run DP80 to generate quotation and confirm quotation.
    goods issue and operation confirmation
    technical completion.
    Run DP90 for billing the customer.
    Could you please suggest me if I need to make any changes to this. If so, which part of it (SPRO) i need to configure.
    And as per my understanding if service contract exist then it will help to determine fixed price in with out warranty case.

    Hi,
    Yes I could able to run DP90 though I don't declare the order as revenue based. Infact the if refurbishement order (SM03) has to trigger automatically from sales order RA. Infact if it is revenue based we canot even generate it from sale order.
    You can even refer to this following link which states that cycle.
    [http://help.sap.com/saphelp_46c/helpdata/en/e6/4a8df09e0311d189b70000e829fbbd/frameset.htm]
    I have only doubt during this process billing is based on DIP profile. But how does pricing procedure is coming in to picture. And how and where to link Pricing procedure. Please guide me. And from one of my collegue came to know that accounting Indicator can be used to get discount condition in pricing procedure so, that when we run for Warranty cycle we can bring that condition to get 100% discount through KBM1 condition type.
    Regards,
    N,Nagaraju

  • Hierarchy with Intervals and Temporal Join

    Hi,
      I am loading a hierarchy structure (Time dependant and with Temporal Join and Intervals)
    in the flat file structure for hier loading we have leaf to and leaf from fields which means Page of the hierarchy to and page of the hierarchy from.
    can anyone let me know what is the use of these fields, and the values we have to pass for these fields with an example.
    i haven't come across Hier loading with intervals and termporal join.
    can anyone please help me in this?
    Regards,
    p423168.

    Hi,
    BI Process (Loading Hierarchies from Flat file to BI)
    Go to RSA1
    Create info object for customer as zcust_b5 and activate
    Create info object as zcust_b5 and activate it
    Select the info object and double click on it
    Select the hierarchies tab and select the option with hierarchies
    And select Hierarchies not time dependent
    Click external characteristics in hierarchies
    Select your Infoobjects in the list and pass it and activate it
    After activating the objects we will see tables of hierarchies at maintain Hierarchies
    Create an application component
    Create the transfer rules for the info object and activate (for hierarchies, texts, attributes)
    This screen will show the communication structure.
    After creating the data source at info source level the field attributes are shown in above
    Create an excel sheet with required values and save it in CSV file.
    Uploading the Hierarchy Data into BW
    a) Create Info Package for Hierarchy Upload. Select the Hierarchy to be uploaded
    and also the Full Update button as we are uploading the entire Hierarchy.
    b) There are three update methods for uploading the hierarchy.
    Full Update: For Uploading the entire hierarchy structure
    Insert Sub tree: For appending the hierarchy with new nodes.
    Update Sub tree: For modifying the nodes of the hierarchy.
    Create info package and schedule the data loads
    Select the Hierarchy and name it before scheduling
    Schedule and Start the data loads
    After creating the info package of the info object the above screen shows the initial hierarchy maintenance
    Hierarchy is done successfully by extracting data from flat file.
    time dependent :
    a) For making the hierarchy time dependent select the u2018Time-Dependent Hierarchy structureu2019 radio button and activate the info object ZSREP
    b) In the transfer structure there will be 2 more additional fields date from and date to for the time dependent nodes.
    c) Consider that Sales Representative u2018SREP2u2019 was in England up to 31/12/1995 and moved to USA
    d) Flat file structure for the above hierarchy is shown below . It contains two extra columns Date-to and Date-from.
    e) In the info-package Update tab , select Fixed Time interval radio button and give start date as 01/01/1000 and End date as 31/12/9999 so that all nodes are uploaded.
    f) Upload the hierarchy data from flat-file to BW.
    g) Display the loaded hierarchy.
    Regards
    Sudheer
    Edited by: SUDHEER on Dec 30, 2008 12:52 PM

  • Case with select into and sub query

    hi im trying to use case and select with sebqueries, but my beginer like understanding of syntax fails me. can someone point out what im doing wrong in the case select below. im using select into, as i ultimatly need to load a ref cursor for use with crystal reports.
    thanks
    james
    ps if anyone is london based, and would like to spend a day or two teaching me how to be a bit better at PL/SQL (can aford to pay a little bit) please get in touch!!
    SELECT
    Case (select kind_code from event where                    
    event.event_id = event.container_event_id)     
    when 1094006
    then          promo_name     
    end
    into      result
    FROM promo,     promo_plan ,     event_promotion
    WHERE      promo.promo_id = promo_plan.promo_id
    AND     promo_plan.promo_plan_id = event_promotion.promo_plan_id
    AND     event_promotion.detail_id = '33532282'
    when blah then 'blah';

    Hello
    AH i see what you are driveing at, yes i am just using case slect to determin which >routine to run, as the name is stored in a diferent location depending on the event kind >code. are are you saying i need multiple selects within the case statment? one for each >type of kind code?Well it depends really. If the select
    select kind_code from event where
    event.event_id = event.container_event_idIs going to return more than one row for any given run, you're going to need to take a bit of a different approach. Is it the case that this query will return more than one row which would mean that you want value X and value Y for each row?
    Using the test data and everything from before:
    SQL> CREATE OR REPLACE PROCEDURE p_GetStuff(ac_Result   OUT sys_refcursor)
      2  IS
      3
      4  BEGIN
      5     /*
      6             This uses a cartesian product i.e. repeat every row in
      7             dt_test_data against every row in dt_test_event
      8     */
      9     OPEN Ac_Result FOR
    10     SELECT
    11             CASE dt_test_event.kind_code
    12             WHEN 1 THEN
    13                     dt_test_data.object_name
    14             WHEN 2 THEN
    15                     dt_test_data.object_type
    16             END
    17     FROM
    18             dt_test_data,
    19             dt_test_event;
    20
    21  END;
    22  /
    Procedure created.
    SQL> var x refcursor
    SQL> exec p_getstuff(:x)
    PL/SQL procedure successfully completed.
    SQL> print x
    CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
    ABC
    ABC4
    AD1
    AD2
    ADHOC_CONTACT_LOG
    AK_CD_CLAIM_VALIDATION_SOURCE
    AK_CD_CLAIM_VALIDATION_TYPE
    AK_CLAIM_ACTION_ROWSOURCE
    APPROVAL_LIST_MEM_IE
    APPROVE_GRP_HIST_IE
    10 rows selected.
    SQL> insert into dt_test_event values(2);
    1 row created.
    SQL> exec p_getstuff(:x)
    PL/SQL procedure successfully completed.
    SQL> print x
    CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
    ABC
    ABC4
    AD1
    AD2
    ADHOC_CONTACT_LOG
    AK_CD_CLAIM_VALIDATION_SOURCE
    AK_CD_CLAIM_VALIDATION_TYPE
    AK_CLAIM_ACTION_ROWSOURCE
    APPROVAL_LIST_MEM_IE
    APPROVE_GRP_HIST_IE
    TABLE
    CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
    TABLE
    TABLE
    TABLE
    TABLE
    INDEX
    INDEX
    INDEX
    INDEX
    INDEX
    20 rows selected.Or an alternative to that would be, if you have a fixed number of event ids and they relate to a fixed number of attributes you could use something like:
    CREATE OR REPLACE PROCEDURE p_GetStuff3(ac_Result     OUT sys_refcursor)
    IS
    BEGIN
              The SUBSTR
              is just there to make sure the data fit on screen, my SQL*Plus
              is a bit weird!
         OPEN Ac_Result FOR
         SELECT
              SUBSTR(MAX(DECODE(dt_test_event.kind_code,1,dt_test_data.object_name,NULL)),1,30) attribute_1,
              SUBSTR(MAX(DECODE(dt_test_event.kind_code,2,dt_test_data.object_type,NULL)),1,30) attribute_2
         FROM
              dt_test_data,
              dt_test_event
         GROUP BY
              object_name;
    END;
    SQL> delete from dt_test_event where kind_code=2;
    1 row deleted.
    SQL> exec p_getstuff3(:x)
    PL/SQL procedure successfully completed.
    SQL> print x
    ATTRIBUTE_1                    ATTRIBUTE_2
    ABC
    ABC4
    AD1
    AD2
    ADHOC_CONTACT_LOG
    AK_CD_CLAIM_VALIDATION_SOURCE
    AK_CD_CLAIM_VALIDATION_TYPE
    AK_CLAIM_ACTION_ROWSOURCE
    APPROVAL_LIST_MEM_IE
    APPROVE_GRP_HIST_IE
    10 rows selected.
    SQL> insert into dt_test_event values(2);
    1 row created.
    SQL> exec p_getstuff3(:x)
    PL/SQL procedure successfully completed.
    SQL> print x
    ATTRIBUTE_1                    ATTRIBUTE_2
    ABC                            TABLE
    ABC4                           TABLE
    AD1                            TABLE
    AD2                            TABLE
    ADHOC_CONTACT_LOG              TABLE
    AK_CD_CLAIM_VALIDATION_SOURCE  INDEX
    AK_CD_CLAIM_VALIDATION_TYPE    INDEX
    AK_CLAIM_ACTION_ROWSOURCE      INDEX
    APPROVAL_LIST_MEM_IE           INDEX
    APPROVE_GRP_HIST_IE            INDEX
    10 rows selected.Message was edited by:
    david_tyler
    Oops, copy + pasted the wrong comments for the 2nd proc.

  • Insert, Case and Select

    I try to do one insert with case and select and I can't, I don't know why:
    This is what I want
    I have one column in the TAUX_MEDIA_PPM named GRAU. IF GRAU = 'TIPO', the I have to do one type of INSERT, if is = 'ATRIBUTO' I have to do another type of INSERT and ELSE, another type of INSERT.
    This is what I tested for the last time:
    SELECT T1.GRAU,
    CASE
    WHEN T1.GRAU = 'TIPO' THEN
    INSERT INTO TF_MEDIA_PPM__TESTE (
    MEDIA_PPM_SEQ, DATA_SK, ESCOPO_SK, MOTIVO_SK, PERIODO_TIPO, MEDIA_PPM_TIPO, TRES_SIGMA_TIPO, SEIS_SIGMA_TIPO,
    PERIODO_ATRIBUTO, MEDIA_PPM_ATRIBUTO, TRES_SIGMA_ATRIBUTO, SEIS_SIGMA_ATRIBUTO, PERIODO_ATRIBCOMPL, MEDIA_PPM_ATRIBCOMPL,
    TRES_SIGMA_ATRIBCOMPL, SEIS_SIGMA_ATRIBCOMPL
    ) VALUES (
    SEQ_TF_MEDIA_PPM.nextval, T2.DATA_SK, T1.ESCOPO_SK, T1.MOTIVO_SK, NULL, T2.MEDIA, T2.ALERTA, T2.ATENCAO, NULL,
    0, 0, 0, NULL, 0, 0, 0
    WHEN T1.GRAU = 'ATRIBUTO' THEN
    INSERT INTO TF_MEDIA_PPM__TESTE (
    MEDIA_PPM_SEQ, DATA_SK, ESCOPO_SK, MOTIVO_SK, PERIODO_TIPO, MEDIA_PPM_TIPO, TRES_SIGMA_TIPO, SEIS_SIGMA_TIPO,
    PERIODO_ATRIBUTO, MEDIA_PPM_ATRIBUTO, TRES_SIGMA_ATRIBUTO, SEIS_SIGMA_ATRIBUTO, PERIODO_ATRIBCOMPL, MEDIA_PPM_ATRIBCOMPL,
    TRES_SIGMA_ATRIBCOMPL, SEIS_SIGMA_ATRIBCOMPL
    ) VALUES (
    SEQ_TF_MEDIA_PPM.nextval, T2.DATA_SK, T1.ESCOPO_SK, T1.MOTIVO_SK, NULL, 0, 0, 0, NULL,
    T2.MEDIA, T2.ALERTA, T2.ATENCAO, NULL, 0, 0, 0
    WHEN T1.GRAU = 'ATRIB_COMPL' THEN
    INSERT INTO TF_MEDIA_PPM__TESTE (
    MEDIA_PPM_SEQ, DATA_SK, ESCOPO_SK, MOTIVO_SK, PERIODO_TIPO, MEDIA_PPM_TIPO, TRES_SIGMA_TIPO, SEIS_SIGMA_TIPO,
    PERIODO_ATRIBUTO, MEDIA_PPM_ATRIBUTO, TRES_SIGMA_ATRIBUTO, SEIS_SIGMA_ATRIBUTO, PERIODO_ATRIBCOMPL, MEDIA_PPM_ATRIBCOMPL,
    TRES_SIGMA_ATRIBCOMPL, SEIS_SIGMA_ATRIBCOMPL
    ) VALUES (
    SEQ_TF_MEDIA_PPM.nextval, T2.DATA_SK, T1.ESCOPO_SK, T1.MOTIVO_SK, NULL, 0, 0, 0, NULL,
    0, 0, 0, NULL, T2.MEDIA, T2.ALERTA, T2.ATENCAO
    END
    FROM TAUX_MEDIA_PPM
    JOIN TX_MEDIA T2 ON T2.CHAVE = T1.CHAVE;
    I don't know what I have to do now...
    Regards,
    Tiberio
    Edited by: MrTiberio on 27/03/2012 06:55
    Fixing code formatting

    I used this:
    INSERT INTO tf_media_ppm__teste
    (media_ppm_seq,data_sk,escopo_sk,motivo_sk,periodo_tipo,media_ppm_tipo,tres_sigma_tipo,seis_sigma_tipo,periodo_atributo,media_ppm_atributo
    ,tres_sigma_atributo,seis_sigma_atributo,periodo_atribcompl,media_ppm_atribcompl,tres_sigma_atribcompl,seis_sigma_atribcompl)
    SELECT seq_tf_media_ppm.nextval,t2.data_sk,t1.escopo_sk,t1.motivo_sk,NULL
    ,CASE t1.grau WHEN 'TIPO' THEN t2.media ELSE 0 END
    ,CASE t1.grau WHEN 'TIPO' THEN t2.alerta ELSE 0 END
    ,CASE t1.grau WHEN 'TIPO' THEN t2.atencao ELSE 0 END
    ,NULL
    ,CASE t1.grau WHEN 'ATRIBUTO' THEN t2.media ELSE 0 END
    ,CASE t1.grau WHEN 'ATRIBUTO' THEN t2.alerta ELSE 0 END
    ,CASE t1.grau WHEN 'ATRIBUTO' THEN t2.atencao ELSE 0 END
    ,NULL
    ,CASE t1.grau WHEN 'ATRIB_COMPL' THEN t2.media ELSE 0 END
    ,CASE t1.grau WHEN 'ATRIB_COMPL' THEN t2.alerta ELSE 0 END
    ,CASE t1.grau WHEN 'ATRIB_COMPL' THEN t2.atencao ELSE 0 END
    FROM TAUX_MEDIA_PPM T1
    JOIN TX_MEDIA T2 ON T2.CHAVE = T1.CHAVE;
    and worked fine.
    Thanks for both of you !

Maybe you are looking for

  • DB2 Connect installation for more as one application-server...

    Greetings, We've installed SAP 4.6D and migrated to ECC 6.0... also migrated from ICLI to DB2 Connect. We've 4 application server's on Win2k3. What's the perfect, with best performance - installation from DB2 Connect ? DB2 Connect on every appication

  • WARNING: LONG POST:  Needing some help with Java Prog

    I hope that this forum can support enough formatting to make the source I'm going to post semi-readable... but here's the problem. First, the program is supposed to take a positive numerical input and turn it into a numerical palindrome by reversal.

  • MISSING BOOKS from iPhoto

    MISSING BOOKS: We upgraded to iLife 08. Our BOOKS created in iPhoto 6 are now missing.

  • Pen tool - feather

    Hi, If I draw a closed path with pen tool that has sharp angles and then make a selection out of it I always end up with a feathered selection. How do I make the selection follow the path exactly? Thanks, Martti

  • I can't type some characters into firefox for android with physical keypad

    I am using an android device which is a Sharp 007sh that come with a physical 9 number keypad like those old nokia phone, running stock android 2.3 and using an input method modifier named as cedIME that can be downloaded from google play. and with t