ORA-00934

I have following part of SQL in my procedure:
select trunc(my_Date) into cancel_date,
sum(Decode(last_retry,'1',1,0)) as 1,
sum(Decode(last_retry,'2',1,0)) as 2
from retry_state@fdb a
where a.cust_id=a.cust_id
group by trunc(my_Date);
I get following error:
PL/SQL: ORA-00934: group function is not allowed here
Can anybody tell how to solve this problem?

Hi Kitty,<br>
<br>
Do you use PL/SQL ? You should said me earlier Transposing rows and ORA group by error;-)<br>
Well, your select statement return three columns, so you need three variables :<br>
select trunc(my_Date),
      sum(Decode(last_retry,'1',1,0)) as 1,
      sum(Decode(last_retry,'2',1,0)) as 2
into cancel_date, MyVar1, MyVar2
from    retry_state@fdb a
where   a.cust_id=a.cust_id
group by trunc(my_Date);<br>
<br>
HTH,<br>
<br>
Nicolas.<br>
<br>
Message was edited by: <br>
N. Gasparotto

Similar Messages

  • CASE statement used in Oracle 10g -ORA-00934 Error

    I am getting ORA-00934 group function not allowed. What am I doing wrong here.
    Please advice.
    select count( case WHEN TRUNC(so_due_Date) = sysdate
    AND ne_state = 'GA'
    AND ((so_type LIKE '%CHANGE%') OR (so_type LIKE '%NEW%')) THEN 1
    end)INTO v_due_today,
    count( case WHERE TRUNC(so_due_Date) = sysdate + 1
    AND ne_state = 'GA'
    AND ((so_type LIKE '%CHANGE%') OR (so_type LIKE '%NEW%')) THEN 1
    end)INTO v_due_tomorrow
    FROM tbl_cif_current ;
    Thanks,
    jaya.

    are you using this in pl/sql block or at SQl
    there two things.
    you are missing
    1 missing )<--- closing para for the count.
    2. if rou are using pl/sql block then INTO clause goes after all the column,
    SELECT COUNT( CASE WHEN TRUNC(so_due_Date) = SYSDATE AND ne_state = 'GA' AND ((so_type LIKE '%CHANGE%') OR (so_type LIKE '%NEW%')) THEN 1
                 END)),
    COUNT( CASE WHERE TRUNC(so_due_Date) = SYSDATE + 1 AND ne_state = 'GA' AND ((so_type LIKE '%CHANGE%') OR (so_type LIKE '%NEW%')) THEN 1
    END))
    FROM tbl_cif_current ;
    or in pl/sql
    SELECT COUNT( CASE WHEN TRUNC(so_due_Date) = SYSDATE AND ne_state = 'GA' AND ((so_type LIKE '%CHANGE%') OR (so_type LIKE '%NEW%')) THEN 1
                 END)),
    COUNT( CASE WHERE TRUNC(so_due_Date) = SYSDATE + 1 AND ne_state = 'GA' AND ((so_type LIKE '%CHANGE%') OR (so_type LIKE '%NEW%')) THEN 1
    END))
      INTO v_due_tomorrow,v_due_today
    FROM tbl_cif_current ;typo correction
    Message was edited by:
    devmiral

  • ORA-00934: group function is not allowed here

    Hi,
    My requirement is to check oi.quantity is equal to sum of packing_detail. quantity
    by order_number
    select oi.quantity_ordered oi_qu, pd.quantity pq
    from ordered_items oi, packing_details pd
    where oi.ordered_item_id = pd.ordered_item_id
    and oi.quantity_ordered = sum(pd.quantity)
    and oi.order_number = '29';
    after executing above query I get error
    SQL Error: ORA-00934: group function is not allowed here
    00934. 00000 - "group function is not allowed here"
    Please tell me how to resolve it.
    Thanks in advance
    Sandy

    You have to make use of a subquery;
    select oi.quantity_ordered oi_qu, pd.quantity pq
    from ordered_items oi, packing_details pd 
    where oi.ordered_item_id = pd.ordered_item_id 
    and oi.quantity_ordered = *(select sum(pd.quantity) from packing_details pd1 group by pd1.ordered_item_id)* 
    and oi.order_number = '29';  This is based on the assumption that ordered_items is the summarize data and packing_details are the line item level data.
    regards,
    Dipankar.

  • PL/SQL: ORA-00934: group function is not allowed here

    Hi,
    I am writing a PL/SQL procedure. The structure is like :
    SET SERVEROUTPUT ON;
    CREATE OR REPLACE Procedure abc
    IS
    v_total_ip_rec number(14);
    v_total_op_rec number(14);
    v_total_rec number(14);
    BEGIN
    SELECT SUM (CASE
    WHEN <condition 1>
    THEN 1
    ELSE 0
    END
    ) into v_total_ip_rec,
    SUM (CASE
    WHEN <condition 2>
    THEN 1
    ELSE 0
    END
    ) into v_total_op_rec,
    SUM (1) into v_total_rec
    FROM A,B
    WHERE A.Col1=B.Col1;
    EXCEPTION
    WHEN OTHERS THEN
    raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
    END;
    When I run this procedure it gives me following error:
    "PL/SQL: ORA-00934: group function is not allowed here"
    Anybody have any idea?
    Any help would be appreciated.
    Thanks.

    Hi Arunkumar ,
    I think you don't need subquery.
    Regards Salim.
    Or.
    SELECT COUNT (CASE
                     WHEN <condition 1>
                        THEN 1
                  END) v_total_ip_rec,
           COUNT (CASE
                     WHEN <condition 2>
                        THEN 1
                  END) v_total_op_rec,
           COUNT (1) v_total_rec
      FROM a, b
    WHERE a.col1 = b.col1

  • ORA-00934: group function is not allowed here Error - On validation screen

    Can anyone help me with this funtion Returning boolean PL/SQL expression
    begin
    select max(sim_trip.finish_time) into finish_time,
          max(sim_trip.start_time) into start_time  from sim_trip
    WHERE ((sim_trip.operator_counter = :P500_operator_counter));
    if (:P500_start_time > finish_time)
       then   return true;
    else
    return false;
    end if;
    end;

    Lucy,
    begin
    select max(sim_trip.finish_time) into finish_time,
          max(sim_trip.start_time) into start_time  from sim_trip
    WHERE ((sim_trip.operator_counter = :P500_operator_counter));
    if (:P500_start_time > finish_time)
       then   return true;
    else
    return false;
    end if;
    end;Your select statement is wrong. It should be:
    begin
    select max(sim_trip.finish_time),max(sim_trip.start_time)
      into :P500_start_time,:P500_finsh_time 
      from sim_trip
      WHERE ((sim_trip.operator_counter = :P500_operator_counter));
    if (:P500_start_time > :P500_finish_time)
       then   return true;
    else
    return false;
    end if;
    end;Robert
    http://apexjscss.blogspot.com

  • Min and MAx Value in a SELECT Statement

    Hi,
    I have a scenario where I am Selecting the values BETWEEN MIN and MAX values:
    SELECT * FROM ABC WHERE CODE BETWEEN MIN(CODE) AND MAX(CODE)
    ITS GETTING Error as:ORA-00934: group function is not allowed here
    Any help will be needful for me.

    select substr(no,1,3)||to_char(substr(no,4,1)+1) "first missing number"
    from
    with t as
    (select 'ABC1' no from dual
    union select 'ABC2' from dual
    union select 'ABC3' from dual
    union select 'ABC5' from dual
    union select 'ABC6' from dual
    union select 'ABC8' from dual
    select no, lead(no,1,0) over (order by no) next_no from t
    where substr(next_no,4,1) - substr(no,4,1) > 1
    and rownum = 1;

  • How to get the number of rows written to the header of the spool file.

    Hi
    I need to create a header line for the spool file .
    the header line should include fixed length values .
    The header should include the number of records found in the table with a maximum begin date (begin_date is the column of the table)
    To get the header in the spool file , i wrote a select query has :-
    --SPOOL 'C:\Documents and Settings\abc\Desktop\output.TXT'
    select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000') ||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) ||
    rpad(' ',76,' ')
    from dad.school
    group by sysdate;
    SPOOL OFF
    which gets me all the rows in the table , but i only want the rows with the latest school_begin_date .
    how can i achieve that ...
    I know that a subquery should be written in the from clause to get the number of rows found with a maximum school_begin_date.
    select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000') ||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) ||
    rpad(' ',76,' ')
    from dad.school where
    select rownum from dad.school
    where school_begin_date = max(school_begin_date) ;
    the error i get is
    ORA-00934: group function is not allowed here
    I NEED HELP ..IN GETTING THE ROWNUM JUST FOR THE LATEST BEGIN_DATE ?
    PLS HELP ME IN WRITING THE QUERY .
    THANKS IN ADVANCE .

    Try this:
    select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000')||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) || rpad(' ',76,' ')
      from dad.school
    where school_begin_date = (select max(school_begin_date)
                                  from dad.school);

  • Sum function in Where clause

    I am trying to return all rows with a 0 value for sum(a.posted_total_amt)
    I've tried the following:
    This returns no rows. However, I know there is data which should be returned.
    SELECT A.BUSINESS_UNIT, A.ACCOUNT, sum(A.POSTED_TOTAL_AMT)
    FROM PS_LEDGER A
    WHERE A.FISCAL_YEAR = 2006
    AND EXISTS (SELECT 'X' FROM PSTREESELECT05 A3_1 WHERE A3_1.SELECTOR_NUM=239846 AND A.BUSINESS_UNIT=A3_1.RANGE_FROM_05)
    AND A.ACCOUNTING_PERIOD IN (0,1,2,3,998)
    AND EXISTS (SELECT 'X' FROM PSTREESELECT10 A3_3 WHERE A3_3.SELECTOR_NUM=239847 AND A.ACCOUNT>= A3_3.RANGE_FROM_10 AND A.ACCOUNT <= A3_3.RANGE_TO_10)
    AND A.STATISTICS_CODE = ' '
    AND A.ACCOUNT NOT IN ('1401','1402','1403')
    group by A.BUSINESS_UNIT, A.ACCOUNT
    having sum(A.POSTED_TOTAL_AMT) = 0
    The following error is returned by the statement below
    ERROR at line 10:
    ORA-00934: group function is not allowed here
    SELECT A.BUSINESS_UNIT, A.ACCOUNT, sum(A.POSTED_TOTAL_AMT)
    FROM PS_LEDGER A
    WHERE A.FISCAL_YEAR = 2006
    AND EXISTS (SELECT 'X' FROM PSTREESELECT05 A3_1 WHERE A3_1.SELECTOR_NUM=239846 AND A.BUSINESS_UNIT=A3_1.RANGE_FROM_05)
    AND A.ACCOUNTING_PERIOD IN (0,1,2,3,998)
    AND EXISTS (SELECT 'X' FROM PSTREESELECT10 A3_3 WHERE A3_3.SELECTOR_NUM=239847 AND A.ACCOUNT>= A3_3.RANGE_FROM_10 AND A.ACCOUNT <= A3_3.RANGE_TO_10)
    AND A.STATISTICS_CODE = ' '
    AND A.ACCOUNT NOT IN ('1401','1402','1403')
    and sum(A.POSTED_TOTAL_AMT) = 0
    group by A.BUSINESS_UNIT, A.ACCOUNT
    Any guidance would be much appreciated

    try to use NVL() or IS NULL
    SELECT A.BUSINESS_UNIT, A.ACCOUNT, sum(A.POSTED_TOTAL_AMT)
      FROM PS_LEDGER A
    WHERE A.FISCAL_YEAR = 2006
       AND EXISTS (SELECT 'X' FROM PSTREESELECT05 A3_1
                    WHERE A3_1.SELECTOR_NUM=239846 AND A.BUSINESS_UNIT=A3_1.RANGE_FROM_05)
       AND A.ACCOUNTING_PERIOD IN (0,1,2,3,998)
       AND EXISTS (SELECT 'X' FROM PSTREESELECT10 A3_3
                    WHERE A3_3.SELECTOR_NUM=239847 AND A.ACCOUNT>= A3_3.RANGE_FROM_10 AND A.ACCOUNT <= A3_3.RANGE_TO_10)
       AND Nvl(A.STATISTICS_CODE,'x') = 'x'
       AND A.ACCOUNT NOT IN ('1401','1402','1403')
    group by A.BUSINESS_UNIT, A.ACCOUNT
    having sum(A.POSTED_TOTAL_AMT) = 0
    or
    SELECT A.BUSINESS_UNIT, A.ACCOUNT, sum(A.POSTED_TOTAL_AMT)
      FROM PS_LEDGER A
    WHERE A.FISCAL_YEAR = 2006
       AND EXISTS (SELECT 'X' FROM PSTREESELECT05 A3_1
                    WHERE A3_1.SELECTOR_NUM=239846 AND A.BUSINESS_UNIT=A3_1.RANGE_FROM_05)
       AND A.ACCOUNTING_PERIOD IN (0,1,2,3,998)
       AND EXISTS (SELECT 'X' FROM PSTREESELECT10 A3_3
                    WHERE A3_3.SELECTOR_NUM=239847 AND A.ACCOUNT>= A3_3.RANGE_FROM_10 AND A.ACCOUNT <= A3_3.RANGE_TO_10)
       AND A.STATISTICS_CODE Is Null
       AND A.ACCOUNT NOT IN ('1401','1402','1403')
    group by A.BUSINESS_UNIT, A.ACCOUNT
    having sum(A.POSTED_TOTAL_AMT) = 0

  • PL/SQL equivalent of T-SQL - "group function is not allowed here"

    Hi all, hope someone can give me a hand as I'm pretty stuck! I have been trying to convert some MS SQL Server T-SQL statements into Oracle PL/SQL and am stuck on the below one:
    SELECT
    CA.AssessmentID,
    (SELECT ProductName + ISNULL(' - ' + PrincipalBenefit,'')
    FROM rptPolicySnapshot WHERE PolicyID = MAX(CA.PolicyID)
    AND SnapshotID = 1),
    MAX(CA.PolicyID)
    FROM rptClaimInvoiceLineSnapshot CIL
    INNER JOIN rptClaimAssessmentSnapshot CA
    ON CIL.AssessmentID = CA.AssessmentID
    AND CIL.SnapshotID = CA.SnapshotID
    WHERE CIL.SnapshotID = 1
    GROUP BY CA.AssessmentID
    This works fine in MSSQL but returns the below error in Oracle:
    'ORA-00934: group function is not allowed here'
    If I take out the subquery the query works fine.
    Any ideas as to the syntax? I am new to Oracle so not sure as to how I should go about writing this.
    Thanks in advance!
    Leo

    WITH x AS (SELECT   ca.assessmentid,
                        MAX (ca.policyid) policy_id
               FROM rptclaiminvoicelinesnapshot cil
                    INNER JOIN rptclaimassessmentsnapshot ca
                        ON cil.assessmentid = ca.assessmentid
                       AND cil.snapshotid = ca.snapshotid
               WHERE cil.snapshotid = 1
               GROUP BY ca.assessmentid
    SELECT x.assessment_id,
           x.policy_id,
           productname + decode(principalbenefit,null,null,' - ' || principalbenefit ) prodname
    FROM   rptpolicysnapshot, x
    WHERE  policyid = x.policy_id
    AND    snapshotid = 1I think that's in the neighbourhood.

  • Error when trying to use SUM with COUNT

    I have the following query which works fine. However, I need to add another column that is the SUM of the firs column ("OPEN"). I have also included that query but I cannot get it to work. Any help would be appreciated.
    SELECT
    TO_CHAR(TRUNC(R.RAD_SUBMIT_DATE, 'MM'), 'yyyy-mm') as THISDATE,
    COUNT(decode(A.STATE_DESC, 'Approved', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Concept', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'New', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Pending', A.STATE_DESC))
    ) as OPEN,
    COUNT(decode(A.STATE_DESC, 'Approved', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Concept', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'New', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Pending', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Completed', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Rejected', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Rescinded', A.STATE_DESC))
    ) as TOTAL
    FROM RAW_APP_DATA R, APP_STATE A
    WHERE R.RAD_STATUS = A.STATE_ID
    AND (R.RAD_SUBMIT_DATE BETWEEN '01-AUG-02' AND '31-JAN-04')
    GROUP BY TO_CHAR(TRUNC(R.RAD_SUBMIT_DATE, 'MM'), 'yyyy-mm')
    ORDER BY TO_CHAR(TRUNC(R.RAD_SUBMIT_DATE, 'MM'), 'yyyy-mm')
    (RESULTS)
    THISDAT OPEN TOTAL
    2002-08 1 37
    2002-09 0 40
    2002-10 0 33
    2002-11 1 25
    2002-12 2 22
    2003-01 3 25
    2003-02 4 101
    2003-03 5 99
    2003-04 5 85
    2003-05 3 69
    2003-06 17 90
    2003-07 6 57
    2003-08 26 89
    2003-09 43 117
    2003-10 59 110
    2003-11 47 67
    2003-12 75 80
    2004-01 9 9
    18 rows selected.
    SECOND QUERY (DOES NOT WORK)
    SELECT
    TO_CHAR(TRUNC(R.RAD_SUBMIT_DATE, 'MM'), 'yyyy-mm') as THISDATE,
    COUNT(decode(A.STATE_DESC, 'Approved', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Concept', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'New', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Pending', A.STATE_DESC))
    ) as OPEN,
    COUNT(decode(A.STATE_DESC, 'Approved', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Concept', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'New', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Pending', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Completed', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Rejected', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Rescinded', A.STATE_DESC))
    ) as TOTAL,
    SUM(
    COUNT(decode(A.STATE_DESC, 'Approved', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Concept', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'New', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Pending', A.STATE_DESC))
    )) as "OPEN TOTAL"
    FROM RAW_APP_DATA R, APP_STATE A
    WHERE R.RAD_STATUS = A.STATE_ID
    AND (R.RAD_SUBMIT_DATE BETWEEN '01-AUG-02' AND '31-JAN-04')
    GROUP BY TO_CHAR(TRUNC(R.RAD_SUBMIT_DATE, 'MM'), 'yyyy-mm')
    ORDER BY TO_CHAR(TRUNC(R.RAD_SUBMIT_DATE, 'MM'), 'yyyy-mm')
    DESIRED RESULT SET
    THISDAT OPEN TOTAL TOTAL OPEN
    2002-08 1 37 1
    2002-09 0 40 1
    2002-10 0 33 1
    2002-11 1 25 2
    2002-12 2 22 4
    2003-01 3 25 7
    2003-02 4 101 11
    2003-03 5 99 16
    2003-04 5 85 21

    You are right those are group functions not aggregate. However, if I try to group by with the group functions I get an error (see code).
    SELECT
    TO_CHAR(TRUNC(R.RAD_SUBMIT_DATE, 'MM'), 'yyyy-mm') as THISDATE,
    COUNT(decode(A.STATE_DESC, 'Approved', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Concept', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'New', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Pending', A.STATE_DESC))
    ) as OPEN,
    COUNT(decode(A.STATE_DESC, 'Approved', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Concept', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'New', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Pending', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Completed', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Rejected', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Rescinded', A.STATE_DESC))
    ) as TOTAL,
    SUM(
    COUNT(decode(A.STATE_DESC, 'Approved', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Concept', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'New', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Pending', A.STATE_DESC))
    )) as "OPEN TOTAL"
    FROM RAW_APP_DATA R, APP_STATE A
    WHERE R.RAD_STATUS = A.STATE_ID
    AND (R.RAD_SUBMIT_DATE BETWEEN '01-AUG-02' AND '31-JAN-04')
    GROUP BY
    TO_CHAR(TRUNC(R.RAD_SUBMIT_DATE, 'MM'), 'yyyy-mm'),
    COUNT(decode(A.STATE_DESC, 'Approved', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Concept', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'New', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Pending', A.STATE_DESC))
    COUNT(decode(A.STATE_DESC, 'Approved', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Concept', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'New', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Pending', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Completed', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Rejected', A.STATE_DESC)) +
    COUNT(decode(A.STATE_DESC, 'Rescinded', A.STATE_DESC))
    ORDER BY TO_CHAR(TRUNC(R.RAD_SUBMIT_DATE, 'MM'), 'yyyy-mm')
    ORA-00934: group function is not allowed here
    Do I group by the columns individually?

  • How to use maximum date condition in where clause ?

    Hi I want to check if SWITCH_FLAG has 'Y' for the latest batch run..how can write it?
    (select a.SWITCH_FLAG
    from MORTGAGE
    where SYS_EFF_DATE = max(SYS_EFF_DATE)
    ) as expected_result
    Error message:
    ORA-00934: group function is not allowed here

    This will give you the switch_flag for the latest eff_date,
    SELECT SWITCH_FLAG
      FROM (SELECT A.SWITCH_FLAG, ROW_NUMBER () OVER (ORDER BY SYS_EFF_DATE DESC) rn
              FROM mortgage A)
    WHERE rn = 1;
    --if you want to test try this,
    SELECT SWITCH_FLAG,SYS_EFF_DATE
      FROM (SELECT A.SWITCH_FLAG,SYS_EFF_DATE , ROW_NUMBER () OVER (ORDER BY SYS_EFF_DATE DESC) rn
              FROM mortgage A)
    WHERE rn = 1;G.

  • Filter on evaluate/db function causing error in OBI report

    Hi,
    I unable to filter the report on EVALUATE function shown below
    CAST((Evaluate ('work_days_between_ADS (min(%1 ), max(%2))' as INT, "Order Attributes"."Booked Date" , "Line Level Attributes"."Line Status Date" )) AS INTEGER) >29
    above code is one column out of about 20 columns and report is working fine without filter but I want to see the data with work_days >29
    I got below error with above filter condition.
    View Display Error
    Odbc driver returned an error (SQLExecDirectW).
    Error Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 17001] Oracle Error code: 604, message: ORA-00604: error occurred at recursive SQL level 1 ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at line 8 ORA-00934: group function is not allowed here at OCI call OCIStmtExecute. [nQSError: 17010] SQL statement preparation failed. (HY000)
    If anyone of you know solution for the above please post it here. appreciate for your help
    Thanks
    Jay.
    Edited by: JV123 on May 9, 2013 9:24 AM

    Hi Jay,
    As you are getting an ORA- error, there is nothing wrong with the OBIEE report or with the fact that the you have used Evaluate in the filters.
    This seems like an error while parsing a particular row value for the parameters (Booked Date and Line Status Date) you are passing to the work_days_between_ADS function. Pick up the physical sql and fire it directly on the database and try to identify what values are causing the error (probably at line 8 of the function def).
    Thanks,
    Gaurav

  • How to update the COST column using another table's column

    Dear All,
    I have table:
    table parts: pno, pname, qoh, price, olevel
    table orders: ono, cno, eno, received, shipped
    table odetails: ono, pno, qty
    view:orders_view: ono, cno, eno, received, shipped,sum(qty*price)order_costview:odetails_view: ono, pno, qty, (qty*price)cost
    after I update the price in parts, I need to update COST and ORDER_COST too. The orders_view does not have pno, qty, and price, the odetails_view does not have price, how can I update the COST and ORDER_COST. Please help and Thanks in advance!!!
    I wrote the update the price in parts:
    create or replace procedure change_price(ppno in parts.pno%type, pprice in parts.price%type) as
    begin
        update parts
        set price = pprice
        where pno = ppno;
    end;
    show errorsthis procedure works fine.
    I wrote the trigger:
    create or replace trigger update_orders_v
    after update of price on parts
    for each row
    begin
        update orders_view
        set order_cost = sum(parts.(:new.price)*parts.qty)
        where parts.pno = :new.pno;
    end;
    show errorsIt gives me:Errors for TRIGGER UPDATE_ORDERS_V:
    LINE/COL ERROR
    3/5 PL/SQL SQL Statement ignored
    4/22 PL/SQL ORA-00934: group function is not allowed hereplease help!

    You could add the columns to the tables and then you would need a trigger to update those columns. However, you could just as easily select the price * qty to get the cost, without creating an additional column or trigger. I have no idea what you might want to do with a global temporary table. I think you need to explain what your purpose is, before any of us can suggest the best method. Since I have already demonstrated an update with a view, I will demonstrate an update with the cost column added to the odetails table and a trigger as you asked about. Notice that you will need triggers on both tables, the one that has qty and the one that has price.
    scott@ORA92> create table parts
      2    (pno    number(5) not null primary key,
      3       pname  varchar2(30),
      4       qoh    integer check(qoh >= 0),
      5       price  number(6,2) check(price >= 0.0),
      6       olevel integer)
      7  /
    Table created.
    scott@ORA92> create table odetails
      2    (ono    number(5),
      3       pno    number(5) references parts,
      4       qty    integer check(qty > 0),
      5       cost   number,
      6       primary key (ono,pno))
      7  /
    Table created.
    scott@ORA92> create or replace procedure change_price
      2    (ppno   in parts.pno%type,
      3       pprice in parts.price%type)
      4  as
      5  begin
      6    update parts
      7    set    price = pprice
      8    where  pno = ppno;
      9  end;
    10  /
    Procedure created.
    scott@ORA92> create or replace trigger update_cost1
      2    after insert or update of price on parts
      3    for each row
      4  begin
      5    update odetails
      6    set    cost = qty * :new.price
      7    where  pno = :new.pno;
      8  end update_cost1;
      9  /
    Trigger created.
    scott@ORA92> show errors
    No errors.
    scott@ORA92> create or replace trigger update_cost2
      2    before insert or update of qty on odetails
      3    for each row
      4  declare
      5    v_price parts.price%type;
      6  begin
      7    select price
      8    into   v_price
      9    from   parts
    10    where  pno = :new.pno;
    11    --
    12    :new.cost := :new.qty * v_price;
    13  end update_cost2;
    14  /
    Trigger created.
    scott@ORA92> show errors
    No errors.
    scott@ORA92> insert into parts values (1, 'name1', 1, 10, 1)
      2  /
    1 row created.
    scott@ORA92> insert into odetails values (1, 1, 22, null)
      2  /
    1 row created.
    scott@ORA92> -- starting data:
    scott@ORA92> select * from parts
      2  /
           PNO PNAME                                 QOH      PRICE     OLEVEL
             1 name1                                   1         10          1
    scott@ORA92> select * from odetails
      2  /
           ONO        PNO        QTY       COST
             1          1         22        220
    scott@ORA92> -- update:
    scott@ORA92> execute change_price (1, 11)
    PL/SQL procedure successfully completed.
    scott@ORA92> -- results:
    scott@ORA92> select * from parts
      2  /
           PNO PNAME                                 QOH      PRICE     OLEVEL
             1 name1                                   1         11          1
    scott@ORA92> select * from odetails
      2  /
           ONO        PNO        QTY       COST
             1          1         22        242
    scott@ORA92> -- select works without extra cost column or trigger:
    scott@ORA92> select o.ono, o.pno, o.qty, (o.qty * p.price) as cost
      2  from   odetails o, parts p
      3  where  o.pno = p.pno
      4  /
           ONO        PNO        QTY       COST
             1          1         22        242
    scott@ORA92>

  • Oracle 11g: update with group by

    DB. 11.2.0.2.0
    Hello
    This feels as though it should be simple. The below code tries to update the Activities table with the sum of staff hours (worked out from two other tables).
    The select works fine:
    select a.activities_id, sum((t.st_proportion*s.staff_time)*7*(t.st_enddate-t.st_startdate)/100)
    from aa_wl_activities3 a
    join aa_wl_stafftime2 t
    on a.activities_id=t.st_activity_id
    join aa_wl_staff s
    on t.st_staff_id=s.staff_id
    group by a.activities_idand produces data like this:
    7    700
    6    700
    44  700
    41  700
    update aa_wl_activities3 a
    set a.activities_stafftime = sum((t.st_proportion*s.staff_time)*7*(t.st_enddate-t.st_startdate)/100)
    join aa_wl_stafftime2 t
    on a.activities_id=t.st_activity_id
    join aa_wl_staff s
    and t.st_staff_id=s.staff_id
    group by a.activities_idI get this error:
    ORA-00934: group function is not allowed hereFrom various bits of googling, it is possible to update using an aggregate function - I want to check it's possible in Oracle SQL and if anyone can spot anything wrong with my code
    Thanks
    Emma

    emma-apex wrote:
    From various bits of googling, it is possible to update using an aggregate function - I want to check it's possible in Oracle SQL and if anyone can spot anything wrong with my codeYes, it's possible but you have to do it with a correlated subquery that computes the sum for each row of the target table :
    update aa_wl_activities3 a
    set a.activities_stafftime =
      select sum(
               (t.st_proportion * s.staff_time)
             * 7
             * (t.st_enddate - t.st_startdate)
             / 100
      from aa_wl_stafftime2 t
           join aa_wl_staff s on s.staff_id = t.st_staff_id
      where t.st_activity_id = a.activities_id
    ;(Or MERGE as suggested)

  • SQL developer 3.0 - Few Query Builder issues

    Hi All,
    I have just started using SQL Developer 3.0 so have not fully browsed thru all of the available options in SQL Developer. I have been trying to work on creating and editing sql statements using Worksheet and Query Builder.
    I am working on to test this tool so I can give it to the users for them to try and use it - they used to work on the old Query Builder 6.0.7....since it is already de-supported long back to work against 11g database, I am hoping to tell them to use SQL developer 3.0 instead.
    Hence, if an user doesn't know how to write a sql statement, he/she would try to do the same using Query Builder.
    So, the following questions are more aligned towards a normal user who would try to create a query in the Query Builder window, instead of directly typing a sql statement in the Worksheet window.
    1) How to establish/create a relationship between tables after you have dragged down the tables into the Query Builder window? - i tried but couldn't get any options!.
    2) Sometimes I see 'Connection closed' error when i try to run a query. How to refresh the connection without opening a new Connection tab?
    - I tried this but evertytime it opens up a new connection tab, while the old tab is still present.
    3) Columns in the Expression field in Query Builder window can ONLY be displayed in the result set, if the 'output' box on the extreme left of the 2nd section in Query Builder window is checked.
    Now when i try to check the output box for an expression (with few aggregate functions), the 'Grouping' check box automatically gets checked, which when run throws an ORA-00934 error: group function is not allowed here...but when I de-select the 'Grouping' check box, the 'output' box also gets un-checked!.
    How to solve this out?
    Please let me know the resolutions of the above - much appreciated.
    With Regards,
    Pamir
    Edited by: user651047 on 11-Aug-2011 07:53

    Hi,
    As Raghu noted above, and you also saw in rp0428's following reply,
    Re: Problem with displaying sdo_geometry objects
    drilling down to the cell edit details is your only recourse for now. Apparently there will be further work done in this area, but it is not clear exactly what or when it will be. For those with access to it, here is a bug reference:
    Bug 13680849 - RC1: NOT DISPLAYING THE DATA OF MDSYS.SDO_GEOMETRY
    Regards,
    Gary

Maybe you are looking for

  • How to get name of variable passed to method

    How can I get the name of the variable that's passed into a method, in the method? for instance: the following code prints an array to a text file, and includes the name of the array in the name of hte text file. So, to call it, I have to do this: pr

  • Finding the images used in my Forest Screensaver to use as a Desktop

    I guess the question is fairly self explanatory from the subject. Is it possibe for someone to tell me the location of the images used in the Forest Screensaver that comes with OSX so that I can use the images a desktop images, because I like them. I

  • OCI provides function oerhms. What is the JDBC equivalent?

    How can I get the complete Oracle error message, not just the terse one?

  • Using sq01

    hi, how can u use where conditions in sq01?? where do u write the sql statements? i created the info sets and usergroups and basic query.. but didnt find a place to write the sql statements for more advance queries? ANy help is appreciated Thanks kes

  • Tidynetworks overwrites data I'm viewing. How to prevent????

    When view catalog or craiglist information, TidyNetwork.com and probably others are overwriting the area I'm trying to read/view. This only recently started. I upgraded to latest version of Firefox to this being a problem. I also downloaded some soft