CASE Statement is not working Derived table

Hi All,
in the bello SQL Statement case statement is not working in derived table. I am new to creation of derived table if any body knows plz kinldy help me out on this.
SELECT x.market, x.droprate as med1
FROM
(select upper(market_name) as market, fulldate as date_value,
     (sum([Dy_LOT_DROPS_N][Dy_OB_HO_DROPS][Dy_NonRF_Drop]))/
          nullif(sum(CASE WHEN (month(BBHDLY.FullDate)}>= 6 and { year(BBHDLY.FullDate)} = 2011) or {fn year(IDENSLABBHDLY.FullDate)} > 2011
THEN  BBHDLY.Dy_Calls - BBHDLY.Dy_HO_CHAN_ALLOC ELSE BBHDLY.Dy_Calls END),0)*100 as droprate
from BBHDLY sla
inner join Dim mkt
     on sla.bts_name = mkt.bts_name and sla.SectorID = mkt.Sector_Id
               where fulldate >= GETDATE()-46
               group by market_name, fulldate) x,
(select market_name as market, fulldate as date_value,
(sum([Dy_LOT_DROPS_N][Dy_OB_HO_DROPS][Dy_NonRF_Drop]))/
          nullif(sum(CASE WHEN ({fn month(BBHDLY.FullDate)}>= 6 and {fn year(BBHDLY.FullDate)} = 2011) or {fn year(BBHDLY.FullDate)} >
2011 THEN  BBHDLY.Dy_Calls - BBHDLY.Dy_HO_CHAN_ALLOC ELSE BBHDLY.Dy_Calls END),0)*100 as droprate
from BBHDLY sla
inner join Dim mkt
     on sla.bts_name = mkt.bts_name and sla.SectorID = mkt.Sector_Id
               where fulldate >=GETDATE()-46
               group by market_name, fulldate) y
where x.market = y.market
GROUP BY x.droprate, x.market
HAVING
   SUM(CASE WHEN y.droprate <= x.droprate
      THEN 1 ELSE 0 END)>=(COUNT(*)+1)/2 AND
   SUM(CASE WHEN y.droprate >= x.droprate
      THEN 1 ELSE 0 END)>=(COUNT(*)/2)+1
Thanks

It looks like SQL Server or Sybase given that you're using getdate().
As such, Vinesh's comment to use decode is wrong - decode is  Oracle syntax.
Looking at your statement again, I've noticed the following:
you have no { to match the first } - not sure why you're using them anyway.
you haven't given x.market a name - use x.market as market instead
use coalesce instead of nullif if you're on SQL Server.

