Query using analytics function in SQL

Hello,
I have a situation here .. kindly guide me..
There are 2 tables, Case table (summary table) and Task table (detailed table)
The structure of tables:
Case Table:
Case_ID,
Trans_CT, à(transaction count could be 1,2,3 ..any numeric  value)
Case_Rec_ID  (major cols required)
Task table:
Case_ID
Case_Rec_ID,
Task Name,
Work_group_name,
Ready_to_work_in (Yes/No),
Ready_to_work_ts
Lst_Upd_ts
A work group can contain multiple cases.
I need to find out the # of ready_to_work transactions per case and roll it up to work group level.
The transaction Count is given at Case level (it is predefined in the source application;need not bother about how the value arrived;) if we do a join between case and task table , trans_ct appears for all the tasks. But there is a business rule for calculating the # of transactions(summation).
A case contains several tasks like for ex. & corresponding ready to work indicator like below
Case1 – Task 1   Y
                Task2    Y
                Task3    N
                Task4    Y
                Task5    Y
Case2 - Task 1   Y
                Task2    Y
                Task3    N
                Task4    Y
                Task5    N
If the RTW indicator is N for the last or recent task within the case then it can be ignored.
If the RTW indicator is Y for the last or recent task then we need consider the “trans_ct” value as # of RTW transaction for that case.
So Case 2 shall be ignored.
In Case 1, you can find the RTW flag has switched from Y-N-Y. If there is a switch of RTW flag within the case from Y to N then to Y and the last or recent tasks RTW flag is Y then we need to account for the number of switches & consider the corresponding “trans_ct” value. (# of switches * trans_ct)
Let’s say the trans_ct is 3 for Case 1. Now in this scenario, the # of RTW transactions would be (2*3=6 ).
Now I need to develop a query that can handle this scenario and roll up to work group level.
Tried the analytic functions lag,lead and first value, last value…but still trying to figure out the logic to handle this case1.
FYI- The Tasks need to be ordered by last_upd_ts
Please can you help me with the query.
Thanks
Vinoth

Are you after something like this ?
with
cases as
(select 1 case_id,3 trans_ct,5 case_rec_id from dual union all
select 2,4,5 from dual union all
select 3,1,4 from dual union all
select 4,2,5 from dual
tasks as
(select 1 case_id,1 case_rec_id,'task 1' task_name,'g 1' work_group_name,'Y' ready_to_work_in,sysdate - 20 ready_to_work_ts,sysdate - 20 lst_upd_ts from dual union all
select 1,2,'task 2','g 1','Y',sysdate - 20,sysdate - 18 from dual union all
select 1,3,'task 3','g 1','N',sysdate - 20,sysdate - 17 from dual union all
select 1,4,'task 4','g 1','Y',sysdate - 16,sysdate - 15 from dual union all
select 1,5,'task 5','g 1','Y',sysdate - 16,sysdate - 12 from dual union all
select 2,1,'task 1','g 1','Y',sysdate - 18,sysdate - 18 from dual union all
select 2,2,'task 2','g 1','Y',sysdate - 16,sysdate - 16 from dual union all
select 2,3,'task 3','g 1','N',sysdate - 12,sysdate - 12 from dual union all
select 2,4,'task 4','g 1','Y',sysdate - 11,sysdate - 11 from dual union all
select 2,5,'task 5','g 1','N',sysdate - 10,sysdate - 10 from dual union all
select 3,1,'task 3','g 2','Y',sysdate - 13,sysdate - 13 from dual union all
select 3,2,'task 5','g 2','N',sysdate - 13,sysdate - 12 from dual union all
select 3,3,'task 1','g 2','N',sysdate - 13,sysdate - 11 from dual union all
select 3,4,'task 2','g 2','Y',sysdate - 13,sysdate - 10 from dual union all
select 4,1,'task 1','g 1','Y',sysdate - 20,sysdate - 20 from dual union all
select 4,2,'task 2','g 1','N',sysdate - 20,sysdate - 17 from dual union all
select 4,3,'task 3','g 1','Y',sysdate - 15,sysdate - 15 from dual union all
select 4,4,'task 4','g 1','N',sysdate - 15,sysdate - 13 from dual union all
select 4,5,'task 5','g 1','Y',sysdate - 15,sysdate - 10 from dual
CASE_ID
TRANS_CT
CASE_REC_ID
1
3
5
2
4
5
3
1
4
4
2
5
CASE_ID
CASE_REC_ID
TASK_NAME
WORK_GROUP_NAME
READY_TO_WORK_IN
READY_TO_WORK_TS
LST_UPD_TS
1
1
task 1
g 1
Y
09/13/2013
09/13/2013
1
2
task 2
g 1
Y
09/13/2013
09/15/2013
1
3
task 3
g 1
N
09/13/2013
09/16/2013
1
4
task 4
g 1
Y
09/17/2013
09/18/2013
1
5
task 5
g 1
Y
09/17/2013
09/21/2013
2
1
task 1
g 1
Y
09/15/2013
09/15/2013
2
2
task 2
g 1
Y
09/17/2013
09/17/2013
2
3
task 3
g 1
N
09/21/2013
09/21/2013
2
4
task 4
g 1
Y
09/22/2013
09/22/2013
2
5
task 5
g 1
N
09/23/2013
09/23/2013
3
1
task 3
g 2
Y
09/20/2013
09/20/2013
3
2
task 5
g 2
N
09/20/2013
09/21/2013
3
3
task 1
g 2
N
09/20/2013
09/22/2013
3
4
task 2
g 2
Y
09/20/2013
09/23/2013
4
1
task 1
g 1
Y
09/13/2013
09/13/2013
4
2
task 2
g 1
N
09/13/2013
09/16/2013
4
3
task 3
g 1
Y
09/18/2013
09/18/2013
4
4
task 4
g 1
N
09/18/2013
09/20/2013
4
5
task 5
g 1
Y
09/18/2013
09/23/2013
switches as
(select case_id,case_rec_id,task_name,work_group_name,ready_to_work_in,ready_to_work_ts,lst_upd_ts,switch
   from (select case_id,case_rec_id,task_name,work_group_name,ready_to_work_in,ready_to_work_ts,lst_upd_ts,
                case when ready_to_work_in = 'N'
                      and lag(ready_to_work_in) over (partition by case_id order by lst_upd_ts) = 'Y'
                      and lead(ready_to_work_in) over (partition by case_id order by lst_upd_ts) = 'Y'
                     then 2
                end switch,
                first_value(ready_to_work_in) over (partition by case_id order by lst_upd_ts desc) last_rtw
           from tasks
  where last_rtw = 'Y'
CASE_ID
CASE_REC_ID
TASK_NAME
WORK_GROUP_NAME
READY_TO_WORK_IN
READY_TO_WORK_TS
LST_UPD_TS
SWITCH
1
1
task 1
g 1
Y
09/13/2013
09/13/2013
1
2
task 2
g 1
Y
09/13/2013
09/15/2013
1
3
task 3
g 1
N
09/13/2013
09/16/2013
2
1
4
task 4
g 1
Y

Similar Messages

  • How can rewrite the Query using Analytical functions ?

    Hi,
    I have the SQL script as shown below ,
    SELECT cd.cardid, cd.cardno,TT.TRANSACTIONTYPECODE,TT.TRANSACTIONTYPEDESC DESCRIPTION,
    SUM (NVL (CASE tt.transactiontypecode
    WHEN 'LOAD_ACH'
    THEN th.transactionamount
    END, 0)
    ) AS load_ach,
    SUM
    (NVL (CASE tt.transactiontypecode
    WHEN 'FUND_TRANSFER_RECEIVED'
    THEN th.transactionamount
    END,
    0
    ) AS Transfersin,
    ( SUM (NVL (CASE tt.transactiontypecode
    WHEN 'FTRNS'
    THEN th.transactionamount
    END,
    0
    ) +
    SUM (NVL (CASE tt.transactiontypecode
    WHEN 'SEND_MONEY'
    THEN th.transactionamount
    END, 0)
    )) AS Transferout,
    SUM (NVL (CASE tt.transactiontypecode
    WHEN 'WITHDRAWAL_ACH'
    THEN th.transactionamount
    END, 0)
    ) AS withdrawal_ach,
    SUM (NVL (CASE tt.transactiontypecode
    WHEN 'WITHDRAWAL_CHECK'
    THEN th.transactionamount
    END, 0)
    ) AS withdrawal_check,
    ( SUM (NVL (CASE tt.transactiontypecode
    WHEN 'WITHDRAWAL_CHECK_FEE'
    THEN th.transactionamount
    END,
    0
    ) +
    SUM (NVL (CASE tt.transactiontypecode
    WHEN 'REJECTED_ACH_LOAD_FEE'
    THEN th.transactionamount
    END,
    0
    ) +
    SUM (NVL (CASE tt.transactiontypecode
    WHEN 'WITHDRAWAL_ACH_REV'
    THEN th.transactionamount
    END,
    0
    ) +
    SUM (NVL (CASE tt.transactiontypecode
    WHEN 'WITHDRAWAL_CHECK_REV'
    THEN th.transactionamount
    END,
    0
    ) +
    SUM
    (NVL (CASE tt.transactiontypecode
    WHEN 'WITHDRAWAL_CHECK_FEE_REV'
    THEN th.transactionamount
    END,
    0
    ) +
    SUM
    (NVL (CASE tt.transactiontypecode
    WHEN 'REJECTED_ACH_LOAD_FEE_REV'
    THEN th.transactionamount
    END,
    0
    ) +
    SUM (NVL (CASE tt.transactiontypecode
    WHEN 'OVERDRAFT_FEE_REV'
    THEN th.transactionamount
    END, 0)
    ) +
    SUM (NVL (CASE tt.transactiontypecode
    WHEN 'STOP_CHECK_FEE_REV'
    THEN th.transactionamount
    END,
    0
    ) +
    SUM (NVL (CASE tt.transactiontypecode
    WHEN 'LOAD_ACH_REV'
    THEN th.transactionamount
    END, 0)
    ) +
    SUM (NVL (CASE tt.transactiontypecode
    WHEN 'OVERDRAFT_FEE'
    THEN th.transactionamount
    END, 0)
    ) +
    SUM (NVL (CASE tt.transactiontypecode
    WHEN 'STOP_CHECK_FEE'
    THEN th.transactionamount
    END, 0)
    )) AS Fee,
    th.transactiondatetime
    FROM carddetail cd,
    transactionhistory th,
    transactiontype tt,
    (SELECT rmx_a.cardid, rmx_a.endingbalance prev_balance, rmx_a.NUMBEROFDAYS
    FROM rmxactbalreport rmx_a,
    (SELECT cardid, MAX (reportdate) reportdate
    FROM rmxactbalreport
    GROUP BY cardid) rmx_b
    WHERE rmx_a.cardid = rmx_b.cardid AND rmx_a.reportdate = rmx_b.reportdate) a
    WHERE th.transactiontypeid = tt.transactiontypeid
    AND cd.cardid = th.cardid
    AND cd.cardtype = 'P'
    AND cd.cardid = a.cardid (+)
    AND CD.CARDNO = '7116734387812758335'
    --AND TT.TRANSACTIONTYPECODE = 'FUND_TRANSFER_RECEIVED'
    GROUP BY cd.cardid, cd.cardno, numberofdays,th.transactiondatetime,tt.transactiontypecode,TT.TRANSACTIONTYPEDESC
    Ouput of the above query is :
    CARDID     CARDNO     TRANSACTIONTYPECODE     DESCRIPTION     LOAD_ACH     TRANSFERSIN     TRANSFEROUT     WITHDRAWAL_ACH     WITHDRAWAL_CHECK     FEE     TRANSACTIONDATETIME
    6005     7116734387812758335     FUND_TRANSFER_RECEIVED     Fund Transfer Received     0     3.75     0     0     0     0     21/09/2007 11:15:38 AM
    6005     7116734387812758335     FUND_TRANSFER_RECEIVED     Fund Transfer Received     0     272     0     0     0     0     05/10/2007 9:12:37 AM
    6005     7116734387812758335     WITHDRAWAL_ACH     Withdraw Funds via ACH     0     0     0     300     0     0     24/10/2007 3:43:54 PM
    6005     7116734387812758335     SEND_MONEY     Fund Transfer Sent     0     0     1     0     0     0     19/09/2007 1:17:48 PM
    6005     7116734387812758335     FUND_TRANSFER_RECEIVED     Fund Transfer Received     0     1     0     0     0     0     18/09/2007 7:25:23 PM
    6005     7116734387812758335     LOAD_ACH     Prepaid Deposit via ACH     300     0     0     0     0     0     02/10/2007 3:00:00 AM
    I want the output like for Load_ACH there should be one record etc.,
    Can any one help me , how can i rewrite the above query using analytical functions .,
    Sekhar

    Not sure of your requirements but this mayhelp reduce your code;
    <untested>
    SUM (
       CASE
       WHEN tt.transactiontypecode IN
          ('WITHDRAWAL_CHECK_FEE', 'REJECTED_ACH_LOAD_FEE', 'WITHDRAWAL_ACH_REV', 'WITHDRAWAL_CHECK_REV',
           'WITHDRAWAL_CHECK_FEE_REV', 'REJECTED_ACH_LOAD_FEE_REV', 'OVERDRAFT_FEE_REV','STOP_CHECK_FEE_REV',
           'LOAD_ACH_REV', 'OVERDRAFT_FEE', 'STOP_CHECK_FEE')
       THEN th.transactionamount
       ELSE 0) feeAlso, you might want to edit your post and use &#91;pre&#93; and &#91;/pre&#93; tags around your code for formatting.

  • Problem using extract function (PL/SQL) with "&#34"

    Hi,
    When I use extract function (PL/SQL), it does not transform well "&#34". Insted of returning ' " ' , it returns ' &quot '.
    I know this works changing the code replacing xml.extract for SELECT extractvalue(xml,'//A/text()') into v from dual;
    But Is there another way to do this using PL/SQL? any patch, option..?
    Regards

    Had to use my website to demonstrate the code...
    As said, whatever I try here the code gets automatically converted...
    See for answer on your question: http://www.liberidu.com/blog/?p=635

  • Insert query using fn-bea:execute-sql() function

    Hi ,
    How to use sql insert query in Xquery function fn-bea:execute-sql().
    Could you please anyone help me on this.
    Regards
    Rajesh.

    Hi
    Can i use stored procedure in that function to include insert query?
    could you please suggest me on this.
    Please provide some links or tutorial on that.
    Regards
    Rajesh

  • How to build dynamic query strings in the query using DB adapter 'Pure SQL'

    Dear Forum,
    I am building an application which will access DB to fetch some result set. The query involves retrieving data from multiple tables(nearly 10 tables). So I have created a DB adapter using 'execute pure sql' option. With this query works fine, but my inputs parameters will vary. So I need to make my query dynamic to append the query strings at runtime depending on the inputs.
    For example I have 3 input variables - input1,input2 and input3 (in my request xsd) which are used in the pure sql query. Now if I get a 4th input parameter input4 in the request, I need to append this to query string as 'AND input4=[some value]' at runtime. Otherwise my query should have only 3 parameters. Please suggest how this can be achieved.
    Regards,
    Satya.

    This is a strange requirement, depending on the columns you have and what are optional in them, one way is to have separate operations and each opeartion will have different inputs and for each operation , a different DB Adapter is called. But this way, it results in more number of operations for the service as well as more number of references in the composite. Even if you pass the column inputs to the SQL procedure, it will result in a large number of if-else cases..
    Thanks,
    N

  • Using User function in SQL*Loader

    Hi, I have created the following control file. I am using DIRECT path insert. I am using a function to retrieve the column system_date. However, when I am running sql*loader, the fields system_date and load_date are loaded with null value.
    OPTIONS (ERRORS=999999999, DIRECT=TRUE, ROWS=100000, SKIP=1)
    LOAD DATA
    INFILE 'Z:\xx.csv'
    APPEND
    PRESERVE BLANKS
    INTO TABLE TB_RAW_DATA
    FIELDS TERMINATED BY ','
    OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    REFERENCE_NUMBER,     
    SYSTEM_DATE "pkg_ken_utility.Fn_ken_get_param_value('SYSTEM_DATE','SYSTEM_DATE')",
    LOAD_DATE "SYSDATE"
    )

    No,
    You can not call PL/SQL functions in DIRECT PATH mode, also this is documented, so you should not need to ask.
    Sybrand Bakker
    Senior Oracle DBA

  • Using cursor function in sql statement

    hi all
    can anyone plss explain why and when we will use cursor function in a sql statement like this and what is the difference while executing this sql statement with cursor function in comparison of a simple sql statement----
    select
    department_name,
    cursor (
    select last_name
    from employees e
    where e.department_id = d.department_id
    order by last_name
    ) the_employees
    from departments d
    thnx in advance

    RTFM
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#sthref1452
    Cheers
    Sarma.

  • SQL query using MAX function

    I am trying to only display the records where the 'date_entered' is the most recent date per case number.
    SELECT distinct c.case_number, u.email,c.assigneddate_chart,
    --m.date_entered,
    max(m.date_entered)as last_date_entered,
    trunc(sysdate)-trunc(c.assigneddate_chart)days_late,
    trunc(sysdate)-trunc(m.date_entered)addl_days_late
    from chart c, chart_user_roles u,comments m
    where
    (c.case_status IN ('Open','Pending')) and
    c.case_number=m.case_number
    group by c.case_number,
    u.email,c.assigneddate_chart,m.date_enteredRight now, this is the output im am getting.
    Output:
    CASE_NUMBER------EMAIL---------ASSIGNEDDATE_CHART---LAST_DATE_ENTERED---DAYS_LATE--ADDL_DAYS_LATE
    [email protected]----06-NOV-09-----------------31--------------------11
    [email protected]----10-NOV-09-----------------31---------------------7
    [email protected]----06-NOV-09-----------------31--------------------11
    [email protected]----06-NOV-09-----------------31--------------------11
    [email protected]----06-NOV-09-----------------31--------------------11
    [email protected]----03-NOV-09-----------------34--------------------14
    I am wanting to achieve this output:
    Therefore, based on the data below, the only records that i am wanting to display are:
    [email protected]----10-NOV-09-----------------31---------------------7
    [email protected]----03-NOV-09-----------------34--------------------14
    Thanks
    Deanna

    Is there a reason that you have a DISTINCT in your query? It always makes me nervous to see that where it's not clearly necessary because it frequently means that a developer is missing a join condition and is using the DISTINCT to mask that fact.
    On to the meat of your question, though, is there a potential for ties? If so, how do you want to handle that-- do you want two rows for that case, do you want to break the tie using some other column, do you want to pick an arbitrary row? If you want to pick an arbitrary row
    SELECT case_number, email, assignedDate_chart, last_date_entered, days_late, addl_days_late
      FROM (
        SELECT a.*, row_number() over (partition by case_number order by date_entered) rn
          FROM (<<your query>>) a
    WHERE rn = 1If you want to do something else, just adjust the analytic function and use RANK or add a tie-breaker to the ORDER BY.
    Justin

  • Replace Values for a Col under a Table using Replace Function in Sql Query

    Hi all
    I have a Custom Table by Name RESP_TABLE which stores the Responsibility Names under the Column RESPONSIBILITY.
    The Sample Value for this col is as follows :
    PF <CNTRY> Gl Analyst <CCY>.
    This <CNTRY> Stands for Country Short Name
    and <CCY> Stands for Currency.
    The <CNTRY> & <CCY> should be passed as a parameter at the run time.
    Based on the value given at the run time it should change accordingly.
    For example
    PF <CNTRY> Gl Analyst <CCY>
    <CNTRY> Value passed at runtime : BE
    <CCY> Value passed at runtime : CAD
    So the resulting value should be as follows :
    PF BE Gl Analyst CAD.
    I had already used the query given below :
    SELECT REPLACE(RESPONSIBILITY,'<CNTRY>','&MARKET') FROM RESP_TABLE.
    This works fine for Country Code alone but not for currency.
    I need both the Country Code and Currency Code to be changed to the respective values given at the runtime.
    Could anybody please help me on this ?
    Regards
    Nakul Venkataraman.

    Hi Nakul,
    Why not just adding another REPLACE to what you still have achieved? :)
    Regards,
    Guido

  • SQL Query - Using Lag function

    Hi All,
    I need to select the previous and next record, when the value of column is changed for each account.
    My table structure is as follows:
    Account_No number(10)
    Payment_type number(5)
    Installment_Type number(5)
    Date_chage date
    Sample record:
    Account_No Payment_Type Installment_Type Date_change
    70539 ** 1 ** 2 ** 01-OCT-83
    70539 ** 1 ** 2 ** 03-FEB-01
    70539 ** 1 ** 2 ** 26-APR-02
    70539 ** 1 ** 1 ** 21-JUN-02
    70539 ** 1 ** 2 ** 12-JUL-02
    185562 ** 1 ** 2 ** 23-APR-02
    185562 ** 2 ** 2 ** 10-MAY-02
    In the above sample data, the value of instalment is changed on 21-jun-02 and 12-jul-02 for the account 70539. Also the value of Payment Type is changed on 23-apr-02 for the account 185562.
    So, my output should be like this.
    Account_No Payment_Type Installment_Type Date_change
    70539 ** 1 ** 2 ** 26-APR-02
    70539 ** 1 ** 1 ** 21-JUN-02
    70539 ** 1 ** 2 ** 12-JUL-02
    185562 ** 1 ** 2 ** 23-APR-02
    185562 ** 2 ** 2 ** 10-MAY-02
    I tried with lag function, but I couldnt succeed. Im using oracle 8.1.6 Version.
    Can anyone help me to achieve this?
    ** To distinguish the value for each coulmn.
    Thanks and regards,
    Vijay R.

    With the information you have provided, I've come up with the following.
    SELECT A.ACCOUNT_NO, A.PAYMENT_TYPE, A.INSTALLMENT_TYPE, A.DATE_CHANGE
    FROM
        (SELECT account_no, payment_type, installment_type, date_change,
                LEAD( (payment_type), 1)
                     over (partition by account_no order by account_no, DATE_CHANGE)  LEAD_PAY,
                LEAD( (installment_type), 1)
                     over (partition by account_no order by account_no, DATE_CHANGE)  LEAD_INST
          from T_ACCNTS ) A
    WHERE A.PAYMENT_TYPE <> NVL(A.LEAD_PAY,99)
       OR A.INSTALLMENT_TYPE <> NVL(A.LEAD_INST,99)
    ORDER BY 1, 4;

  • Regardin handling exception in a function, while using that function in sql

    Hi gurus,
    I have a question regarding logging exceptions while using functions.
    I wrote a separate package to handle errors, where i have a procedure.
    In this proc i'm logging my error into a table and then raise the error to the front end.
    Ex:
    proc_log_and_raise    -- this proc... inserts my error into a table and then raisenow i included this error procedure in all functions and procedures.
    consider an example with a sample procedure and function.
    function func_1(( v_var   varchar2) return varchar2 is
    begin
         select   column2
         from     table2
        where col1 = v_var;
    exception
        when others then
             proc_log_and_raise;
    end;  
    procedure proc_1( v_var   varchar2) is
    begin
        select   func_1(v_var)  -- error occurs here..
        from     table_a
        where   col1 = v_var;
    exception
        when others then
             proc_log_and_raise;
    end;    now i do
    exec  proc_1( v_var );but now my problem is, when an error occurs in func_1, i'm getting an error with DML operation ( as we are inserting into error table)
    ORA-14551: cannot perform a DML operation inside a query.
    so what i want to do is, log both function and procedure where error occured.
    So is there any other better way, we can write our exception handling, so that i can log error and use function in a select statement.
    thank you.

    I changed my procedure a little, to make it simple.
    FUNCTION        PKG_WEEKLY.FUNC_1
                RETURN NUMBER IS 
                exc exception;
    BEGIN                         
                raise exc;
                RETURN           v_provr_rcoupt;
    EXCEPTION
                when exc then
                            PKG.PKG_ERROR.USP_LOG_AND_RAISE(
                                        'batch_1',
                                        'func_1',
                                        SQLCODE,
                                        DBMS_UTILITY.FORMAT_ERROR_STACK || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE()); 
    END FUNC_1;     
    PROCEDURE    PKG_WEEKLY.PROC_1(
                cur_details                                OUT      sys_refcursor) IS
    BEGIN
                OPEN cur_details FOR
                SELECT            NVL(PKG.PKG_WEEKLY.FUNC_1,0))    FROM DUAL;
    EXCEPTION
                WHEN OTHERS THEN
                            REPORT_APP_PKG.PKG_REPORT_ERROR.USP_LOG_AND_RAISE(
                                        'batch_1',
                                        'PROC_1',
                                        SQLCODE,
                                        DBMS_UTILITY.FORMAT_ERROR_STACK || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE());  
    END PROC_1; Now i execute it.
    exec PKG_WEEKLY.PROC_1(:cursor); Error logged into the table:
    242 batch_1 func_1 ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "REPORT_APP_PKG.PKG_REPORT_WEEKLY_CAO", line 230
    04/14/2009 16:09:25
    ERRORS displayed to the front end:
    ORA-20156: ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "PKG.PKG_WEEKLY", line 230
    ORA-06512: at "PKG.PKG_ERROR", line 48
    ORA-06512: at "PKG.PKG_ERROR", line 226
    ORA-06512: at "PKG.PKG_WEEKLY", line 261
    thank you

  • Using XML functions in SQL Developer

    Hi,
    I'm using OSD 1.5.3 on a WinXP machine. I love OSD and use it every day! But I think i found a little bug. When you use some Oracle XML functions like (XMLELEMENTS and XMLAGG) in your query (these functions return CLOB values) it hangs OSD.
    For Example:
    SELECT XMLELEMENT("Relation",
    XMLELEMENT("Name", 'Dennis'),
    XMLELEMENT("DateOfBirth", '09/28/1975')
    ) as Relation
    FROM DUAL;
    Are there some parameters I can set to prevent this, or is this a bug?
    Kind Regards,
    D.

    Your query works fine for me from SQL Dev 1.5.3 (JDK 1.6.0_06), using either a JDBC or TNS connection (Oracle Client 9.2) to a 10.2.0.3 DB. Another thing which I have no idea if it is relevant (someone else may be able to say) is the following line from Help > About > Properties:
    oracle.xdkjava.compatibility.version     9.0.4
    Given that it works fine over TNS connections from SQL*Plus and PL/SQL Developer, I would assume that it is something related to your SQL Developer setup, unless you are using a different version of the Oracle client for these tools.
    theFurryOne

  • Using DECODE Function in SQL

    I need to know if there is any way to use a range of values from
    database and decode to certain text. I am able to do with one
    value.
    for example:
    DECODE(column_name,'216767111','Unlimited',column_name)
    above argument works with one value only. How about a range,
    ex: 216767000 to 216767111. I need to use only SQL. No PL/SQL.
    Kinldly need some body's help
    Thanks
    Munis

    Which version of the database? If it's 8i+ then you can use
    the CASE function
    for example:
    (CASE WHEN column_name between 216767000 and 216767111
    THEN 'Unlimited' ELSE column_name END)
    This won't work in PL/SQL because they're introducing a CASE
    statement does soemthing different.
    rgds, APCHello Andrew
    Thank you for response. I am using 8i. 8.1.6. However using
    CASE, I get inconsistent data type, ORA-00932: inconsistent
    datatypes. I able to work it out with other response using
    DECODE(sign(. Do you have any idea why i am getting this error.
    If time permits, let me know

  • How to use evaluate function for sql server function

    Hi Team,
    We have imported a column(date dtat type) from SQL server cube . By default it imported as varchar,. We have three option in physical layer for this column(Varchar,Intiger,unknown)
    So we want to convert this column into date.can we use evaluate or there is any option to do that.?

    Hi,
    I am not sure your requirement. But how pass evaluate function obiee?
    syntax:- EVAULATE('your db function(%1,%2)', parameter list)
    here %1 and %2 are the no.of parameters (columns or may constant values) to be passed for the db-function
    if you have 3 parameters then you need to use %3 also.. means the columns to be passed.
    following exapmples are for ORACLE db,
    ex1: EVALUATE('upper(%1)', 'satya ranki reddy') gives the result as -> SATYA RANKI REDDY
    ex2: EVALUATE('upper(%1)', 'Markets.Region') here Markets.Region is column.
    you also can call the user-defined functions through evaulate
    EVALUATE('functioname(%1,%2), column1, column2)
    the above function has 2 parameters to be inputted
    Hope this help's
    Thanks
    Satya

  • How to use nvl() function in SQL Loader

    I am trying to use nvl() funtion in my SQL Loader control file and I keep geting errors. Would someone please tell me where I can find the syntax reference to this?
    Thanks a lot!

    I just answered a similar question like this last Thursday.
    SQL*LOADER how to load blanks when data is null

Maybe you are looking for

  • Lost ~20% of library when upgrading to V7

    I recently upgraded to Itunes V7 only to discover that the library couldn't locate about 20% of my songs (I have over 2500). After manually locating about 50 songs one at a time I gave up and went back to version 6. Very disappointed. I won't upgrade

  • DB Selects during Mapping

    Hello, during my message mapping i need to call a Database in Order to select dynamically a value for the destination field. I need to know whether Is this possible with message mapping at all, and if so, what are the basic stepts to this <i><b>withi

  • Apple iPhone & Flash

    Hi everyone, It seems as if the iPhone features the flash player within Safari. The page www.fandango.com is being used as a demo on the device in Apple's web site and this page has a few Flash banners. They don't seem to be animated on the demo thou

  • How to extract a jar to a specified folder??

    I want to extract a jar file with sun' Jar, But how set the target folder in the Jar command Line It is like this ?? Jar -xvf Test.jar -C d:\test\ But it can't work ! please help me !

  • Searching a revision using CMIS query in Oracle UCM 11g

    Hi, I have 4 revisions of a content ,4th revision being the latest one ,Is there a way where in I can search the earlier revision of a content i.e. 2,3 or 1st revisions based on a combination of metadata using CMIS query...