Totals of calculated field w/ PL/SQL function

I have a worksheet with a numeric field that is calculated using
a registered PL/SQL function. When I add totals to the sheet, no
total appears for this column. Is this a known issue, or is
there something else going on?
Thanks,
Charles

I have the same problem. I used to work with Discoverer 4 and all the totals were there, but after the upgrade to 9.0.4 the totals for the calculated items that are based on stored procedures are gone. It has something to do with the procedures because the calculated items that do not call procedures do have the totals.
What is meant by the default setting of "Data point"? I cannot find anything like it in the administrator.....

Similar Messages

  • Running total of calculated field in pivot

    VERSION: ORACLE 11
    TABLE:
    create table chart_detail (
    DIS        NUMBER,
    BLD_MO VARCHAR2(7),
    BLD        NUMBER(10),
    RPLC      NUMBER(10));DATA:
    insert into chart_detail values (60,'2011-03',0,2);
    insert into chart_detail values (150,'2011-04',10572,0);
    insert into chart_detail values (120,'2011-04',26449,5);
    insert into chart_detail values (30,'2011-04',0,1);
    insert into chart_detail values (60,'2011-04',0,7);
    insert into chart_detail values (90,'2011-04',0,9);
    insert into chart_detail values (120,'2011-05',5714,0);
    insert into chart_detail values (90,'2011-05',24557,1);
    insert into chart_detail values (60,'2011-05',0,4);
    insert into chart_detail values (30,'2011-05',0,0);
    COMMIT;EXPECTED RESULTS:
         2011-04                    2011-05               
    DIS     RPLC     BLD     TBLD     IPTV     RPLC     BLD     TBLD     IPTV
    30     1     0     37021     0.03     0     0     30271     0.00
    60     7     0     37021     0.22     4     0     30271     0.13
    90     9     0     37021     0.46     1     24557     30271     0.17
    120     5     26449     37021     0.59     0     5714     5714     0.17
    150     0     10572     10572     0.59               0     
    180               0                    0     
    TOTAL     22     37021               5     30271          PROBLEM: I need to have a running total of IPTV like in the above example. I can get the IPTV for each DIS/bld_mo but I don't know how to get the running total of it. In the script below I just used an example where I tried summing the IPTV like was done for build. I know it can't be done that way because IPTV is a calculated field in the query but if I substitute "APR_IPTV" with the formula for IPTV I get an error that window functions aren't allowed here. I do not know a way around this. I commented out the bad piece of code.
    PROBLEM SCRIPT:
    WITH  pivot_results  AS
      SELECT    dis
      ,    NVL (apr11_rep,  0)  AS apr11_rep
      ,    NVL (apr11_bld,   0)  AS apr11_bld
      ,    NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS apr11_tbld
    ,      DECODE(NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(apr11_rep, 0)*1000/ NVL ( SUM (apr11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS apr11_iptv               
    ,      NVL ( SUM (apr11_iptv)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS apr11_tiptv  
      ,    NVL (may11_rep,  0)  AS may11_rep
      ,    NVL (may11_bld,   0)  AS may11_bld
      ,    NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0
                    )        AS may11_tbld
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_iptv
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_tiptv               
      FROM     chart_detail
      PIVOT     (  MAX (rplc)  AS rep
              ,  MAX (bld)  AS bld
              FOR  bld_mo   IN ( '2011-04'  AS apr11
                                             , '2011-05'  AS may11
    SELECT    CASE
            WHEN  GROUPING (dis) = 0
            THEN  TO_CHAR (dis)
            ELSE  'Total'
        END      AS dis
    ,    SUM (apr11_rep)  AS apr11_rep
    ,    SUM (apr11_bld)  AS apr11_bld
    ,    SUM (apr11_tbld) AS apr11_tbld
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (apr11_iptv)
        END      AS apr11_iptv
    ,    SUM (apr11_tiptv) AS apr11_tiptv
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (apr11_tpiptv)
        END      AS apr11_tiptv
    ,    SUM (may11_rep)  AS may11_rep
    ,    SUM (may11_bld)  AS may11_bld
    ,    SUM (may11_tbld) AS may11_tbld
    ,    CASE
            WHEN  GROUPING (dis) = 0
            THEN  SUM (may11_iptv)
        END      AS may11_iptv   
    FROM    pivot_results
    GROUP BY  ROLLUP (dis)
    ORDER BY  pivot_results.dis
    ;Thank you,

    Hi,
    So you know how to compute iptv for an individual row; the problem now is that you want to get a running total of iptv; is that it?
    The problem there is that computing iptv requires an analytic function, and analytic functions can't be nested. To get the results of nesting f (g (x)), where f and g are analytic funtions, you have to compute g in a sub-query, and then use the results as the argument to f in a super-query.
    Here's how to apply that to your situation:
    WITH  pivot_results  AS
         SELECT    dis
    -- April, 2011
           ,           NVL (apr11_rep,   0)  AS apr11_rep
           ,           NVL (apr11_bld,   0)  AS apr11_bld
           ,           NVL ( SUM (apr11_bld)
                                       OVER (ORDER BY dis DESC)
                          , 0
                          )               AS apr11_tbld
         ,      NVL ( 1000 * apr11_rep
                              / NULLIF ( SUM (apr11_bld) OVER (ORDER BY dis DESC)
                                          , 0
                   , 0
                   )               AS apr11_iptv
    -- May, 2011
           ,           NVL (may11_rep,   0)  AS may11_rep
           ,           NVL (may11_bld,   0)  AS may11_bld
           ,           NVL ( SUM (may11_bld)
                                       OVER (ORDER BY dis DESC)
                          , 0
                          )               AS may11_tbld
         ,      NVL ( 1000 * may11_rep
                              / NULLIF ( SUM (may11_bld) OVER (ORDER BY dis DESC)
                                          , 0
                   , 0
                   )               AS may11_iptv
           FROM     chart_detail
           PIVOT    (    MAX (rplc)  AS rep
                    ,    MAX (bld)   AS bld
                    FOR  bld_mo   IN ( '2011-04'  AS apr11
                                      , '2011-05'  AS may11
    SELECT    CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  TO_CHAR (dis)
                  ELSE  'Total'
               END      AS dis
    -- April 2011
    ,           SUM (apr11_rep)  AS apr11_rep
    ,           SUM (apr11_bld)  AS apr11_bld
    ,           SUM (apr11_tbld) AS apr11_tbld
    ,           CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  ROUND ( SUM (SUM (apr11_iptv))
                                          OVER (ORDER BY  dis)
                      , 2
               END      AS apr11_iptv
    -- May 2011
    ,           SUM (may11_rep)  AS may11_rep
    ,           SUM (may11_bld)  AS may11_bld
    ,           SUM (may11_tbld) AS may11_tbld
    ,           CASE
                  WHEN  GROUPING (dis) = 0
                  THEN  ROUND ( SUM (SUM (may11_iptv))
                                          OVER (ORDER BY  dis)
                      , 2
               END      AS may11_iptv
    FROM      pivot_results
    GROUP BY  ROLLUP (dis)
    ORDER BY  pivot_results.dis
    ;Output:
          APR11  APR11   APR11  APR11 MAY11  MAY11   MAY11  MAY11
    DIS    _REP   _BLD   _TBLD  _IPTV  _REP   _BLD   _TBLD  _IPTV
    30        1      0   37021    .03     0      0   30271    .00
    60        7      0   37021    .22     4      0   30271    .13
    90        9      0   37021    .46     1  24557   30271    .17
    120       5  26449   37021    .59     0   5714    5714    .17
    150       0  10572   10572    .59     0      0       0    .17
    Total    22  37021  158656            5  30271   96527As you can see, this is not quite what you wanted on the row where dis='150'. You asked for NULLS in the may11_rep, may11_bld and may11_iptv columns. You can get those results if you need them; just explain the rules that govern whether to display the values and when to display NULL.
    The way you posted the sample data and results, and the quantity of sample data were all excellent; it really helped me find a solution. Thanks.
    It would have also helped it you had explained how iptv is computed. Basically, iptv = 1000 * rep / tbld, right?
    It looks like most of this code:
    ,      DECODE(NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),0,0,ROUND(NVL(may11_rep, 0)*1000/ NVL ( SUM (may11_bld)
                      OVER (ORDER BY dis DESC)
                    ,                 0),2
                    ))        AS may11_iptvwas a way of avoiding divide by 0 errors; it would have been helpful if you had explained that.

  • Total of calculated fields

    In a page-detail table report, there are several numeric fields which must be totalled at the end of the report.
    Some of the fields are calculated ones, i.e. a dollar amount multiplied by a conversion rate.
    The total of the calculated fields are always blank whether I run the report in DESKTOP or I run the report in PLUS.
    Any suggestions?
    Thank you.
    Leah

    HI,
    Two things you should try:
    a) put a to_number(nvl(field,0)) on the calculation
    b) Try cell sum instead of regular sum.
    Hope it will help you solve the problem

  • Totalling a calculated field in end of report

    Hi I have a formula field (F087/F050) in the report Repetitive Area0 and I want to total the results of these line by line amounts in the 'End of Report'
    Please can someone explain how to compose the field I need in the End of Report
    Thanks
    Dom

    Hi Dom,
    You may use ColSum(FXXX) to get the total in the 'End of Report'.
    Thanks,
    Gordon

  • How to create a calculated field

    Hi. I'd like to know how to create a calculated field for a master- detail form. For example: having two db fields price and quantity, i created a the total item (price * quantity) as pl/sql function like this:
    begin
    :p13_item_total := :p13_price * :p13_quantity;
    end;
    However, the item is not calculated. It is not and instant calculation. I mean if i modify either price or quantity, how to recalculate item total immediately

    You must submit the page to do it with PL/SQL. If you do not want to submit the page, you must do it with JavaScript.
    Thanks,
    Tyler

  • New Calculated field question. Complicated I think.

    I have managed to create this table from a MySQL database: http://ppbm5.com/DB-PPBM5.php
    The field 'Total' is a calculated field using this SQL query:
    $query_Recordset1  = 'SELECT *, `Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE  Off`) As Total, `CPU`*`Cores` As Phys_Cores FROM `Personal_data` WHERE 1  ORDER BY (`Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE Off`)),  `Date & Time` ASC';
    So far, so good, but as you may have  noticed, there is a next field called 'Rel. Perf.' which only contains  blanks. And that is where my problems start.
    The table is sorted by 'Total' and the first record shows these figures and field names that are relevant for my question:
    Fields: 'Total'  'Disk I/O'  'MPEG2-DVD'   'H.264-BR'   'MPE On'   'MPE Off'
    Values:  131,        67,              21,                  37,              6,              64
    In addition, I use four 'weight' figures, let's say these are 0.27 , 0.30 ,  0.20 and 0.23 denoted as W1, W2, W3, W4.
    First step is to calculate four temp values, using a formula like this resulting in T1, T2, T3 and T4:
    T1 = W1 x  Total /Disk I/O; T2 =  W2 x Total/MPEG2-DVD ; T3 = W3 x Total/H.264-BR ; T4 = W4 x Total/(IFNULL(MPE On, MPE Off)
    Note that this only applies to the top record and here the SUM(T1, T2, T3, T4) results in 131, equal to the Total.
    The result of 100 x SUM(T1, T2, T3, T4)/ Total = 100 should be the 'Rel.Perf.' result for the top record.
    Now  is gets difficult. Let me call the records R1, R2, R3, ..., Rx. Now, in  the previous step we have established that the figure 100 should into  R1.
    For R2 the result of the 'Rel.Perf.' is 100 x SUM(T1 x Disk  I/O(2), T2 x MPEG2-DVD(2), T3 x (H.264-BR(2), T4 x (IFNULL(MPE on, MPE  Off)))/ Total(2)
    For R3 the result of the 'Rel.Perf.' is 100 x  SUM(T1 x Disk I/O(3), T2 x MPEG2-DVD(3), T3 x (H.264-BR(3), T4 x  (IFNULL(MPE on, MPE Off)))/ Total(3)
    etcetera for all the rest of the records in the table.
    A  complicating factor is that the reference point of the top machine  should remain fixed at 100, but when doing queries, the top machine may  not be in the query results, but all the query results for the Rel.Perf.  should be derived from these scores. Life would be infinitely easier if  one would be certain that the top machine is fixed, but that is not the  case.
    Sorry to make this such a long and complicated post, but  for those who have struggled through this long message, if you have any  suggestions on how to make this work, I would appreciate it.
    Thanks in advance.
    Harm, while non is intended.
    PS. I have been trying to generate a SQL query, using the following code:
    $query_Recordset1 = 'SELECT *, FORMAT(`Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE Off`),0) As Total, FORMAT((54.661*`Disk I/O`+161.25*`MPEG2-DVD`+71.66666*`H264-BR`+645*IFNULL(`MPE On`,`MPE Off`))/129,1) As RPI,`CPU`*`Cores` As Phys_Cores FROM `Personal_data` WHERE 1 ORDER BY 54.661*`Disk I/O`+161.25*`MPEG2-DVD`+71.66666*`H264-BR`+645*IFNULL(`MPE On`,`MPE Off`), `Disk I/O`+`MPEG2-DVD`+`H264-BR`+IFNULL(`MPE On`,`MPE Off`) ASC';
    For static work it is OK, but not when a new top performer submits his data.

    Hi William,
    Per my understanding that you want to count the number of the value in the field wait which is smaller then 15, right?
    I have tested on my local environment and that you can add the calculated field (Count) using the expression as below:
    =IIF(Fields!wait.Value<15,1,0)
    Insert an outside group row and then get the total count by using below expression:
    =SUM(Fields!Count.Value)
    Preview you will get the result like below:
    If your problem stil exists, please try to provide some sample data and the exprect count result you want.
    Any problem, please feel free to ask.
    Regards
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • Total Before Discount field.

    Hi, evrybody!
    Can you show me about what table store Total Before Discount field..in SQL tables
    Can you help me! Thank you.

    Hi,
    The total before discount is the sum of the line total which are stored in the lines table.
    For an example ,
    Sales Order,
    SELECT SUM(PriceBefDi),docentry FROM RDR1 WHERE DOCENTRY = "docentry value" group by docentry.
    Regards,
    Tom.

  • Using AGO function in calculated fields in Analysis

    Oracle BI 11g.
    Hi!
    I have time-hierarchy and try to use function Ago in calculated fields. I created Analysis and add columns Year, Revenue, Revenue (1 year ago). In formula of column "Revenue (1 year ago)" I wrote:
    AGO("Sales"."Revenue", "H Calendar"."Year", 1)
    "H Calendar"."Year" - is level in my time Hierarchy "H Calendar".
    But when I clicked [OK], I got error: [nQSError: 27037] Unresolved level: "H Calendar"."Year".(HY000)
    What I do wrong?

    Hi,
    I think it's a bug, try this.
    If Analysis you have a time folder with this object dimension:
    Time Hierarchy
    Total Time
    Year
    Quarter
    Month
    Week
    Day
    And a measures 1- Revenue try to calculate the criteria like this (write in the level the formula "Time"."Time Hierarchy".Year)
    For example:
    AGO("Base Facts"."1- Revenue", "Time"."Time Hierarchy".Year,1)
    If you have the sample sales of the 11g installed try this on A - Sample Sales
    SELECT s_0, s_1, s_2 FROM (
    SELECT
    0 s_0,
    "A - Sample Sales"."Time"."T05 Per Name Year" s_1,
    AGO("A - Sample Sales"."Base Facts"."1- Revenue","Time"."Time Hierarchy"."Year",1) s_2
    FROM "A - Sample Sales"
    ) djm ORDER BY 1, 2 ASC NULLS LAST
    For me it works.
    Regards,
    Gianluca

  • Populating text field with pl/sql expression or function

    Hi all,
    I have a function which return an object.
    create or replace type emp2_oty is object (server_name varchar2(20),
    status varchar2(4),
    refresh_on date,
    dw_refresh date)
    create or replace type emp2_nt is table of emp2_oty
    create or replace function testserver12 return emp2_nt
    is
    v_emp2_nt emp2_nt:=emp2_nt();
    a number;
    b number;
    c number;
    begin
    for r_emp in (select * from testing)
    loop
    a := extract(DAY FROM r_emp.dw_refresh);
    c := extract(DAY FROM r_emp.refresh_on);
    b := extract(DAY FROM SYSDATE);
    if (a != b) or (c != b) or (r_emp.status != 'on') then
    v_emp2_nt.extend; v_emp2_nt(v_emp2_nt.last):=emp2_oty(r_emp.server_name,r_emp.status,r_emp.refresh_on,r_emp.dw_refresh);
    end if;
    end loop;
    return v_emp2_nt;
    end testserver12;
    The pl/sql code to get the return value displayed. It works very fine in sqlworkshop.
    declare
    v_temp_nt emp2_nt;
    i number := 1;
    begin
    v_temp_nt:= testserver12();
    for i in (v_temp_nt.first)..(v_temp_nt.last) loop
    dbms_output.put_line(v_temp_nt(i).server_name||' '||v_temp_nt(i).status||' '||v_temp_nt(i).refresh_on ||' '||v_temp_nt(i).dw_refresh);
    end loop;
    end;
    I want it to get display the output into the text field.
    Please could any one help me to achieve this.
    Thanks in advance
    bye
    Srikavi

    Pretty easy, add a CHR(10) (ASCII for carriage return) in the string concatenation.
    e.g.
       l_result:= l_result || (v_temp_nt(i).server_name || ' ' ||
                     v_temp_nt(i).status || ' ' ||
                     v_temp_nt(i).refresh_on ||' ' ||
                     v_temp_nt(i).dw_refresh) || CHR(10);Also why over complicate the whole process by using objects and types by simplifying the code and also improving readability and maintenance by replacing the PL/SQL function body with something similar to (the conditions have been negated and may have not been what you meant in the first place)
    DECLARE
       v_text_return VARCHAR2(2000);
       l_cur CURSOR IS
          SELECT t.server_name,
                 t.status,
                 t.refresh_on,
                 t.dw_refresh
          FROM   testing t
          WHERE  To_Char(t.refresh_on, 'DD') = To_Char(SYSDATE, 'DD')
          AND    To_Char(t.dw_refresh, 'DD') = To_Char(SYSDATE, 'DD')
          AND    Upper(t.status) = 'ON');
    BEGIN
       FOR r_emp in l_cur
       LOOP
          v_text_return := v_text_return || r_emp.server_name || ' ' ||
                             r_emp.status || ' ' ||
                             r_emp.refresh_on || ' ' ||
                             r_emp.dw_refresh || CHR(10);
       END LOOP;
       RETURN v_text_return;
    END;Hope this helps

  • PL/SQL Function to convert fields & set max length

    I am having a problem with the following assignment:
    Write a stored PL-SQL function called namefct that will convert two varchar2 fields (first and last names) into the format: lastname, firstname with a maximum length of 10 chars. If the combined size of the two names is greater than 10 characters, you will issue an error message indicating the name has been shortened to 10 characters and return only the first ten characters, otherwise return the entire name. Test the namefct function by using the staff table created in Part 1 (above). Turn in: the SQL statements to build the function, execute the sample code and the resulting output.
    This is the start of my attempt, excluding the error message that is to be issued:
    CREATE OR REPLACE FUNCTION namefct (fname VARCHAR2, lname VARCHAR2) IS
    BEGIN
    column "full name" format a10;
    SELECT namefct(fname, lname) as "full name" from staff;
    END namefct
    Any advice or assistance would be greatly appreciated, since my Professor seems unwilling to assist me. Thanks!

    Write a stored PL-SQL function called namefct that
    will convert two varchar2 fields (first and last
    names) into the format: lastname, firstname with a
    maximum length of 10 chars. If the combined size of
    the two names is greater than 10 characters, you will
    issue an error message indicating the name has been
    shortened to 10 characters and return only the first
    ten characters, otherwise return the entire name.
    Test the namefct function by using the staff table
    created in Part 1 (above). Turn in: the SQL
    statements to build the function, execute the sample
    code and the resulting output.Firstly you need to consider what you have already been taught as you need to ensure that you code your function according to the purpose of the assignment. i.e. are you supposed to be demonstrating the use of returning values in a function or are you supposed to be demonstrating the use of exception handling etc.
    The main tricky bit with this assignment is the requirement to show an error message and still return a value. If you were to just raise an exception with the error message (e.g. raise application error) then you won't be able to actually return a value. Because it's a function and not a procedure that has been specified you aren't returning the value in an OUT parameter which would have made passing the value back and raising an exception easier.
    So, the only real way to have a function and allow it to show an error message would be something like...
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE OR REPLACE FUNCTION f_name(p_forename IN VARCHAR2, p_surname IN VARCHAR2) RETURN VARCHAR2 IS
      2    name_too_long EXCEPTION;
      3  BEGIN
      4    IF LENGTH(p_surname||', '||p_forename) > 10 THEN
      5      RAISE name_too_long;
      6    END IF;
      7    RETURN p_surname||', '||p_forename;
      8  EXCEPTION
      9    WHEN name_too_long THEN
    10      DBMS_OUTPUT.PUT_LINE('Name Too Long. Truncating to 10 chrs.');
    11      RETURN SUBSTR(p_surname||', '||p_forename, 1, 10);
    12* END;
    SQL> /
    Function created.
    SQL> select f_name('FRED','SIMS') from dual;
    F_NAME('FRED','SIMS')
    SIMS, FRED
    SQL> select f_name('FRED','SIMKINSON') from dual;
    F_NAME('FRED','SIMKINSON')
    SIMKINSON,
    Name Too Long. Truncating to 10 chrs.
    SQL>Note: Tutors/Professors are very wise to checking your work on the internet to make sure it hasn't been copied, so I would suggest you don't just copy this verbatim, but actually read it and understand how it's working and write your own version, taking account of what you have been taught so far and not using things you haven't been taught.
    ;)

  • PL/SQL Function source of text field

    I have the following code as a PL/SQL function body as the source of a text item. There is a group_options table that specifies if the user group selected has fixed pricing or
    can key in a price. For the fixed price groups, I was wanting to have the text field auto-populate and for the nonfixed price groups, I just wanted an empty text field for them to key in the price. The check boxes on the page for purchasing an item or leasing an item determine which table the pricing comes from. I don't get an error message, but there is something APEX doesn't like about the code below because I get the 'page cannot be found' message. Do you see a problem with the code below? Last week, it would not work and then mysteriously started to work. Today, it started out not working, so there has to be something flakey about it.
    Thank you in advance.
    Kelly
    DECLARE
    vfixed NUMBER;
    vpurprice NUMBER;
    vleasprice NUMBER;
    BEGIN
    SELECT FIXED_PRICE INTO vfixed FROM UPSL_DEV.GROUP_OPTIONS WHERE USER_GROUP =
    :P7_GROUP ;
    IF vfixed = 1 and :P9_PURCHASE = 1 THEN
    SELECT PURCHASE_PRICE INTO vpurprice FROM UPSL_DEV.PRICE_GRID g WHERE g.user_GROUP = :P7_GROUP and g.equip_code =:P9_ITEMCODE ;
    return vpurprice;
    ELSIF vfixed = 0 and :P9_PURCHASE = 1 THEN
    return NULL;
    END if;
    IF vfixed = 1 and :P9_LEASE = 1 THEN
    SELECT MIN into vleasprice from UPSL_DEV.PRICE_GRID_LEASE l WHERE l.equip_code = :P9_ITEMCODE AND l.user_group = :P7_GROUP and l.term = :P9_LEASETERM;
    RETURN vleasprice;
    ELSIF vfixed = 0 and :P9_LEASE = 1 then
    RETURN NULL;
    END if;
    END;

    Put a "return null;" statement at the end of the block to allow for your logic not covering all cases. It may presently be getting a "function returned without value" error that is inconveniently suppressed in the page output.
    Just a guess.
    Scott

  • Calculated Field to get Total Number of Records does not work

    Hi,
    For some reason, calculated fields aren't working in my business rule.
    What I did:
    In deficiency criteria, I added the calculated field "Total Val".
    In conditions and calculations I chose "Grouping/Aggregation".
    For Select Group Fields, I chose "Plant and Material Number".
    For Aggregation Method, I chose "Count".
    Result when "Apply Rule" is used:
    The filtered records are still shown. The "Field Names" (names within the table such as MATNR instead of material number) are shown instead of the field labels.
    I'm trying to determine the cause of this issue and how to resolve it. Does anyone have a suggestion of what it is and what can be done?

    Hi Arif,
    Thank you for the response.
    Is there a way we can further pin down the ABAP problem that is being experienced?
    Best Regards, 
    Raphael

  • SQL Function for calculating IP Address

    Hi Experts ,
    I have an IP Range i need to find out the First Host detail for the IP using a SQL scalar function .
    Example : 11.30.10.40
    Subnet Mask is 26
    Output required
    First host: 11.30.10.1
    am confused how i can derive the first host  values from a sql function kindly help .
    Thanks
    Priya

    DECLARE @Mask TINYINT = 26;
    DECLARE @AddressIP VARCHAR(15)= '11.30.10.40';
    DECLARE @AddressValue BIGINT = PARSENAME(@AddressIP,4)*CAST(256*256*256 AS BIGINT)+PARSENAME(@AddressIP,3)*256*256+PARSENAME(@AddressIP,2)*256+PARSENAME(@AddressIP,1);
    WITH
    n0(n) AS (SELECT 0 UNION ALL SELECT 0)
    ,n1(n) AS (SELECT 0 FROM n0 a CROSS JOIN n0)
    ,n2(n) AS (SELECT 0 FROM n1 a CROSS JOIN n1)
    ,n3(n) AS (SELECT 0 FROM n2 a UNION ALL SELECT 0 g FROM n2)
    ,t (n) AS (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM n3)
    ,bits(b,v) AS (SELECT n,POWER(CAST(2 AS BIGINT),32-n) FROM t)
    SELECT @AddressIP [Address]
    ,CAST((SUM(v) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST((SUM(v) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST((SUM(v) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(SUM(v) % 256 AS VARCHAR(3)) [Netmask]
    ,CAST(((SUM(v) ^ 0xFFFFFFFF) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((SUM(v) ^ 0xFFFFFFFF) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((SUM(v) ^ 0xFFFFFFFF) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((SUM(v) ^ 0xFFFFFFFF)) % 256 AS VARCHAR(3)) [Wildcard]
    ,CAST(((@AddressValue & SUM(v)) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v)) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v)) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v))) % 256 AS VARCHAR(3)) + '/' + CAST(MAX(b) AS VARCHAR(2)) [NetworkAddress]
    ,CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue)) % 256 AS VARCHAR(3)) [BroadcastAddress]
    ,CAST(((@AddressValue & SUM(v)) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v)) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v)) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((@AddressValue & SUM(v))) % 256 + 1 AS VARCHAR(3)) [FirstHost]
    ,CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256 / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256 / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) / 256) % 256 AS VARCHAR(3)) + '.' + CAST(((((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue)) % 256 - 1 AS VARCHAR(3)) [LastHost]
    ,(((SUM(v) ^ 0xFFFFFFFF)) | @AddressValue) - (@AddressValue & SUM(v)) - 1 [TotalHostCount]
    FROM bits WHERE @Mask BETWEEN 1 AND 32 AND b <= @Mask
    Jon

  • Subtotal issue when subtotaling on a calc field built using CASE function

    Okay, I hpe I can explain this well. May be possible that this is something cannot handle in Discoverer. I am using Discoverer Plus to develop a new workbook - cross project expenditure inquiry. A requirement is to not allow a worksheet user to see labor cost (since possible to figure out someone's salary) amount unless they are allowed to view labor cost. I have a function that returns a Y/N value that tells me if they can view labor cost. That works out just fine. So what I am doing is taking my database cost column (which is defined as Number(22,5) in the Oracle table. I create a new calculated column, basically like this -
    CASE WHEN expenditure type <> LABOR THEN cost WHEN view labor cost = 'Y' THEN cost ELSE NULL END.
    That calculated column is working just fine. I am seeing my desired results in that column. Okay so far.
    Next, the users want subtotals by project organization and project. So I created a new total. When I did that, my subtotal row amount is blank.
    Okay, I have seen this happen with NULLS before. Like in the gl_je_lines tables, where the accounted_Dr and accounted_Cr may be null, and have to do a NVL function to convert the null to 0 and allow me to subtotal on the column in a Discoverer workbook.
    So I tried creating a second calculation -
    NVL(Cost,0)
    So I return the cost if not null, otherwise I return 0. Second calc column results look okay.
    Now I did a subtotal on the second calculation. Oops. Wrong result. Amount is shown as 0.
    For grins, I went back to my CASE statement on my first calculation and changed the ELSE condtion from NULL to 0. When I did that, the subtotal on that column changes from a blank (Null) value to a 0 value. Well, better, but still just like my second calculation subtotal.
    Obviously the users have the option to export to Excel and subtotal in Excel.
    Does anyone know of a way to get a good subtotal in this kind of situation, where I am attempting to subtotal on a calculated field that is built on a CASE function? Or am I out of luck when it comes to Discoverer?
    John Dickey

    Okay, I did find a workaround, though I do not understand why the workaround works, but why the way I first tried to get a subtotal did not work. What I did is that I had to go to Discoverer Administrator. I picked my folder and did an Insert/Item. I created my new item building the same CASE statement that I used in my worksheet to create a new calculation. I then closed Discoverer Plus and reopened Discoverer Plus. Opened my worksheet. Edited the worksheet and brought in my new (derived) item from my folder. Then I created my subtotals for this secured cost amount. Voila. I get a number now, and the subtotal amount appears to be correct (still testing/verifying, but looks okay so far). So I deleted my subtotals on my calculated column and then deleted the calculation, to get that stuff out of the report. Sure would be nice if there was documentation in the Discoverer manuals about this.
    John Dickey

  • Issue with running PL/SQL function returning Sql query

    hi, I am trying to create a report region by using the option of PL/SQL function returning sql query.
    I notice that it's very slow for the report region page to show up. In my PL/SQL function body, there are only 3 steps, first update all the 10 rows of varchar2 fields to null,then insert values to those fields, then select all from the table to show report results. It takes more than 5 minitues for the page to load up, how ever, if i run those steps in SQL*Plus, it only takes a couple of seconds to finish. Any suggestions?
    Thanks,
    gina

    Sergio, the codes are as followed,
    Declare
    q varchar2(32767); -- query
    Begin
    q := 'select "ID",'||
    '"ENTRY NAME","TOTAL","#CM","%CM","#CA",'||
    '"%CA", from Info_table';
    update info_table
    set "TOTAL" = '',
    "#CM" = '',
    "%CM" = '',
    "#CA" ='',
    "%CA"=''
    where "ID"<=10;
    // set all data in column Total to null,there is only 10 rows in the table
    update info_Table set Total = vTotal,
    "#CM" = vCM
    (those variables hold user key-in Text filed value)
    where ID = 1;
    return q;
    End;

Maybe you are looking for

  • Creating GUI based Help File!!!

    Can anyone point me to a resource where I can find information for creating Help for a GUI based application? I know that javadoc can create API specification for standalone programs but I like something for GUI based application like the one found o

  • Object Level Security in Oracle 10g

    Hi gurus Question regarding object level priviliges 1.Created a schema "TEST" and assigned following privileges GRANT CREATE SESSION TO TEST; GRANT CREATE ANY TABLE TO TEST; 2. created a table "Emp" Able to alter the table without assigning ALTER ANY

  • Container Object - type Abstrace Interface

    Hi everyone, When I try to create a container Object in BPM of category Abs. Interface, for the type, it gets the Async Abs Interfaces only from the IR but not Sync Abs Interfaces. Is there any reason for this. It is on sync send step. -Naveen.

  • "Mostly Dead" iMac

    My early  2010 27" iMac froze while playing video in Netflix and now will not start. I get a start up tone and the grey screen with logo, then it goes to a blue screen and then it goes to a grey pixelated screen.  i was able to open in safe mode a co

  • How to get internet on the go for iPad 2, is it possible? Thanks for ur help in advance...

    How to get internet on the go for iPad 2, is it possible? Thanks for ur help in advance...