Similar Messages

  • Case statement insert not working

    This cursor is retrieving data for each pidm
    SPRIDEN_PIDM     ACTIVITY1     ACTIVITY2     ACTIVITY3     ACTIVITY4     ACTIVITY5     ACTIVITY6
    2287953                        RA      RC      RF     RJ       RN      RU
    CURSOR activities_cursor
          IS
             SELECT spriden_pidm,
                    REGEXP_SUBSTR (szcasup_activities,
                                   '[[:alpha:]]+',
                                   1,
                                   1
                                  ) activity1,
                    REGEXP_SUBSTR (szcasup_activities,
                                   '[[:alpha:]]+',
                                   1,
                                   2
                                  ) activity2,
                    REGEXP_SUBSTR (szcasup_activities,
                                   '[[:alpha:]]+',
                                   1,
                                   3
                                  ) activity3,
                    REGEXP_SUBSTR (szcasup_activities,
                                   '[[:alpha:]]+',
                                   1,
                                   4
                                  ) activity4,
                    REGEXP_SUBSTR (szcasup_activities,
                                   '[[:alpha:]]+',
                                   1,
                                   5
                                  ) activity5,
                    REGEXP_SUBSTR (szcasup_activities,
                                   '[[:alpha:]]+',
                                   1,
                                   6
                                  ) activity6              
               FROM saturn_midd.szcasup, saturn.spriden
              WHERE szcasup_common_appl_id = spriden_id
                AND spriden_ntyp_code = 'CAPP';Then I fetched the results in variadles
    FETCH activities_cursor
              INTO v_pidm, v_activity1, v_activity2, v_activity3, v_activity4,
                   v_activity5,v_activity6;
    Created a loop with a case statement
    LOOP
             FETCH activities_cursor
              INTO v_pidm, v_activity1, v_activity2, v_activity3, v_activity4,
                   v_activity5,v_activity6;
             EXIT WHEN activities_cursor%NOTFOUND;
             IF activities_cursor%FOUND
             THEN
                CASE
                   WHEN (v_activity1 IS NOT NULL)
                   THEN
                      INSERT INTO saturn.sorints
                                  (sorints_pidm, sorints_ints_code,
                                   sorints_activity_date)
                                   values
                                    v_pidm,
                                     v_activity1,
                                      sysdate
                    WHEN (v_activity2 IS NOT NULL)
                   THEN
                      INSERT INTO saturn.sorints
                                  (sorints_pidm, sorints_ints_code,
                                   sorints_activity_date)
                                   values
                                    v_pidm,
                                     v_activity2,
                                      sysdate
                   WHEN (v_activity3 IS NOT NULL)
                   THEN
                      INSERT INTO saturn.sorints
                                  (sorints_pidm, sorints_ints_code,
                                   sorints_activity_date)
                                   values
                                    v_pidm,
                                     v_activity3,
                                      sysdate
                    WHEN (v_activity4 IS NOT NULL)
                   THEN
                      INSERT INTO saturn.sorints
                                  (sorints_pidm, sorints_ints_code,
                                   sorints_activity_date)
                                   values
                                    v_pidm,
                                     v_activity4,
                                      sysdate
                END CASE;
             END IF;
          END LOOP;
    It is working just for one activity (activity1) The variable definition is correctv_activity1 sorints.sorints_ints_code%TYPE;
    v_activity2 sorints.sorints_ints_code%TYPE;
    v_activity3 sorints.sorints_ints_code%TYPE;
    v_activity4 sorints.sorints_ints_code%TYPE;
    v_activity5 sorints.sorints_ints_code%TYPE;
    v_activity6 sorints.sorints_ints_code%TYPE;
    Edited by: peace4all on Aug 16, 2009 9:42 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    peace4all wrote:
    It is working just for one activity (activity1) The variable definition is correct
    Well, what else did you expect? CASE evaluates brances starting first one. If WHEN condition is not met it continues to next one. As soon as WHEN condition is met, THEN clause is executed after that CASE exits. You need to use IF statement, not case:
    with t as (
               select to_date('01/11/2005','dd/mm/yyyy') Start_Date,to_date('13/11/2005','dd/mm/yyyy') End_Date,13 Days,'CMP1' Component,1000.00 Amount from dual union all
               select to_date('01/11/2005','dd/mm/yyyy'),to_date('13/11/2005','dd/mm/yyyy'),13,'CMP2',826.67 from dual union all
               select to_date('15/11/2005','dd/mm/yyyy'),to_date('20/11/2005','dd/mm/yyyy'),6,'CMP1',413.33 from dual union all
               select to_date('15/11/2005','dd/mm/yyyy'),to_date('20/11/2005','dd/mm/yyyy'),6,'CMP2',166.67 from dual union all
               select to_date('21/11/2005','dd/mm/yyyy'),to_date('28/11/2005','dd/mm/yyyy'),8,'CMP1',633.00 from dual union all
               select to_date('21/11/2005','dd/mm/yyyy'),to_date('28/11/2005','dd/mm/yyyy'),8,'CMP2',111.00 from dual union all
               select to_date('21/11/2005','dd/mm/yyyy'),to_date('28/11/2005','dd/mm/yyyy'),8,'CMP3',22.00 from dual union all
               select to_date('21/11/2005','dd/mm/yyyy'),to_date('28/11/2005','dd/mm/yyyy'),8,'CMP4',333.00 from dual union all
               select to_date('01/12/2005','dd/mm/yyyy'),to_date('15/12/2005','dd/mm/yyyy'),15,'CMP1',2480.00 from dual union all
               select to_date('01/12/2005','dd/mm/yyyy'),to_date('15/12/2005','dd/mm/yyyy'),15,'CMP2',1488.00 from dual union all
               select to_date('01/12/2005','dd/mm/yyyy'),to_date('15/12/2005','dd/mm/yyyy'),15,'CMP3',496.00 from dual union all
               select to_date('01/12/2005','dd/mm/yyyy'),to_date('15/12/2005','dd/mm/yyyy'),15,'CMP4',200.00 from dual union all
               select to_date('16/12/2005','dd/mm/yyyy'),to_date('31/12/2005','dd/mm/yyyy'),16,'CMP1',522.00 from dual union all
               select to_date('16/12/2005','dd/mm/yyyy'),to_date('31/12/2005','dd/mm/yyyy'),16,'CMP2',166.00 from dual union all
               select to_date('16/12/2005','dd/mm/yyyy'),to_date('31/12/2005','dd/mm/yyyy'),16,'CMP3',242.00 from dual
    SELECT  P_Month,
            SUM(LEAST(LAST_DAY(P_Month),end_date) - GREATEST(P_Month,start_date) + 1) Total_Days
      FROM  t,
             SELECT  ADD_MONTHS(first_month,LEVEL - 1) P_Month
               FROM  (
                      SELECT  TRUNC(MIN(start_date),'MM') first_month,
                              TRUNC(MAX(end_date),'MM') last_month
                        FROM  t
               CONNECT BY LEVEL <= MONTHS_BETWEEN(last_month,first_month) + 1
      WHERE P_Month BETWEEN TRUNC(start_date,'MM') and end_date
      GROUP BY P_Month
      ORDER BY P_Month
    with t as (
               select to_date('01/11/2005','dd/mm/yyyy') Start_Date,to_date('13/11/2005','dd/mm/yyyy') End_Date,13 Days,'CMP1' Component,1000.00 Amount from dual union all
               select to_date('01/11/2005','dd/mm/yyyy'),to_date('13/11/2005','dd/mm/yyyy'),13,'CMP2',826.67 from dual union all
               select to_date('15/11/2005','dd/mm/yyyy'),to_date('20/11/2005','dd/mm/yyyy'),6,'CMP1',413.33 from dual union all
               select to_date('15/11/2005','dd/mm/yyyy'),to_date('20/11/2005','dd/mm/yyyy'),6,'CMP2',166.67 from dual union all
               select to_date('21/11/2005','dd/mm/yyyy'),to_date('28/11/2005','dd/mm/yyyy'),8,'CMP1',633.00 from dual union all
               select to_date('21/11/2005','dd/mm/yyyy'),to_date('28/11/2005','dd/mm/yyyy'),8,'CMP2',111.00 from dual union all
               select to_date('21/11/2005','dd/mm/yyyy'),to_date('28/11/2005','dd/mm/yyyy'),8,'CMP3',22.00 from dual union all
               select to_date('21/11/2005','dd/mm/yyyy'),to_date('28/11/2005','dd/mm/yyyy'),8,'CMP4',333.00 from dual union all
               select to_date('01/12/2005','dd/mm/yyyy'),to_date('15/12/2005','dd/mm/yyyy'),15,'CMP1',2480.00 from dual union all
               select to_date('01/12/2005','dd/mm/yyyy'),to_date('15/12/2005','dd/mm/yyyy'),15,'CMP2',1488.00 from dual union all
               select to_date('01/12/2005','dd/mm/yyyy'),to_date('15/12/2005','dd/mm/yyyy'),15,'CMP3',496.00 from dual union all
               select to_date('01/12/2005','dd/mm/yyyy'),to_date('15/12/2005','dd/mm/yyyy'),15,'CMP4',200.00 from dual union all
               select to_date('16/12/2005','dd/mm/yyyy'),to_date('31/12/2005','dd/mm/yyyy'),16,'CMP1',522.00 from dual union all
               select to_date('16/12/2005','dd/mm/yyyy'),to_date('31/12/2005','dd/mm/yyyy'),16,'CMP2',166.00 from dual union all
               select to_date('16/12/2005','dd/mm/yyyy'),to_date('31/12/2006','dd/mm/yyyy'),381,'CMP3',242.00 from dual
    SELECT  P_Month,
            SUM(LEAST(LAST_DAY(P_Month),end_date) - GREATEST(P_Month,start_date) + 1) Total_Days
      FROM  t,
             SELECT  ADD_MONTHS(first_month,LEVEL - 1) P_Month
               FROM  (
                      SELECT  TRUNC(MIN(start_date),'MM') first_month,
                              TRUNC(MAX(end_date),'MM') last_month
                        FROM  t
               CONNECT BY LEVEL <= MONTHS_BETWEEN(last_month,first_month) + 1
      WHERE P_Month BETWEEN TRUNC(start_date,'MM') and end_date
      GROUP BY P_Month
      ORDER BY P_Month
    LOOP
             FETCH activities_cursor
              INTO v_pidm, v_activity1, v_activity2, v_activity3, v_activity4,
                   v_activity5,v_activity6;
             EXIT WHEN activities_cursor%NOTFOUND;
             IF v_activity1 IS NOT NULL
                   THEN
                      INSERT INTO saturn.sorints
                                  (sorints_pidm, sorints_ints_code,
                                   sorints_activity_date)
                                   values
                                    v_pidm,
                                     v_activity1,
                                      sysdate
              ELSIF v_activity2 IS NOT NULL
                   THEN
                      INSERT INTO saturn.sorints
                                  (sorints_pidm, sorints_ints_code,
                                   sorints_activity_date)
                                   values
                                    v_pidm,
                                     v_activity2,
                                      sysdate
              ELSIF v_activity3 IS NOT NULL
                   THEN
                      INSERT INTO saturn.sorints
                                  (sorints_pidm, sorints_ints_code,
                                   sorints_activity_date)
                                   values
                                    v_pidm,
                                     v_activity3,
                                      sysdate
              ELSIF v_activity4 IS NOT NULL
                   THEN
                      INSERT INTO saturn.sorints
                                  (sorints_pidm, sorints_ints_code,
                                   sorints_activity_date)
                                   values
                                    v_pidm,
                                     v_activity4,
                                      sysdate
              END IF;
          END LOOP;SY.

  • NOT IN clause in CASE statement condition not working

    Dear Friends,
    I want to use below condition in WHERE clause of my SELECT statement.
    WHERE <...........>
    <...........>
    AND eihf.exr_aip_asset_sid NOT IN
    (CASE when safa.fund_relation = 'C' and safa.fund_account_code != vFundAccount
    THEN (37874,37909,43424,55040,59513,59598,58570,76148,75885,75927)
    ELSE
    (0)
    END
    But it gives me an error as "missing right parenthis".
    Please help.
    Regards,
    Jignesh

    CASE returns one and only one value. It can't return a list. Your satement should be something like:
    WHERE <...........>
    <...........>
    AND (
                 safa.fund_relation = 'C'
             AND
                 safa.fund_account_code != vFundAccount
             AND
                 eihf.exr_aip_asset_sid NOT IN (37874,37909,43424,55040,59513,59598,58570,76148,75885,75927)
         OR
             NOT (
                      safa.fund_relation = 'C'
                  AND
                      safa.fund_account_code != vFundAccount
             AND
                 eihf.exr_aip_asset_sid != 0
        )SY.

  • Insert statement is not working for z table.

    Hi experts,
    My insert statement is not working.
    I have used follwing code to update z table .
    INSERT ztable FROM TABLE gt_table.
    here i have checked gt_table and its filled up with all the records properly.
    now the problem is in this table i have 15 fields and it inserts 14  fields of it but
    the last field is never inserted though in gt_table i can see value for last fields also.
    I have added this field in ztable recently . so i also used se14 to adjust table but still i am facing same problem.
    please help me out.
    thanks,
    Neo

    > > Table maintainance will have nothing to do with
    > this
    > > issue.
    >
    > It does sometimes when you are trying to see the
    > values from SM30 instead of SE16. The value may be
    > there, but it may just not seen in SM30 because the
    > table maintenance hasn't registered the addition of
    > new field.
    >
    > Another place to look at is the activation log to see
    > if there are any warnings issued there.
    You shouldn't use SM30 to view table entries. You use this transaction to maintain the table entries. Pure and Simple.

  • Insert statement will not work if select statement has less number of colum

    Hi,
    One of my thread is already resolved on the following URL : unable to insert rows into the table
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
    DECLARE
    S VARCHAR2(200);
    STMT VARCHAR2(500);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    STMT := 'INSERT INTO TEMP SELECT * FROM ';
    STMT:=STMT || C.TABLE_NAME;
    EXECUTE IMMEDIATE STMT;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
    Please let me know , how can i execute proper way.
    Thanks.
    Best Regards
    Arshad

    user13360241 wrote:
    Hi,
    One of my thread is already resolved on the following URL : unable to insert rows into the table
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
    DECLARE
    S VARCHAR2(200);
    STMT VARCHAR2(500);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    STMT := 'INSERT INTO TEMP SELECT * FROM ';
    STMT:=STMT || C.TABLE_NAME;
    EXECUTE IMMEDIATE STMT;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
    Please let me know , how can i execute proper way.
    Thanks.
    Best Regards
    Arshadmore often than not "TEMP" tables are NOT required & are highly inefficient in Oracle.
    Either only specify explicit column in TEMP to get data,
    or provide value for "extra" column in TEMP

  • Delete Statement is not working correctly

    Hello,
    The following delete statement is not working correctly.
    If I press delete it will delete everything in the category table
    I don't know whats wrong with it.
    ----delete row from category if there is not infrastructure to support------
    IF :P12_DFCY_SEQNO4 IS NOT NULL AND :P12_DFCY_CATG_C = '7' THEN
    DELETE FROM DFCY_CATG
    WHERE NOT EXISTS(SELECT I.DFCY_SEQNO
    FROM DFCY_CATG C, DFCY_CATG_INFRSTRCTR I
    WHERE C.DFCY_SEQNO = I.DFCY_SEQNO
    AND :P12_DFCY_SEQNO4 = I.DFCY_SEQNO);
    end if;
    Thanks
    Mary

    Hi,
    IF :P12_DFCY_SEQNO4 IS NOT NULL AND :P12_DFCY_CATG_C = '7' THEN
    DELETE FROM DFCY_CATG
    WHERE NOT EXISTS(SELECT I.DFCY_SEQNO
    FROM DFCY_CATG C, DFCY_CATG_INFRSTRCTR I
    WHERE C.DFCY_SEQNO = I.DFCY_SEQNO
    AND :P12_DFCY_SEQNO4 = I.DFCY_SEQNO);
    end if;So, if P12_DFCY_SEQNO4 does not exist, then I would expect all records to be deleted because the NOT EXISTS() function would just return TRUE for every record on the table. Somewhere in the statement, I would expect to see something that links between the table being deleted from and the NOT EXISTS() data or, perhaps, using the P12_DFCY_CATG_C value as a filter?
    Andy

  • Delete statement is not working.

    Hi,
    find the code. Here the delete statement is not working and i am getting sy-subrc = 4. although ,
    xe1edp10-idnkd = 34596 and dint_edidd -sdata = 34596.
    please help me ...
    loop at dekek_x.
    loop at dint_edidd where segnam = 'E1EDP10'.
    if dekek_x-stpin = 1 .
    CLEAR xe1edp10.
      MOVE dint_edidd-sdata TO xe1edp10.
    delete dint_edidd where sdata = xe1edp10-idnkd.
    endif.
    endloop.

    1st thing..
    i tried this :
    tables: edidd, e1edp10.
    edidd-sdata = '315934 EA 017'.
    WRITE edidd-sdata.
    move edidd-sdata to e1edp10.
    IF edidd-sdata = e1edp10-idnkd.
    WRITE: e1edp10-idnkd.
    else.
      WRITE: 'nothing'.
    ENDIF.
    output
    >315934 EA 017
    >315934 EA 017
    2nd thing,.
    your loop inside loop doesnt make any sense as they are not related any where.
    3rd thing:
    the fields are not type compatible.. this might be the reason for wrong delete statement..
    and 1 more clarification:
    TABLES: edidd, e1edp10.
    DATA :it TYPE TABLE OF edidd WITH HEADER LINE.
    edidd-sdata = '315934 EA 017'.
    WRITE edidd-sdata.
    APPEND edidd TO it.
    edidd-sdata = '315934 EA 018'.
    APPEND edidd TO it.
    LOOP AT it." where segnam = 'E1EDP10'.
      CLEAR e1edp10.
      MOVE it-sdata TO e1edp10.
      DELETE it WHERE sdata = e1edp10-idnkd.
    ENDLOOP.
    in this also delete is working perfectly fine... you run and check..

  • SORT statement is not working!

    Hi frdz,
    Below SORT statement is not working. Can any one explain me why this is happening.
    SORT i_bseg ASCENDING BY belnr bukrs
                        DESCENDING kunnr.
    I have table content as below.
    BELNR      BUKRS KUNNR   
    0016000000|CROP |         
    0016000000|CROP |0008910168
    Before and after the sort content order is same.
    I want to sort the content like below.
    0016000000|CROP |0008910168
    0016000000|CROP |       
    Is there any thing wrong with the sort statement???
    i_bseg is defined as TYPE STANDARD TABLE OF
    Sort criteria must not change i. e ascending by belnr and bukrs and descending by kunnr.
    Thanks,
    Vinod.

    hi vinod,
    this is because on your statement, you are sorting BUKRS in descending order and KUNNR in ASCENDING order.
    please take note that the sort order should come after the sorted field. if no order is given, the default which is ASCENDING will be used.
    do your sorting like this
    SORT i_bseg BY belnr bukrs kunnr DESCENDING.
    regards,
    Peter

  • Oracle equals_path condition NOT working with table and materialized view

    The user i am using is xdb with dba role.
    1.When i try to use the statement
    SELECT PATH FROM xdb.path_VIEW
    WHERE
    EQUALS_PATH(res, '/home/OE/PurchaseOrders/2002')=1
    the result is
    /home/OE/PurchaseOrders/2002
    2. When i drop the path_view and recreated it like materialized view with statement
    create MATERIALIZED view path_view as
    select /*+ ORDERED */ t2.path path, t.res res,
    xmltype.createxml(xdb.xdb_link_type(NULL, r2.xmldata.dispname, t.name,
    h.name, h.flags, h.parent_oid, h.child_oid),
    'http://xmlns.oracle.com/xdb/XDBStandard.xsd', 'LINK') link,
    t.resid
    from ( select xdb.all_path(9999) paths, value(p) res, p.sys_nc_oid$ resid,
    p.xmldata.dispname name
    from xdb.xdb$resource p
    where xdb.under_path(value(p), '/', 9999)=1 ) t,
    TABLE( cast (t.paths as xdb.path_array) ) t2,
    xdb.xdb$h_link h, xdb.xdb$resource r2
    where t2.parent_oid = h.parent_oid and t2.childname = h.name and
    t2.parent_oid = r2.sys_nc_oid$
    then the equals_path condition STOP working !!!
    3. The same experiment, but i recreate it like table
    create table path_view as .... using the rest of the statement ...
    Can someone help me to understand why equals_path is NOT working on table and materialized view !

    Thanks Jonah. I was under the impression that I already had it but seems like it has to be a direct priv - thru a role doesn't work.
    I granted the reqd privs and then it worked fine. Thx for your help!

  • Layout adjustment not working with tables

    Hi all
    Why will layout adjustment not work with tables?
    I am trying to re-format from A4 landscape to A4 portrait.
    The text box containing the table will resize but not the table.
    Any clues why this might be, I don't want to manually resize every table in the document.
    Many thanks,
    Rob

    Thanks Jongware,
    Having resized the table and got the little red ovals, I tried various things like changing the font size etc but the best workaround I found was to select the table and change the cell inset value to 0, this got rid of all red ovals and I didn't need to change the font size.
    Cheers,
    Rob

  • Upper case "s" does not work in most programs

    Upper case "s" does not work in a number of programs, lower case is fine. It is the only letter that is missing in both cases.
    Any ideas. Do I need to reinstall driver for keyboard? If so any idea where to get it.

    Open the Speech pane of System Preferences and check whether either the listening key or the speech key has become set to that keystroke; if so, change the setting.
    (41135)

  • Count Distinct Wtih CASE Statement - Does not follow aggregation path

    All,
    I have a fact table, a day aggregate and a month aggregate. I have a time hierarchy and the month aggregate is set to the month level, the day aggregate is set to the day level within the time hierarchy.
    When using any measures and a field from my time dimension .. the appropriate aggregate is chosen, ie month & activity count .. month aggregate is used. Day & activity count .. day aggregate is used.
    However - when I use the count distinct aggregate rule .. the request always uses the lowest common denominator. The way I have found to get this to work is to use a logical table source override in the aggregation tab. Once I do this .. it does use the aggregates correctly.
    A few questions
    1. Is this the correct way to use aggregate navigation for the count distinct aggregation rule (using the source override option)? If yes, why is this necessary for count distinct .. what is special about it?
    2. The main problem I have now is that I need to create a simple count measure that has a CASE statement in it. The only way I see to do this is to select the Based on Dimensions checkbox which then allows me to add a CASE statement into my count distinct clause. But now the aggregation issue comes back into play and I can't do the logical table source override when the based on dimensions checkbox is checked .. so I am now stuck .. any help is appreciated.
    K

    Ok - I found a workaround (and maybe the preferred solution for my particular issue), which is - Using a CASE Statement with a COUNT DISTINCT aggregation and still havine AGGREGATE AWARENESS
    To get all three of the requirements above to work I had to do the following:
    - Create the COUNT DISTINCT as normal (counting on a USERID physically mapped column in my case)
    - Now I need to map my fact and aggregates to this column. This is where I got the case statement to work. Instead of trying to put the case statement inside of the Aggregate definition by using the checkbox 'Base on Dimension' (which didnt allow for aggregate awareness for some reason) .. I instead specified the case statement in the Column Mapping section of the Fact and Aggregate tables.
    - Once all the LTS's (facts and aggregates) are mapped .. you still have to define the Logical Table Source overrides in the aggregate tab of the count distinct definition. Add in all the fact and aggregates.
    Now the measure will use my month aggregate when i specify month, the day aggregate when i specify day, etc..
    If you are just trying to use a Count Distinct (no CASE satement needed) with Aggregate Awareness, you just need to use the Logical Table Source override on the aggregate tab.
    There is still a funky issue when using the COUNT aggregate type. As long as you dont map multiple logical table sources to the COUNT column it works fine and as expected. But, if you try to add in multiple sources and aggregate awareness it randomly starts SUMMING everything .. very weird. The blog in this thread says to check the 'Based on Dimension' checkbox to fix the problem but that did not work for me. Still not sure what to do on this one .. but its not currently causing me a problem so I will ignore for now ;)
    Thanks for all the help
    K

  • SELECT statement does not work if characters ## are contained in field

    Hi Experts,
    I have the following statement:
    select single field1
        from table1
        into var1
        where field2 = text.
    This is a very simple statement that is working for me almost always correct. However there is a situation where the system is not able to find the record in my table. If text is equal to JAN##2011 the system won't deliver a result even if I have an entry in table1 with exactly this value.
    TABLE1
    field1 field2
    rome JAN##2011
    paris JAN2011
    only if text is JAN2011 the select will find a result.
    all fields are defined as CHAR.
    Thanks in advanced

    Hi Alberto,
    probably ## is not ## :-).
    is the visible representation used by ABAP to show any non-displayable characters as control characters like TAB, CR, LF, FF and the like.
    In debugger you can switch to HEX display of values, if you see something like 0A0D you can find this using CL_ABAP_CHAR_UTILITIES constant attributes.
    Regards
    Clemens

  • Last_page button is not working in table control-urgent

    hi  all,
    iam displaying the data in table control.in my pf-status i have first_page,next_page,prev_page and last_page.out of 4 buttons 3 buttons are working finr except last_page. any body can send me the code for this program.iam sending my program below.
    REPORT ZMAHI_TABLE_CONTROL .
    TABLES : VBAK,VBAP.
    DATA : BEGIN OF ITAB OCCURS 0,
             VBELN TYPE VBAK-VBELN,
             ERDAT TYPE VBAK-ERDAT,
             ERNAM TYPE VBAK-ERNAM,
             ERZET TYPE VBAK-ERZET,
             REASON(40) TYPE C,
           END OF ITAB.
    DATA :   FILL TYPE I VALUE 1.
    DATA : N TYPE I .
    DATA      : BEGIN OF XVALUES OCCURS 50,
                  BUTXT LIKE  T001-BUTXT,
                END OF XVALUES.
    DATA      : BEGIN OF XFIELDS OCCURS 50.
            INCLUDE STRUCTURE HELP_VALUE.
    DATA      : END OF XFIELDS.
    DATA      : BEGIN OF SEL_VAL OCCURS 50.
            INCLUDE STRUCTURE HELP_VTAB.
    DATA      : END OF SEL_VAL.
    TABLE CONTROL DECLARATIONS------
    CONTROLS : CONTROL_DATA TYPE TABLEVIEW USING  SCREEN '100'.
    DATA : OK_CODE TYPE SY-UCOMM,
    LIN TYPE I,
    LIN1 TYPE I,
    LIN2 TYPE I,
    LIN3 TYPE I.
    DATA: LINES TYPE I,
          LIMIT TYPE I VALUE 1.
    DATA :   LINE_COUNT       TYPE  I,
             LINEI            TYPE  I,
             LINEJ            TYPE  I,
             LINE1            TYPE  I,
             LINE2            TYPE  I,
             LN1              TYPE  I.
    SELECTION-SCREEN : BEGIN OF BLOCK B1.
    SELECT-OPTIONS   : P_VBELN FOR VBAK-VBELN.
    SELECTION-SCREEN : END OF BLOCK B1.
    START-OF-SELECTION.
      SELECT VBELN
             ERDAT
             ERNAM
             ERZET
        FROM VBAK
        INTO TABLE ITAB
      WHERE VBELN IN P_VBELN.
      CALL SCREEN 100.
    *&      Module  F4_HELP  INPUT
    MODULE F4_HELP INPUT.
      FREE  :  XFIELDS,SEL_VAL,XVALUES.
      MOVE : 'ZMAHI'     TO XFIELDS-TABNAME,
             'REASON'    TO XFIELDS-FIELDNAME,
             'X'        TO XFIELDS-SELECTFLAG.
      APPEND XFIELDS.
      XVALUES = 'Non Trade F&F'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Retention'.
      APPEND XVALUES .
      XVALUES = 'Oldbills Accnt cntmnt'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Not claimed'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Dispute'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Payment Block'.
      APPEND XVALUES .
      XVALUES = 'N/T Subsntly Cleared'.
      APPEND XVALUES .
      XVALUES = 'N/T Unstld Advances'.
      APPEND XVALUES .
      XVALUES = 'N/T OThers'.
      APPEND XVALUES .
      XVALUES = 'Trade Non Receipt OF BOE'.
      APPEND XVALUES .
      XVALUES = 'Trade OEM Adjustments'.
      APPEND XVALUES .
      XVALUES = 'Trade Reject Of Material'.
      APPEND XVALUES .
      XVALUES = 'Trade NOt Claimed'.
      APPEND XVALUES .
      XVALUES = 'Trade Dispute'.
      APPEND XVALUES .
      XVALUES = 'Trade Payment BLock'.
      APPEND XVALUES .
      XVALUES = 'Trade Subsntly Cleared'.
      APPEND XVALUES .
      XVALUES = 'Trade Non Submission of bills'.
      APPEND XVALUES .
      XVALUES = 'Trade others'.
      APPEND XVALUES .
      CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE_EXT'
           EXPORTING
                CUCOL         = 0
                CUROW         = 0
                DISPLAY       = ' '
                FIELDNAME     = 'REASON'
                TABNAME       = 'ZIFIOD011'
           IMPORTING
                SELECT_VALUE  = ITAB-REASON
           TABLES
                FIELDS        = XFIELDS
                SELECT_VALUES = SEL_VAL
                VALUETAB      = XVALUES.
    ENDMODULE.                 " F4_HELP  INPUT
    *&      Module  STATUS_0100  OUTPUT
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS '0100'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'CANCEL' OR 'EXIT' OR 'BACK'.
          LEAVE TO SCREEN 0.
       WHEN 'NEXT_LINE'.
         CONTROL_DATA-top_line = CONTROL_DATA-top_line + 1.
         limit = fill - lines + 1.
         IF CONTROL_DATA-top_line > limit.
           CONTROL_DATA-top_line = limit.
         ENDIF.
       WHEN 'PREV_LINE'.
         CONTROL_DATA-top_line = CONTROL_DATA-top_line - 1.
         IF CONTROL_DATA-top_line < 0.
           CONTROL_DATA-top_line = 0.
         ENDIF.
        WHEN 'NEXT_PAGE'.
          CONTROL_DATA-TOP_LINE = CONTROL_DATA-TOP_LINE + LINES.
          LIMIT = LIMIT + 1.
          CONTROL_DATA-TOP_LINE = LIMIT.
        WHEN 'PREV_PAGE'.
          CONTROL_DATA-TOP_LINE = CONTROL_DATA-TOP_LINE - LINES.
          LIMIT = LIMIT - 1.
          CONTROL_DATA-TOP_LINE = LIMIT.
       WHEN 'LAST_PAGE'.
         CONTROL_DATA-TOP_LINE =  FILL - LINES + 1.
        WHEN 'FIRST_PAGE'.
          CONTROL_DATA-TOP_LINE = 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  SCROLL_BAR  INPUT
    MODULE SCROLL_BAR INPUT.
      DESCRIBE  TABLE  ITAB  LINES  CONTROL_DATA-LINES.
    ENDMODULE.                 " SCROLL_BAR  INPUT
    thanks,
    maheedhar.T

    Hi Ravi,
    The code which u sent to me is not working for next page and previous page.
    can u plz resend me the code.
    iam sending my code below.
    REPORT ZMAHI_TABLE_CONTROL .
    TABLES : VBAK,VBAP.
    DATA : BEGIN OF ITAB OCCURS 0,
             VBELN TYPE VBAK-VBELN,
             ERDAT TYPE VBAK-ERDAT,
             ERNAM TYPE VBAK-ERNAM,
             ERZET TYPE VBAK-ERZET,
             REASON(40) TYPE C,
           END OF ITAB.
    DATA :   FILL TYPE I VALUE 1.
    DATA : N TYPE I .
    DATA      : BEGIN OF XVALUES OCCURS 50,
                  BUTXT LIKE  T001-BUTXT,
                END OF XVALUES.
    DATA      : BEGIN OF XFIELDS OCCURS 50.
            INCLUDE STRUCTURE HELP_VALUE.
    DATA      : END OF XFIELDS.
    DATA      : BEGIN OF SEL_VAL OCCURS 50.
            INCLUDE STRUCTURE HELP_VTAB.
    DATA      : END OF SEL_VAL.
    TABLE CONTROL DECLARATIONS------
    CONTROLS : CONTROL_DATA TYPE TABLEVIEW USING  SCREEN '100'.
    DATA : OK_CODE TYPE SY-UCOMM,
    LIN TYPE I,
    LIN1 TYPE I,
    LIN2 TYPE I,
    LIN3 TYPE I.
    DATA: LINES TYPE I,
          LIMIT TYPE I VALUE 1.
    DATA :   LINE_COUNT       TYPE  I,
             LINEI            TYPE  I,
             LINEJ            TYPE  I,
             LINE1            TYPE  I,
             LINE2            TYPE  I,
             LN1              TYPE  I.
    SELECTION-SCREEN : BEGIN OF BLOCK B1.
    SELECT-OPTIONS   : P_VBELN FOR VBAK-VBELN.
    SELECTION-SCREEN : END OF BLOCK B1.
    START-OF-SELECTION.
      SELECT VBELN
             ERDAT
             ERNAM
             ERZET
        FROM VBAK
        INTO TABLE ITAB
      WHERE VBELN IN P_VBELN.
      CALL SCREEN 100.
    *&      Module  F4_HELP  INPUT
    MODULE F4_HELP INPUT.
      FREE  :  XFIELDS,SEL_VAL,XVALUES.
      MOVE : 'ZMAHI'     TO XFIELDS-TABNAME,
             'REASON'    TO XFIELDS-FIELDNAME,
             'X'        TO XFIELDS-SELECTFLAG.
      APPEND XFIELDS.
      XVALUES = 'Non Trade F&F'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Retention'.
      APPEND XVALUES .
      XVALUES = 'Oldbills Accnt cntmnt'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Not claimed'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Dispute'.
      APPEND XVALUES .
      XVALUES = 'Non Trade Payment Block'.
      APPEND XVALUES .
      XVALUES = 'N/T Subsntly Cleared'.
      APPEND XVALUES .
      XVALUES = 'N/T Unstld Advances'.
      APPEND XVALUES .
      XVALUES = 'N/T OThers'.
      APPEND XVALUES .
      XVALUES = 'Trade Non Receipt OF BOE'.
      APPEND XVALUES .
      XVALUES = 'Trade OEM Adjustments'.
      APPEND XVALUES .
      XVALUES = 'Trade Reject Of Material'.
      APPEND XVALUES .
      XVALUES = 'Trade NOt Claimed'.
      APPEND XVALUES .
      XVALUES = 'Trade Dispute'.
      APPEND XVALUES .
      XVALUES = 'Trade Payment BLock'.
      APPEND XVALUES .
      XVALUES = 'Trade Subsntly Cleared'.
      APPEND XVALUES .
      XVALUES = 'Trade Non Submission of bills'.
      APPEND XVALUES .
      XVALUES = 'Trade others'.
      APPEND XVALUES .
      CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE_EXT'
           EXPORTING
                CUCOL         = 0
                CUROW         = 0
                DISPLAY       = ' '
                FIELDNAME     = 'REASON'
                TABNAME       = 'ZIFIOD011'
           IMPORTING
                SELECT_VALUE  = ITAB-REASON
           TABLES
                FIELDS        = XFIELDS
                SELECT_VALUES = SEL_VAL
                VALUETAB      = XVALUES.
    ENDMODULE.                 " F4_HELP  INPUT
    *&      Module  STATUS_0100  OUTPUT
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS '0100'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'CANCEL' OR 'EXIT' OR 'BACK'.
          LEAVE TO SCREEN 0.
       WHEN 'NEXT_LINE'.
         CONTROL_DATA-top_line = CONTROL_DATA-top_line + 1.
         limit = fill - lines + 1.
         IF CONTROL_DATA-top_line > limit.
           CONTROL_DATA-top_line = limit.
         ENDIF.
       WHEN 'PREV_LINE'.
         CONTROL_DATA-top_line = CONTROL_DATA-top_line - 1.
         IF CONTROL_DATA-top_line < 0.
           CONTROL_DATA-top_line = 0.
         ENDIF.
       WHEN 'NEXT_PAGE'.
         CONTROL_DATA-TOP_LINE = CONTROL_DATA-TOP_LINE + LINES.
         LIMIT = LIMIT + 1.
         CONTROL_DATA-TOP_LINE = LIMIT.
       WHEN 'PREV_PAGE'.
         CONTROL_DATA-TOP_LINE = CONTROL_DATA-TOP_LINE - LINES.
         LIMIT = LIMIT - 1.
         CONTROL_DATA-TOP_LINE = LIMIT.
       WHEN 'LAST_PAGE'.
         DESCRIBE TABLE ITAB LINES LIMIT.
         CONTROL_DATA-TOP_LINE =  LIMIT.
       WHEN 'FIRST_PAGE'.
         CONTROL_DATA-TOP_LINE = 0.
    WHEN 'P--'.
    CLEAR ok_code.
    PERFORM paging USING 'P--'.
    WHEN 'P-'.
    CLEAR ok_code.
    PERFORM paging USING 'P-'.
    WHEN 'P+'.
    CLEAR ok_code.
    PERFORM paging USING 'P+'.
    WHEN 'P++'.
    CLEAR ok_code.
    PERFORM paging USING 'P++'.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  SCROLL_BAR  INPUT
    MODULE SCROLL_BAR INPUT.
      DESCRIBE  TABLE  ITAB  LINES  CONTROL_DATA-LINES.
    ENDMODULE.                 " SCROLL_BAR  INPUT
    *&      Form  paging
          text
         -->P_0356   text
    *FORM paging USING    VALUE(P_0356).
    FORM paging USING code.
    DATA: i TYPE i,
    j TYPE i.
    CASE code.
    WHEN 'P--'.
    CONTROL_DATA-top_line = 1.
    WHEN 'P-'.
    CONTROL_DATA-top_line = CONTROL_DATA-top_line - line_count.
    IF CONTROL_DATA-top_line LE 0.
    CONTROL_DATA-top_line = 1.
    ENDIF.
    WHEN 'P+'.
    i = CONTROL_DATA-top_line + line_count.
    j = CONTROL_DATA-lines - line_count + 1.
    IF j LE 0. j = 1. ENDIF.
    IF i LE j.
    CONTROL_DATA-top_line = i.
    ELSE.
    CONTROL_DATA-top_line = j.
    ENDIF.
    WHEN 'P++'.
    CONTROL_DATA-top_line = CONTROL_DATA-lines - line_count + 1.
    IF CONTROL_DATA-top_line LE 0.
    CONTROL_DATA-top_line = 1.
    ENDIF.
    ENDCASE.
    ENDFORM. " PAGING
    *ENDFORM.                    " paging
    thanks,
    maheedhar.t

  • CASE function is not working

    Hi,
    I want to use the CASE function in a sql statement used at form level but it's not working. I can't compile the form. I am using developer 6i at font end and Oracle 10g database at back end. Is it possible to use case function at form level sql statement. If so then please help me about it.
    Best Regards

    Forms has it's own PL/SQL engine, and in Forms 6i it's version 8 where no CASE was available. So if you want to use CASE you'll have to use a view or put your logic in a stored procedure.

Maybe you are looking for

  • Excise Invoice output

    Hi Experts, If you could please lead me in this scenario. I have created an output type Z001 for which I have maintained VV31. In the Commercial Invoice it is rightly appearing with all the requirements. But when I am refferencing the same Invoice to

  • How do I delete my credit card information from my account?

    How do I delete my credit card information from my account?

  • Editable fields in Acrobat DC

    How do I create edible fields in Acrobat DC. I need contain font size, font and color. Please help

  • Problems with X-FI on central spea

    Hi. I'm italian and it's the first time I write on this forum. I have?problems with X-Fi Extreme Gamer Fatalty on Windows XP SP2. My central speaker doesn't work, only scratches. I have removed?X-Fi and reinstalled, but nothing is changed. I read on

  • InDesign Server serial number

    Hello!! I want to install a trial plugin to rotate pages, but the company that distributes it ask me for the serial number of our InDesign Server CS4. The problem is that I don´t remember it, so, does someone known how can I get it? I`ve been looking