If else or decode

can you please help me to find What is worng with below query. it showing as null output which not true
<?xdofx:if TOT_PROJ_COST=0 then 0 else (TOT_OTH_TAX_EXMPT/TOT_PROJ_COST) end if?> can i convert it to decode or correct the above statment.

I find that special tests for NULL/undefined conditions are more straightforward in SQL instead of XSLT. The fact that all numbers are effectively interpreted as text in XML makes things less intuitive. Furthermore, do you really like debugging templates more than queries? I would rather write three levels of subqueries than do condition tests and conditional formatting in XSL.

Similar Messages

  • IF THEN ELSE in DATA TEMPLATE NOT IN RTF

    Hi,
    Can any one tell me How to Implement IF THEN ELSE or DECODE or CASE Logic in a DATA TEMPLATE not in RTF
    as I saw loads of Post about implementing them in RTF not in the Template itself.
    I have a requirement please click this below for the Detailed Version of this Post, Else Please Just give me a Snippet from which i can Implement the IF THEN ELSE Logic in a DATA TEMPLATE( the .xml file) bu please not via a RTF not using PL/SQL Package
    Logic to select Report name based on User's input.
    Thanks
    vasanthanand

    Hello
    I am looking to do the same type of thing did you ever get an answer without having to use a RTF format perhaps in another forum or through investigation?

  • Cursor w/alias,decode,round,sum etc - not working

    Hello all,
    I'm Herb. I'm having trouble creating a cursor. My select statement has decode,round, sum, mutiplication etc.
    Example.
    cursor first_info (ppe_date_in varchar2) is
    (select decode(pdrdedn_opt_code1,'P1',(round((sum(nhrdist_amt) * .095),2)),
    'P2',(round((sum(nhrdist_amt) * .095),2)),
    'P3',(round((sum(nhrdist_amt) * .095),2)),
    (round((sum(nhrdist_amt) * .08),2))) v_contribution,
    to_number('0.00') p_contribution,
    pdrdedn_pidm v_pidm
    from ptrcaln, pdrdedn, phrdedn, nhrdist, spriden, nbrbjob, nbrjobs
    Has anyone been successful in using an arrangement like this? My procedure has no errors, but I have no data also. CAn someone please help.
    Herb

    Will this complexity is sufficient for you? ;)
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.18
    satyaki>
    satyaki>
    satyaki>declare
      2    cursor c1(e_no in number)
      3    is
      4      select trunc(
      5                    (
      6                      nvl(
      7                            case
      8                              when sal between 3000 and 7000 then
      9                                count(*)
    10                            else
    11                                decode(comm,'',max(comm),trunc(comm))
    12                            end,
    13                            555
    14                          )*120
    15                     )/34
    16                  ) complex_calc_in_cur
    17      from emp
    18      where empno = e_no
    19      group by empno,sal,comm;
    20     
    21     r1 c1%rowtype;
    22  begin
    23    open c1(&eno);
    24    loop
    25      fetch c1 into r1;
    26       exit when c1%notfound;
    27         dbms_output.put_line('Calculated Value: '||r1.complex_calc_in_cur);
    28    end loop;
    29    close c1;
    30  end;
    31  /
    Enter value for eno: 7902
    old  23:   open c1(&eno);
    new  23:   open c1(7902);
    Calculated Value: 3
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.07
    satyaki>
    satyaki>/
    Enter value for eno: 7777
    old  23:   open c1(&eno);
    new  23:   open c1(7777);
    Calculated Value: 12000
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.05
    satyaki>
    satyaki>/
    Enter value for eno: 7566
    old  23:   open c1(&eno);
    new  23:   open c1(7566);
    Calculated Value: 1958
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.06
    satyaki>
    satyaki>Until or unless you post your exact code it is difficult for us tell anything on your problem.
    And, please don't ask the purpose of this function. ;)
    Regards.
    Satyaki De.

  • Decode formula for Interactive Compute field

    Hi,
    Need help for decode formula for Interactive Compute field.
    What is wrong with the formula below?
    What I want is...
    If BH field value is 'Y' then get T field value else 'OK'
    If T field value does not begin with 'FY11 OU%' then get AL field value else 'OK'
    If AL field value ends with 'REC' then 'CHECK' else 'OK'
    DECODE(SUBSTR(decode(SUBSTR(decode(BH,'Y',T,'OK'),1,7),not like 'FY11 OU%',AL,'OK'),-3),'REC','CHECK','OK')
    I get error message: Invalid computation expression. not
    Would you please suggest me a correct formula?
    FYI, I'm using Apex 3.0 which does not support CASE WHEN THEN END.
    Thanks,
    Guy

    DECODE(BH || SUBSTR(T,1,7) || SUBSTR(AL,-3),'YFY11 OUREC','OK','CHECK')
    I guess the above code will mark 'YFY11 PRREC' as 'CHECK' because it is different from 'YFY11 OUREC'.
    But according to my second case criteria, it should be marked as 'OK' because...
    BH = 'Y'
    T does not begin with 'FY11 OU'
    AL ends with 'REC'.
    Currently I'm running filtering with your formula. But it is taking too long time. I guess there are too many lines matching with this criteria.
    Thanks,
    Guy

  • Oracle query help

    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.8.0 - Production
    Report Builder 10.1.2.0.2
    ORACLE Server Release 10.1.0.4.2
    Oracle Procedure Builder 10.1.2.0.2
    Oracle ORACLE PL/SQL V10.1.0.4.2 - Production
    Oracle CORE    10.1.0.4.0    Production
    Oracle Tools Integration Services 10.1.2.0.2
    Oracle Tools Common Area 10.1.2.0.2
    Oracle Toolkit 2 for Windows 32-bit platforms 10.1.2.0.2
    Resource Object Store 10.1.2.0.2
    Oracle Help 10.1.2.0.2
    Oracle Sqlmgr 10.1.2.0.2
    Oracle Query Builder 10.1.2.0.2 - Production
    PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
    Oracle ZRC 10.1.2.0.2
    Oracle XML Developers Kit 10.1.0.4.2 - Production
    Oracle Virtual Graphics System 10.1.2.0.2
    Oracle Image 10.1.2.0.2
    Oracle Multimedia Widget 10.1.2.0.2
    Oracle Tools GUI Utilities 10.1.2.0.2
    I have enclosed sample data and also table structure. I need help in getting the query.
    select dept_id,proc_code,override_goal,goal_override_date
      from table2
    where goal_override_date between '02-jan-2014' and '11-jan-2014'
       and dept_id = 10
       and proc_code = 'CP'
    select DEPT_ID, PROC_CODE, DAY_SUNDAY, DAY_MONDAY,
           DAY_TUESDAY, DAY_WEDNESDAY, DAY_THURSDAY,
             DAY_FRIDAY, DAY_SATURDAY
      from table1
    where dept_id =10
    and proc_code = 'CP'; 
    Table1  is kind of maintenance table.
    In Table2 values can be overridden.
    Requirement
    Check to see if there is data in table 2 for the date range . If table2 has no value then take value from table1 for that day the date falls into. Any more clarification please ask me.
    Sundays are all zeros.
    I want this data. and the sum for the date range.
    2-jan-2014  - 3
    3-jan-2014  - 3
    4-jan-2014  - 3
    5-jan-2014  - 0
    6-jan-2014  - 1
    7-jan-2014  - 3
    8-jan-2014  - 5
    9-jan-2014  - 5
    10-jan-2014 - 3
    11-jan-2014 - 3
    Sum for the date range has to be 29
    Sample table and data
    CREATE TABLE TABLE1
      DEPT_ID NUMBER NOT NULL,
      PROC_CODE VARCHAR2(2 BYTE) NOT NULL,
      DAY_SUNDAY NUMBER(4) NOT NULL,
      DAY_MONDAY NUMBER(4) NOT NULL,
      DAY_TUESDAY NUMBER(4) NOT NULL,
      DAY_WEDNESDAY NUMBER(4) NOT NULL,
      DAY_THURSDAY NUMBER(4) NOT NULL,
      DAY_FRIDAY NUMBER(4) NOT NULL,
      DAY_SATURDAY NUMBER(4) NOT NULL
    Insert into TABLE1
      (DEPT_ID, PROC_CODE, DAY_SUNDAY, DAY_MONDAY, DAY_TUESDAY,
      DAY_WEDNESDAY, DAY_THURSDAY, DAY_FRIDAY, DAY_SATURDAY)
    Values
      (10, 'CP', 0, 3, 3,
      3, 3, 3, 3);
    COMMIT;
    CREATE TABLE TABLE2
      DEPT_ID NUMBER NOT NULL,
      PROC_CODE VARCHAR2(2 BYTE) NOT NULL,
      OVERRIDE_GOAL NUMBER(4),
      GOAL_OVERRIDE_DATE DATE NOT NULL
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 1, TO_DATE('01/06/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 3, TO_DATE('01/07/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 5, TO_DATE('01/08/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 5, TO_DATE('01/09/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 3, TO_DATE('01/10/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 3, TO_DATE('01/11/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;
    Help is highly appreciated.

    SELECT dates,
           override_goal,
           SUM(override_goal) OVER()
           FROM(SELECT dates,
                       CASE WHEN EXISTS(SELECT 1
                                        FROM table2 t2
                                        WHERE t2.goal_override_date = qry1.dates
                                        AND t2.dept_id = 10
                                        AND t2.proc_code = 'CP')
                            THEN (SELECT override_goal
                                  FROM table2 t2
                                  WHERE t2.goal_override_date = qry1.dates
                                  AND t2.dept_id = 10
                                  AND t2.proc_code = 'CP')
                       ELSE (SELECT DECODE(days,'SUN',day_sunday,
                                                'MON',day_monday,
                                                'TUE',day_tuesday,
                                                'WED',day_wednesday,
                                                'THU',day_thursday,
                                                'FRI',day_friday,
                                                'SAT',day_saturday )
                              FROM table1)
                       END as override_goal
                FROM (SELECT in_dt1+(LEVEL-1) dates,
                             TO_CHAR(in_dt1+(LEVEL-1),'DY') days
                      FROM(SELECT TO_DATE(&from_date,'DD-MON-YYYY') in_dt1,
                                  TO_DATE(&to_date,'DD-MON-YYYY') in_dt2
                                 FROM dual)
                      CONNECT BY LEVEL <= (in_dt2 - in_dt1)+1) qry1);
    Now run the query it will prompt you for the inputs. You can pass the date values and check the result. Otherwise replace &from_date,&to_date with user inputs

  • Audit Trail on R12.1 (shadow table concept)

    I want to enable Audit Trail at table (column) level. Though I got response from Oracle Support but at present I am stuck on particular error. Here are the steps which I followed:
    1. Apply latest Patch 12860752:R12.FND.B - Latest Audit Trail Fixes for post 12.1.3.
    2. Enable Audit Trail on a table : I have set this for "PER_PEOPLE_F" tables of HR module
    a. (R)System Administrator, (N) Profile -> System
    Query Profile: 'AuditTrail:Activate'. Click FIND
    Set it to 'Yes' at Site level.
    b) Enable Audit Installations (HR)
    -- Got System Admin: Security:AuditTrail:Install
    -- Enable Audit Installation for HR
    c) Define Audit tables and desired columns.
    -- Got System Admin: Security: Audit Trail: Tables
    -- Query for user table name 'PER_PEOPLE_F' and add columns on which enable trail
    d) Define an Audit Group and associated tables
    -- Got System Admin: Security: Audit Trail: Groups
    -- Create Audit group for table defined in 'C'
    e) Run Concurrent program 'AuditTrail Report for Audit Group Validation' with parameter as that of Audit Group.
    f) Define an Industry Template contain Audit Group
    -- Got System Admin: Security: Audit Trail Reporting: Audit Industry Template
    g) Run concurrent program "AuditTrail Update Tables".
    Now, I am facing challenge at point (g), as, the concurrent request "AuditTrail Update Tables" is completing with error.
    And I am not able to proceed further.
    ****Log file shows as:****
    Application Object Library: Version : 12.0.0
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    FNDATUPD module: AuditTrail Update Tables
    Current system time is 02-APR-2013 01:02:32
    ----->Expand Rows
    INSERT INTO FND_AUDIT_COLUMNS (TABLE_APP_ID, TABLE_ID,COLUMN_ID,STATE,SEQUENCE_ID, SCHEMA_ID, LAST_UPDATE_DATE,LAST_UPDATED_BY, LAST_UPDATE_LOGIN,CREATED_BY,CREATION_DATE) VALUES ( 800, 53506, 135906, 'P', -1, 900, SYSDATE,0,0,0,SYSDATE)
    UPDATE FND_AUDIT_TABLES T SET T.STATE = 'P' WHERE T.TABLE_APP_ID = 800 AND T.TABLE_ID = 53506
    commit
    commit
    DELETE FROM FND_AUDIT_TABLES WHERE STATE = 'X'
    DELETE FROM FND_AUDIT_COLUMNS C WHERE C.STATE = 'P' AND NOT EXISTS (SELECT NULL FROM FND_AUDIT_TABLES T WHERE T.TABLE_APP_ID = C.TABLE_APP_ID AND T.TABLE_ID = C.TABLE_ID AND T.STATE !='X')
    ----->Update Pending Columns
    ----->Adding ROW_KEY
    **Starts**02-APR-2013 01:02:54
    **Ends**02-APR-2013 01:02:57
    ----->Alter Shadow Table
    ALTER TABLE PER_ALL_PEOPLE_F_A ADD (FULL_NAME VARCHAR2(240))
    ALTER TABLE PER_ALL_PEOPLE_F_A ADD (FULL_NAME VARCHAR2(240))
    commit
    commit
    UPDATE FND_AUDIT_COLUMNS SET STATE = 'N' , SEQUENCE_ID = 5 WHERE TABLE_APP_ID = 800 AND SCHEMA_ID = 900 AND TABLE_ID = 53506 AND COLUMN_ID = 135906 AND STATE = 'P'
    commit
    commit
    ----->Drop Triggers
    DROP TRIGGER PER_ALL_PEOPLE_F_AI
    DROP TRIGGER PER_ALL_PEOPLE_F_AI
    commit
    DROP PROCEDURE PER_ALL_PEOPLE_F_AIP
    DROP PROCEDURE PER_ALL_PEOPLE_F_AIP
    commit
    DROP TRIGGER PER_ALL_PEOPLE_F_AD
    DROP TRIGGER PER_ALL_PEOPLE_F_AD
    commit
    DROP PROCEDURE PER_ALL_PEOPLE_F_ADP
    DROP PROCEDURE PER_ALL_PEOPLE_F_ADP
    commit
    DROP TRIGGER PER_ALL_PEOPLE_F_AU
    DROP TRIGGER PER_ALL_PEOPLE_F_AU
    commit
    DROP PROCEDURE PER_ALL_PEOPLE_F_AUP
    DROP PROCEDURE PER_ALL_PEOPLE_F_AUP
    commit
    DROP TRIGGER PER_ALL_PEOPLE_F_AC
    DROP TRIGGER PER_ALL_PEOPLE_F_AC
    commit
    DROP TRIGGER PER_ALL_PEOPLE_F_AH
    DROP TRIGGER PER_ALL_PEOPLE_F_AH
    commit
    DROP TRIGGER PER_ALL_PEOPLE_F_AT
    DROP TRIGGER PER_ALL_PEOPLE_F_AT
    commit
    ----->Create Standard Triggers
    CREATE OR REPLACE PROCEDURE
    PER_ALL_PEOPLE_F_AIP(A0 IN DATE,A1 IN DATE,A2 IN NUMBER,JB IN DATE,JC IN VARCHAR2,JD IN VARCHAR2,E0 IN DATE,E1 IN DATE,E2 IN NUMBER,RB IN DATE,RC IN VARCHAR2,RD IN VARCHAR2 )
    AS
    ROWKEY number;
    NXT number;
    CMT number;
    NUSER varchar2(100);
    nls_date_fmt VARCHAR2(40);
    BEGIN
    select value into nls_date_fmt from v$NLS_PARAMETERS where parameter='NLS_DATE_FORMAT';
    execute IMMEDIATE 'alter session set nls_date_format="MM/DD/YYYY HH24:MI:SS"';
    NXT:=FND_AUDIT_SEQ_PKG.NXT;
    CMT:=FND_AUDIT_SEQ_PKG.CMT;
    ROWKEY:=(TO_NUMBER(TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'))*100000 MOD(NXT,100000)) * 100000 USERENV('SESSIONID');
    NUSER:=FND_AUDIT_SEQ_PKG.USER_NAME;
    INSERT INTO PER_ALL_PEOPLE_F_A
    VALUES(SYSDATE,'I',NUSER,NULL,USERENV('SESSIONID'),NXT,CMT,ROWKEY,E0,E1,E2,NULL,NULL,NULL);
    execute IMMEDIATE 'alter session set nls_date_format="'||nls_date_fmt||'"';
    END PER_ALL_PEOPLE_F_AIP;
    commit
    CREATE OR REPLACE PROCEDURE
    PER_ALL_PEOPLE_F_AUP (A0 IN DATE,A1 IN DATE,A2 IN NUMBER,JB IN DATE,JC IN VARCHAR2,JD IN VARCHAR2,E0 IN DATE,E1 IN DATE,E2 IN NUMBER,RB IN DATE,RC IN VARCHAR2,RD IN VARCHAR2)
    AS
    NXT NUMBER;
    CMT NUMBER;
    NUSER varchar2(100);
    newtransaction_TYPE VARCHAR2(1);
    newTRUE_NULLS VARCHAR2(250);
    tmpPRIMCHANGE NUMBER;
    nls_date_fmt VARCHAR2(40);
    I0 DATE;
    I1 DATE;
    I2 NUMBER(10,0);
    YB DATE;
    YC VARCHAR2(150);
    YD VARCHAR2(240);
    BEGIN
    select value into nls_date_fmt from v$NLS_PARAMETERS where parameter='NLS_DATE_FORMAT';
    execute IMMEDIATE 'alter session set nls_date_format="MM/DD/YYYY HH24:MI:SS"';
    NUSER:=FND_AUDIT_SEQ_PKG.USER_NAME;
    SELECT 0+decode(E0,A0,0,1)+decode(E1,A1,0,1)+decode(E2,A2,0,1) into tmpPRIMCHANGE FROM SYS.DUAL;
    IF tmpPRIMCHANGE>=1 THEN
    SELECT decode(A0,NULL,'Y','N')
    ||decode(A1,NULL,'Y','N')
    ||decode(A2,NULL,'Y','N')
    ||decode(JB,NULL,'Y','N')
    ||decode(JC,NULL,'Y','N')
    ||decode(JD,NULL,'Y','N') INTO newTRUE_NULLS FROM SYS.DUAL;
    IF(newTRUE_NULLS='NNNNNN')THEN
    newTRUE_NULLS:=NULL;END IF;
    NXT:=FND_AUDIT_SEQ_PKG.NXT;
    CMT:=FND_AUDIT_SEQ_PKG.CMT;
    INSERT INTO PER_ALL_PEOPLE_F_A
    VALUES(SYSDATE,'D',NUSER,newTRUE_NULLS,
    USERENV('SESSIONID'),NXT,CMT,(TO_NUMBER(TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'))*100000+MOD(NXT,100000)) * 100000 + USERENV('SESSIONID'),
    A0,A1,A2,JB,JC,JD);
    NXT:=FND_AUDIT_SEQ_PKG.NXT;
    CMT:=FND_AUDIT_SEQ_PKG.CMT;
    NUSER:=FND_AUDIT_SEQ_PKG.USER_NAME;
    INSERT INTO PER_ALL_PEOPLE_F_A
    VALUES(SYSDATE,'I',NUSER,NULL,USERENV('SESSIONID'),NXT,CMT,(TO_NUMBER(TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'))*100000+MOD(NXT,100000)) * 100000 + USERENV('SESSIONID'),
    E0,E1,E2,NULL,NULL,NULL);
    ELSE
    SELECT DECODE(JB,RB,NULL,JB)INTO YB FROM SYS.DUAL;
    SELECT DECODE(JC,RC,NULL,JC)INTO YC FROM SYS.DUAL;
    SELECT DECODE(JD,RD,NULL,JD)INTO YD FROM SYS.DUAL;
    SELECT decode(A0,NULL,decode(E0,NULL,'N','Y'),'N')
    ||decode(A1,NULL,decode(E1,NULL,'N','Y'),'N')
    ||decode(A2,NULL,decode(E2,NULL,'N','Y'),'N')
    ||decode(JB,NULL,decode(RB,NULL,'N','Y'),'N')
    ||decode(JC,NULL,decode(RC,NULL,'N','Y'),'N')
    ||decode(JD,NULL,decode(RD,NULL,'N','Y'),'N') INTO newTRUE_NULLS FROM SYS.DUAL;
    IF(newTRUE_NULLS='NNNNNN')THEN newTRUE_NULLS:=NULL;END IF;
    IF(newTRUE_NULLS is not NULL)OR
    YB IS NOT NULL OR
    YC IS NOT NULL OR
    YD IS NOT NULL THEN
    NXT:=FND_AUDIT_SEQ_PKG.NXT;
    CMT:=FND_AUDIT_SEQ_PKG.CMT;
    INSERT INTO PER_ALL_PEOPLE_F_A
    VALUES(SYSDATE,'U',NUSER,newTRUE_NULLS,USERENV('SESSIONID'),NXT,CMT,(TO_NUMBER(TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'))*100000+MOD(NXT,100000)) * 100000 + USERENV('SESSIONID'),
    E0,E1,E2,YB,YC,YD);
    END IF;
    END IF;
    execute IMMEDIATE 'alter session set nls_date_format="'||nls_date_fmt||'"';
    END PER_ALL_PEOPLE_F_AUP;
    commit
    CREATE OR REPLACE PROCEDURE
    PER_ALL_PEOPLE_F_ADP(A0 IN DATE,A1 IN DATE,A2 IN NUMBER,JB IN DATE,JC IN VARCHAR2,JD IN VARCHAR2,E0 IN DATE,E1 IN DATE,E2 IN NUMBER,RB IN DATE,RC IN VARCHAR2,RD IN VARCHAR2)
    AS
    NXT NUMBER;
    CMT NUMBER;
    NUSER varchar2(100);
    newTRUE_NULLS VARCHAR2(250);
    nls_date_fmt VARCHAR2(40);
    BEGIN
    select value into nls_date_fmt from v$NLS_PARAMETERS where parameter='NLS_DATE_FORMAT';
    execute IMMEDIATE 'alter session set nls_date_format="MM/DD/YYYY HH24:MI:SS"';
    NXT:=FND_AUDIT_SEQ_PKG.NXT;
    CMT:=FND_AUDIT_SEQ_PKG.CMT;
    NUSER:=FND_AUDIT_SEQ_PKG.USER_NAME;
    SELECT decode(A0,NULL,'Y','N')
    ||decode(A1,NULL,'Y','N')
    ||decode(A2,NULL,'Y','N')
    ||decode(JB,NULL,'Y','N')
    ||decode(JC,NULL,'Y','N')
    ||decode(JD,NULL,'Y','N') INTO newTRUE_NULLS FROM SYS.DUAL;
    IF(newTRUE_NULLS='NNNNNN') THEN
    newTRUE_NULLS:= NULL;
    END IF;
    INSERT INTO PER_ALL_PEOPLE_F_A
    VALUES(SYSDATE,'D',NUSER,newTRUE_NULLS,
    USERENV('SESSIONID'),NXT,CMT,(TO_NUMBER(TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'))*100000+MOD(NXT,100000)) * 100000 + USERENV('SESSIONID'),
    A0,A1,A2,JB,JC,JD);
    execute IMMEDIATE 'alter session set nls_date_format="'||nls_date_fmt||'"';
    END PER_ALL_PEOPLE_F_ADP;
    commit
    CREATE OR REPLACE TRIGGER PER_ALL_PEOPLE_F_AH BEFORE INSERT ON PER_ALL_PEOPLE_F BEGIN IF fnd_global.audit_active THEN fnd_audit_pkg.audit_on := TRUE;ELSE fnd_audit_pkg.audit_on := FALSE;END IF;END;
    commit
    CREATE OR REPLACE TRIGGER PER_ALL_PEOPLE_F_AI AFTER INSERT ON PER_ALL_PEOPLE_F FOR EACH ROW BEGIN IF fnd_audit_pkg.audit_on THEN PER_ALL_PEOPLE_F_AIP(:old.EFFECTIVE_START_DATE,:old.EFFECTIVE_END_DATE,:old.PERSON_ID,:old.DATE_OF_BIRTH,:old.FIRST_NAME,:old.FULL_NAME,:new.EFFECTIVE_START_DATE,:new.EFFECTIVE_END_DATE,:new.PERSON_ID,:new.DATE_OF_BIRTH,:new.FIRST_NAME,:new.FULL_NAME);END IF;END;
    commit
    CREATE OR REPLACE TRIGGER PER_ALL_PEOPLE_F_AT BEFORE UPDATE OF EFFECTIVE_START_DATE,EFFECTIVE_END_DATE,PERSON_ID,DATE_OF_BIRTH,FIRST_NAME,FULL_NAME ON PER_ALL_PEOPLE_F BEGIN IF fnd_global.audit_active THEN fnd_audit_pkg.audit_on := TRUE;ELSE fnd_audit_pkg.audit_on := FALSE;END IF;END;
    commit
    CREATE OR REPLACE TRIGGER PER_ALL_PEOPLE_F_AU AFTER UPDATE OF EFFECTIVE_START_DATE,EFFECTIVE_END_DATE,PERSON_ID,DATE_OF_BIRTH,FIRST_NAME,FULL_NAME ON PER_ALL_PEOPLE_F FOR EACH ROW BEGIN IF fnd_audit_pkg.audit_on THEN PER_ALL_PEOPLE_F_AUP(:old.EFFECTIVE_START_DATE,:old.EFFECTIVE_END_DATE,:old.PERSON_ID,:old.DATE_OF_BIRTH,:old.FIRST_NAME,:old.FULL_NAME,:new.EFFECTIVE_START_DATE,:new.EFFECTIVE_END_DATE,:new.PERSON_ID,:new.DATE_OF_BIRTH,:new.FIRST_NAME,:new.FULL_NAME);END IF;END;
    commit
    CREATE OR REPLACE TRIGGER PER_ALL_PEOPLE_F_AC BEFORE DELETE ON PER_ALL_PEOPLE_F BEGIN IF fnd_global.audit_active THEN fnd_audit_pkg.audit_on := TRUE;ELSE fnd_audit_pkg.audit_on := FALSE;END IF;END;
    commit
    CREATE OR REPLACE TRIGGER PER_ALL_PEOPLE_F_AD AFTER DELETE ON PER_ALL_PEOPLE_F FOR EACH ROW BEGIN IF fnd_audit_pkg.audit_on THEN PER_ALL_PEOPLE_F_ADP(:old.EFFECTIVE_START_DATE,:old.EFFECTIVE_END_DATE,:old.PERSON_ID,:old.DATE_OF_BIRTH,:old.FIRST_NAME,:old.FULL_NAME,:new.EFFECTIVE_START_DATE,:new.EFFECTIVE_END_DATE,:new.PERSON_ID,:new.DATE_OF_BIRTH,:new.FIRST_NAME,:new.FULL_NAME);END IF;END;
    commit
    ----->Create Views
    VIEW PER_ALL_PEOPLE_F_AV1
    commit
    VIEW PER_ALL_PEOPLE_F_AV2
    commit
    VIEW PER_ALL_PEOPLE_F_AV3
    commit
    VIEW PER_ALL_PEOPLE_F_AV4
    commit
    VIEW PER_ALL_PEOPLE_F_AC1
    -->EFFECTIVE_START_DATE
    -->EFFECTIVE_END_DATE
    -->PERSON_ID
    -->DATE_OF_BIRTH
    -->FIRST_NAME
    -->FULL_NAME
    commit
    UPDATE FND_AUDIT_TABLES T SET T.STATE = 'E' WHERE T.TABLE_ID = 53506 AND T.TABLE_APP_ID = 800 AND NOT EXISTS ( SELECT NULL FROM FND_AUDIT_COLUMNS C WHERE C.TABLE_APP_ID = T.TABLE_APP_ID AND C.TABLE_ID = T.TABLE_ID AND C.STATE = 'P' AND C.SCHEMA_ID != -1)
    commit
    commit
    ----->Delete Invalid Columns
    ----->Drop Triggers
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AI
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AI
    commit
    DROP PROCEDURE FND_PROFILE_OPTION_VALUE_AIP
    DROP PROCEDURE FND_PROFILE_OPTION_VALUE_AIP
    commit
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AD
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AD
    commit
    DROP PROCEDURE FND_PROFILE_OPTION_VALUE_ADP
    DROP PROCEDURE FND_PROFILE_OPTION_VALUE_ADP
    commit
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AU
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AU
    commit
    DROP PROCEDURE FND_PROFILE_OPTION_VALUE_AUP
    DROP PROCEDURE FND_PROFILE_OPTION_VALUE_AUP
    commit
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AC
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AC
    commit
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AH
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AH
    commit
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AT
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AT
    commit
    Cause: Table name is FND_PROFILE_OPTION_VALUE_A.
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV1
    commit
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV2
    commit
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV3
    commit
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV4
    commit
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV5
    commit
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV6
    commit
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV7
    commit
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV8
    commit
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV9
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV10
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV11
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV12
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV13
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV14
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV15
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV16
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV17
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV18
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV19
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV20
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV21
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV22
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV23
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV24
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV25
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV26
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV27
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV28
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV29
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV30
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV31
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV32
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV33
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV34
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV35
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV36
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV37
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV38
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV39
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV40
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV41
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV42
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV43
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV44
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV45
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV46
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV47
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV48
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV49
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV50
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV51
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV52
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV53
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV54
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV55
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV56
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV57
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV58
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV59
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV60
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV61
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV62
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV63
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV64
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV65
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV66
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV67
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV68
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV69
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV70
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV71
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV72
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV73
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV74
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV75
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV76
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV77
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV78
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV79
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV80
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV81
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV82
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV83
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV84
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV85
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV86
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV87
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV88
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV89
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV90
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV91
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV92
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV93
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV94
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV95
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV96
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV97
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV98
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV99
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV100
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AC1
    commit
    ----->Drop Shadow Table
    DROP TABLE FND_PROFILE_OPTION_VALUE_A
    ORA-00942: table or view does not exist
    Error in fdasql, continuing...
    /oracleferp/FERP/APPS/apps_st/appl/fnd/12.0.0/bin/FNDATUPD
    Program was terminated by signal 11
    Executing request completion options...
    Output file size:
    0
    Output is not being printed because:
    The print option has been disabled for this report.
    Finished executing request completion options.
    Concurrent request completed
    Current system time is 02-APR-2013 01:03:56
    Any comments/ suggestions in context of the Audit Trail query are heartily welcome !!
    Regards,
    S.Malik

    Dear Hussein,
    I followed the doc id: 727770.1 and as per note, I deleted the previous Audit data.
    And enabled the audit trail as per document to the similar table as mentioned in the doc. with similar steps. But still the concurrent request "AuditTrail Update Tables" is completing with error. Please find below the log file for the same:
    Application Object Library: Version : 12.0.0
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    FNDATUPD module: AuditTrail Update Tables
    Current system time is 02-APR-2013 04:19:23
    ----->Expand Rows
    INSERT INTO FND_AUDIT_COLUMNS (TABLE_APP_ID, TABLE_ID,COLUMN_ID,STATE,SEQUENCE_ID, SCHEMA_ID, LAST_UPDATE_DATE,LAST_UPDATED_BY, LAST_UPDATE_LOGIN,CREATED_BY,CREATION_DATE) VALUES ( 810, 55079, 158785, 'P', -1, 900, SYSDATE,0,0,0,SYSDATE)
    UPDATE FND_AUDIT_TABLES T SET T.STATE = 'P' WHERE T.TABLE_APP_ID = 810 AND T.TABLE_ID = 55079
    commit
    INSERT INTO FND_AUDIT_COLUMNS (TABLE_APP_ID, TABLE_ID,COLUMN_ID,STATE,SEQUENCE_ID, SCHEMA_ID, LAST_UPDATE_DATE,LAST_UPDATED_BY, LAST_UPDATE_LOGIN,CREATED_BY,CREATION_DATE) VALUES ( 810, 55079, 158787, 'P', -1, 900, SYSDATE,0,0,0,SYSDATE)
    UPDATE FND_AUDIT_TABLES T SET T.STATE = 'P' WHERE T.TABLE_APP_ID = 810 AND T.TABLE_ID = 55079
    commit
    INSERT INTO FND_AUDIT_COLUMNS (TABLE_APP_ID, TABLE_ID,COLUMN_ID,STATE,SEQUENCE_ID, SCHEMA_ID, LAST_UPDATE_DATE,LAST_UPDATED_BY, LAST_UPDATE_LOGIN,CREATED_BY,CREATION_DATE) VALUES ( 810, 55079, 158786, 'P', -1, 900, SYSDATE,0,0,0,SYSDATE)
    UPDATE FND_AUDIT_TABLES T SET T.STATE = 'P' WHERE T.TABLE_APP_ID = 810 AND T.TABLE_ID = 55079
    commit
    INSERT INTO FND_AUDIT_COLUMNS (TABLE_APP_ID, TABLE_ID,COLUMN_ID,STATE,SEQUENCE_ID, SCHEMA_ID, LAST_UPDATE_DATE,LAST_UPDATED_BY, LAST_UPDATE_LOGIN,CREATED_BY,CREATION_DATE) VALUES ( 810, 55079, 158790, 'P', -1, 900, SYSDATE,0,0,0,SYSDATE)
    UPDATE FND_AUDIT_TABLES T SET T.STATE = 'P' WHERE T.TABLE_APP_ID = 810 AND T.TABLE_ID = 55079
    commit
    commit
    DELETE FROM FND_AUDIT_TABLES WHERE STATE = 'X'
    DELETE FROM FND_AUDIT_COLUMNS C WHERE C.STATE = 'P' AND NOT EXISTS (SELECT NULL FROM FND_AUDIT_TABLES T WHERE T.TABLE_APP_ID = C.TABLE_APP_ID AND T.TABLE_ID = C.TABLE_ID AND T.STATE !='X')
    ----->Create New Table
    CREATE TABLE OTA_DELEGATE_BOOKINGS_A (AUDIT_TIMESTAMP DATE NOT NULL, AUDIT_TRANSACTION_TYPE VARCHAR(1) NOT NULL, AUDIT_USER_NAME VARCHAR2(100) NOT NULL, AUDIT_TRUE_NULLS VARCHAR2(250), AUDIT_SESSION_ID NUMBER NOT NULL, AUDIT_SEQUENCE_ID NUMBER NOT NULL,AUDIT_COMMIT_ID NUMBER NOT NULL, ROW_KEY NUMBER )
    commit
    GRANT ALL ON OTA_DELEGATE_BOOKINGS_A to APPS
    GRANT ALL ON OTA_DELEGATE_BOOKINGS_A to APPS
    commit
    CREATE SYNONYM OTA_DELEGATE_BOOKINGS_A for OTA.OTA_DELEGATE_BOOKINGS_A
    CREATE SYNONYM OTA_DELEGATE_BOOKINGS_A for OTA.OTA_DELEGATE_BOOKINGS_A
    commit
    ----->Adding ROW_KEY
    **Starts**02-APR-2013 04:19:32
    **Ends**02-APR-2013 04:19:34
    ----->Alter Shadow Table
    ALTER TABLE OTA_DELEGATE_BOOKINGS_A ADD (BOOKING_ID NUMBER(9,0))
    ALTER TABLE OTA_DELEGATE_BOOKINGS_A ADD (BOOKING_ID NUMBER(9,0))
    commit
    commit
    DELETE FROM FND_AUDIT_COLUMNS C WHERE C.TABLE_APP_ID= 810 AND C.TABLE_ID = 55079 AND C.COLUMN_ID = 158785 AND C.SCHEMA_ID = 900
    INSERT INTO FND_AUDIT_COLUMNS (TABLE_APP_ID,TABLE_ID,COLUMN_ID,STATE,SEQUENCE_ID,SCHEMA_ID,LAST_UPDATE_DATE,LAST_UPDATED_BY,LAST_UPDATE_LOGIN,CREATED_BY,CREATION_DATE) VALUES ( 810, 55079, 158785, 'K', 0, 900, SYSDATE,0,0,0,SYSDATE)
    commit
    ----->Update Pending Columns
    ----->Adding ROW_KEY
    **Starts**02-APR-2013 04:19:36
    **Ends**02-APR-2013 04:19:36
    ----->Alter Shadow Table
    ALTER TABLE OTA_DELEGATE_BOOKINGS_A ADD (BOOKING_STATUS_TYPE_ID NUMBER(9,0))
    ALTER TABLE OTA_DELEGATE_BOOKINGS_A ADD (BOOKING_STATUS_TYPE_ID NUMBER(9,0))
    commit
    commit
    UPDATE FND_AUDIT_COLUMNS SET STATE = 'N' , SEQUENCE_ID = 1 WHERE TABLE_APP_ID = 810 AND SCHEMA_ID = 900 AND TABLE_ID = 55079 AND COLUMN_ID = 158786 AND STATE = 'P'
    commit
    ----->Adding ROW_KEY
    **Starts**02-APR-2013 04:19:37
    **Ends**02-APR-2013 04:19:37
    ----->Alter Shadow Table
    ALTER TABLE OTA_DELEGATE_BOOKINGS_A ADD (DELEGATE_PERSON_ID NUMBER(10,0))
    ALTER TABLE OTA_DELEGATE_BOOKINGS_A ADD (DELEGATE_PERSON_ID NUMBER(10,0))
    commit
    commit
    UPDATE FND_AUDIT_COLUMNS SET STATE = 'N' , SEQUENCE_ID = 2 WHERE TABLE_APP_ID = 810 AND SCHEMA_ID = 900 AND TABLE_ID = 55079 AND COLUMN_ID = 158787 AND STATE = 'P'
    commit
    ----->Adding ROW_KEY
    **Starts**02-APR-2013 04:19:37
    **Ends**02-APR-2013 04:19:37
    ----->Alter Shadow Table
    ALTER TABLE OTA_DELEGATE_BOOKINGS_A ADD (EVENT_ID NUMBER(9,0))
    ALTER TABLE OTA_DELEGATE_BOOKINGS_A ADD (EVENT_ID NUMBER(9,0))
    commit
    commit
    UPDATE FND_AUDIT_COLUMNS SET STATE = 'N' , SEQUENCE_ID = 3 WHERE TABLE_APP_ID = 810 AND SCHEMA_ID = 900 AND TABLE_ID = 55079 AND COLUMN_ID = 158790 AND STATE = 'P'
    commit
    commit
    ----->Drop Triggers
    DROP TRIGGER OTA_DELEGATE_BOOKINGS_AI
    DROP TRIGGER OTA_DELEGATE_BOOKINGS_AI
    ORA-04080: trigger 'OTA_DELEGATE_BOOKINGS_AI' does not exist
    DROP PROCEDURE OTA_DELEGATE_BOOKINGS_AIP
    DROP PROCEDURE OTA_DELEGATE_BOOKINGS_AIP
    ORA-04043: object OTA_DELEGATE_BOOKINGS_AIP does not exist
    DROP TRIGGER OTA_DELEGATE_BOOKINGS_AD
    DROP TRIGGER OTA_DELEGATE_BOOKINGS_AD
    ORA-04080: trigger 'OTA_DELEGATE_BOOKINGS_AD' does not exist
    DROP PROCEDURE OTA_DELEGATE_BOOKINGS_ADP
    DROP PROCEDURE OTA_DELEGATE_BOOKINGS_ADP
    ORA-04043: object OTA_DELEGATE_BOOKINGS_ADP does not exist
    DROP TRIGGER OTA_DELEGATE_BOOKINGS_AU
    DROP TRIGGER OTA_DELEGATE_BOOKINGS_AU
    ORA-04080: trigger 'OTA_DELEGATE_BOOKINGS_AU' does not exist
    DROP PROCEDURE OTA_DELEGATE_BOOKINGS_AUP
    DROP PROCEDURE OTA_DELEGATE_BOOKINGS_AUP
    ORA-04043: object OTA_DELEGATE_BOOKINGS_AUP does not exist
    DROP TRIGGER OTA_DELEGATE_BOOKINGS_AC
    DROP TRIGGER OTA_DELEGATE_BOOKINGS_AC
    ORA-04080: trigger 'OTA_DELEGATE_BOOKINGS_AC' does not exist
    DROP TRIGGER OTA_DELEGATE_BOOKINGS_AH
    DROP TRIGGER OTA_DELEGATE_BOOKINGS_AH
    ORA-04080: trigger 'OTA_DELEGATE_BOOKINGS_AH' does not exist
    DROP TRIGGER OTA_DELEGATE_BOOKINGS_AT
    DROP TRIGGER OTA_DELEGATE_BOOKINGS_AT
    ORA-04080: trigger 'OTA_DELEGATE_BOOKINGS_AT' does not exist
    ----->Create Standard Triggers
    CREATE OR REPLACE PROCEDURE
    OTA_DELEGATE_BOOKINGS_AIP(A0 IN NUMBER,JB IN NUMBER,JC IN NUMBER,JD IN NUMBER,E0 IN NUMBER,RB IN NUMBER,RC IN NUMBER,RD IN NUMBER )
    AS
    ROWKEY number;
    NXT number;
    CMT number;
    NUSER varchar2(100);
    nls_date_fmt VARCHAR2(40);
    BEGIN
    select value into nls_date_fmt from v$NLS_PARAMETERS where parameter='NLS_DATE_FORMAT';
    execute IMMEDIATE 'alter session set nls_date_format="MM/DD/YYYY HH24:MI:SS"';
    NXT:=FND_AUDIT_SEQ_PKG.NXT;
    CMT:=FND_AUDIT_SEQ_PKG.CMT;
    ROWKEY:=(TO_NUMBER(TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'))*100000 MOD(NXT,100000)) * 100000 USERENV('SESSIONID');
    NUSER:=FND_AUDIT_SEQ_PKG.USER_NAME;
    INSERT INTO OTA_DELEGATE_BOOKINGS_A
    VALUES(SYSDATE,'I',NUSER,NULL,USERENV('SESSIONID'),NXT,CMT,ROWKEY,E0,NULL,NULL,NULL);
    execute IMMEDIATE 'alter session set nls_date_format="'||nls_date_fmt||'"';
    END OTA_DELEGATE_BOOKINGS_AIP;
    commit
    CREATE OR REPLACE PROCEDURE
    OTA_DELEGATE_BOOKINGS_AUP (A0 IN NUMBER,JB IN NUMBER,JC IN NUMBER,JD IN NUMBER,E0 IN NUMBER,RB IN NUMBER,RC IN NUMBER,RD IN NUMBER)
    AS
    NXT NUMBER;
    CMT NUMBER;
    NUSER varchar2(100);
    newtransaction_TYPE VARCHAR2(1);
    newTRUE_NULLS VARCHAR2(250);
    tmpPRIMCHANGE NUMBER;
    nls_date_fmt VARCHAR2(40);
    I0 NUMBER(9,0);
    YB NUMBER(9,0);
    YC NUMBER(10,0);
    YD NUMBER(9,0);
    BEGIN
    select value into nls_date_fmt from v$NLS_PARAMETERS where parameter='NLS_DATE_FORMAT';
    execute IMMEDIATE 'alter session set nls_date_format="MM/DD/YYYY HH24:MI:SS"';
    NUSER:=FND_AUDIT_SEQ_PKG.USER_NAME;
    SELECT 0+decode(E0,A0,0,1) into tmpPRIMCHANGE FROM SYS.DUAL;
    IF tmpPRIMCHANGE>=1 THEN
    SELECT decode(A0,NULL,'Y','N')
    ||decode(JB,NULL,'Y','N')
    ||decode(JC,NULL,'Y','N')
    ||decode(JD,NULL,'Y','N') INTO newTRUE_NULLS FROM SYS.DUAL;
    IF(newTRUE_NULLS='NNNN')THEN
    newTRUE_NULLS:=NULL;END IF;
    NXT:=FND_AUDIT_SEQ_PKG.NXT;
    CMT:=FND_AUDIT_SEQ_PKG.CMT;
    INSERT INTO OTA_DELEGATE_BOOKINGS_A
    VALUES(SYSDATE,'D',NUSER,newTRUE_NULLS,
    USERENV('SESSIONID'),NXT,CMT,(TO_NUMBER(TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'))*100000+MOD(NXT,100000)) * 100000 + USERENV('SESSIONID'),
    A0,JB,JC,JD);
    NXT:=FND_AUDIT_SEQ_PKG.NXT;
    CMT:=FND_AUDIT_SEQ_PKG.CMT;
    NUSER:=FND_AUDIT_SEQ_PKG.USER_NAME;
    INSERT INTO OTA_DELEGATE_BOOKINGS_A
    VALUES(SYSDATE,'I',NUSER,NULL,USERENV('SESSIONID'),NXT,CMT,(TO_NUMBER(TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'))*100000+MOD(NXT,100000)) * 100000 + USERENV('SESSIONID'),
    E0,NULL,NULL,NULL);
    ELSE
    SELECT DECODE(JB,RB,NULL,JB)INTO YB FROM SYS.DUAL;
    SELECT DECODE(JC,RC,NULL,JC)INTO YC FROM SYS.DUAL;
    SELECT DECODE(JD,RD,NULL,JD)INTO YD FROM SYS.DUAL;
    SELECT decode(A0,NULL,decode(E0,NULL,'N','Y'),'N')
    ||decode(JB,NULL,decode(RB,NULL,'N','Y'),'N')
    ||decode(JC,NULL,decode(RC,NULL,'N','Y'),'N')
    ||decode(JD,NULL,decode(RD,NULL,'N','Y'),'N') INTO newTRUE_NULLS FROM SYS.DUAL;
    IF(newTRUE_NULLS='NNNN')THEN newTRUE_NULLS:=NULL;END IF;
    IF(newTRUE_NULLS is not NULL)OR
    YB IS NOT NULL OR
    YC IS NOT NULL OR
    YD IS NOT NULL THEN
    NXT:=FND_AUDIT_SEQ_PKG.NXT;
    CMT:=FND_AUDIT_SEQ_PKG.CMT;
    INSERT INTO OTA_DELEGATE_BOOKINGS_A
    VALUES(SYSDATE,'U',NUSER,newTRUE_NULLS,USERENV('SESSIONID'),NXT,CMT,(TO_NUMBER(TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'))*100000+MOD(NXT,100000)) * 100000 + USERENV('SESSIONID'),
    E0,YB,YC,YD);
    END IF;
    END IF;
    execute IMMEDIATE 'alter session set nls_date_format="'||nls_date_fmt||'"';
    END OTA_DELEGATE_BOOKINGS_AUP;
    commit
    CREATE OR REPLACE PROCEDURE
    OTA_DELEGATE_BOOKINGS_ADP(A0 IN NUMBER,JB IN NUMBER,JC IN NUMBER,JD IN NUMBER,E0 IN NUMBER,RB IN NUMBER,RC IN NUMBER,RD IN NUMBER)
    AS
    NXT NUMBER;
    CMT NUMBER;
    NUSER varchar2(100);
    newTRUE_NULLS VARCHAR2(250);
    nls_date_fmt VARCHAR2(40);
    BEGIN
    select value into nls_date_fmt from v$NLS_PARAMETERS where parameter='NLS_DATE_FORMAT';
    execute IMMEDIATE 'alter session set nls_date_format="MM/DD/YYYY HH24:MI:SS"';
    NXT:=FND_AUDIT_SEQ_PKG.NXT;
    CMT:=FND_AUDIT_SEQ_PKG.CMT;
    NUSER:=FND_AUDIT_SEQ_PKG.USER_NAME;
    SELECT decode(A0,NULL,'Y','N')
    ||decode(JB,NULL,'Y','N')
    ||decode(JC,NULL,'Y','N')
    ||decode(JD,NULL,'Y','N') INTO newTRUE_NULLS FROM SYS.DUAL;
    IF(newTRUE_NULLS='NNNN') THEN
    newTRUE_NULLS:= NULL;
    END IF;
    INSERT INTO OTA_DELEGATE_BOOKINGS_A
    VALUES(SYSDATE,'D',NUSER,newTRUE_NULLS,
    USERENV('SESSIONID'),NXT,CMT,(TO_NUMBER(TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'))*100000+MOD(NXT,100000)) * 100000 + USERENV('SESSIONID'),
    A0,JB,JC,JD);
    execute IMMEDIATE 'alter session set nls_date_format="'||nls_date_fmt||'"';
    END OTA_DELEGATE_BOOKINGS_ADP;
    commit
    CREATE OR REPLACE TRIGGER OTA_DELEGATE_BOOKINGS_AH BEFORE INSERT ON OTA_DELEGATE_BOOKINGS BEGIN IF fnd_global.audit_active THEN fnd_audit_pkg.audit_on := TRUE;ELSE fnd_audit_pkg.audit_on := FALSE;END IF;END;
    commit
    CREATE OR REPLACE TRIGGER OTA_DELEGATE_BOOKINGS_AI AFTER INSERT ON OTA_DELEGATE_BOOKINGS FOR EACH ROW BEGIN IF fnd_audit_pkg.audit_on THEN OTA_DELEGATE_BOOKINGS_AIP(:old.BOOKING_ID,:old.BOOKING_STATUS_TYPE_ID,:old.DELEGATE_PERSON_ID,:old.EVENT_ID,:new.BOOKING_ID,:new.BOOKING_STATUS_TYPE_ID,:new.DELEGATE_PERSON_ID,:new.EVENT_ID);END IF;END;
    commit
    CREATE OR REPLACE TRIGGER OTA_DELEGATE_BOOKINGS_AT BEFORE UPDATE OF BOOKING_ID,BOOKING_STATUS_TYPE_ID,DELEGATE_PERSON_ID,EVENT_ID ON OTA_DELEGATE_BOOKINGS BEGIN IF fnd_global.audit_active THEN fnd_audit_pkg.audit_on := TRUE;ELSE fnd_audit_pkg.audit_on := FALSE;END IF;END;
    commit
    CREATE OR REPLACE TRIGGER OTA_DELEGATE_BOOKINGS_AU AFTER UPDATE OF BOOKING_ID,BOOKING_STATUS_TYPE_ID,DELEGATE_PERSON_ID,EVENT_ID ON OTA_DELEGATE_BOOKINGS FOR EACH ROW BEGIN IF fnd_audit_pkg.audit_on THEN OTA_DELEGATE_BOOKINGS_AUP(:old.BOOKING_ID,:old.BOOKING_STATUS_TYPE_ID,:old.DELEGATE_PERSON_ID,:old.EVENT_ID,:new.BOOKING_ID,:new.BOOKING_STATUS_TYPE_ID,:new.DELEGATE_PERSON_ID,:new.EVENT_ID);END IF;END;
    commit
    CREATE OR REPLACE TRIGGER OTA_DELEGATE_BOOKINGS_AC BEFORE DELETE ON OTA_DELEGATE_BOOKINGS BEGIN IF fnd_global.audit_active THEN fnd_audit_pkg.audit_on := TRUE;ELSE fnd_audit_pkg.audit_on := FALSE;END IF;END;
    commit
    CREATE OR REPLACE TRIGGER OTA_DELEGATE_BOOKINGS_AD AFTER DELETE ON OTA_DELEGATE_BOOKINGS FOR EACH ROW BEGIN IF fnd_audit_pkg.audit_on THEN OTA_DELEGATE_BOOKINGS_ADP(:old.BOOKING_ID,:old.BOOKING_STATUS_TYPE_ID,:old.DELEGATE_PERSON_ID,:old.EVENT_ID,:new.BOOKING_ID,:new.BOOKING_STATUS_TYPE_ID,:new.DELEGATE_PERSON_ID,:new.EVENT_ID);END IF;END;
    commit
    ----->Create Views
    VIEW OTA_DELEGATE_BOOKINGS_AV1
    commit
    VIEW OTA_DELEGATE_BOOKINGS_AV2
    commit
    VIEW OTA_DELEGATE_BOOKINGS_AV3
    commit
    VIEW OTA_DELEGATE_BOOKINGS_AV4
    commit
    VIEW OTA_DELEGATE_BOOKINGS_AC1
    -->BOOKING_ID
    -->BOOKING_STATUS_TYPE_ID
    -->DELEGATE_PERSON_ID
    -->EVENT_ID
    commit
    UPDATE FND_AUDIT_TABLES T SET T.STATE = 'E' WHERE T.TABLE_ID = 55079 AND T.TABLE_APP_ID = 810 AND NOT EXISTS ( SELECT NULL FROM FND_AUDIT_COLUMNS C WHERE C.TABLE_APP_ID = T.TABLE_APP_ID AND C.TABLE_ID = T.TABLE_ID AND C.STATE = 'P' AND C.SCHEMA_ID != -1)
    commit
    commit
    ----->Delete Invalid Columns
    ----->Drop Triggers
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AI
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AI
    ORA-04080: trigger 'FND_PROFILE_OPTION_VALUE_AI' does not exist
    DROP PROCEDURE FND_PROFILE_OPTION_VALUE_AIP
    DROP PROCEDURE FND_PROFILE_OPTION_VALUE_AIP
    ORA-04043: object FND_PROFILE_OPTION_VALUE_AIP does not exist
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AD
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AD
    ORA-04080: trigger 'FND_PROFILE_OPTION_VALUE_AD' does not exist
    DROP PROCEDURE FND_PROFILE_OPTION_VALUE_ADP
    DROP PROCEDURE FND_PROFILE_OPTION_VALUE_ADP
    ORA-04043: object FND_PROFILE_OPTION_VALUE_ADP does not exist
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AU
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AU
    ORA-04080: trigger 'FND_PROFILE_OPTION_VALUE_AU' does not exist
    DROP PROCEDURE FND_PROFILE_OPTION_VALUE_AUP
    DROP PROCEDURE FND_PROFILE_OPTION_VALUE_AUP
    ORA-04043: object FND_PROFILE_OPTION_VALUE_AUP does not exist
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AC
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AC
    ORA-04080: trigger 'FND_PROFILE_OPTION_VALUE_AC' does not exist
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AH
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AH
    ORA-04080: trigger 'FND_PROFILE_OPTION_VALUE_AH' does not exist
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AT
    DROP TRIGGER FND_PROFILE_OPTION_VALUE_AT
    ORA-04080: trigger 'FND_PROFILE_OPTION_VALUE_AT' does not exist
    Cause: Table name is FND_PROFILE_OPTION_VALUE_A.
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV1
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV2
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV3
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV4
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV5
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV6
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV7
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV8
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV9
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV10
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV11
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV12
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV13
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV14
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV15
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV16
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV17
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV18
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV19
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV20
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV21
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV22
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV23
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV24
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV25
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV26
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV27
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV28
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV29
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV30
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV31
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV32
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV33
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV34
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV35
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV36
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV37
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV38
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV39
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV40
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV41
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV42
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV43
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV44
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV45
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV46
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV47
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV48
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV49
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV50
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV51
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV52
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV53
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV54
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV55
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV56
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV57
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV58
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV59
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV60
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV61
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV62
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV63
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV64
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV65
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV66
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV67
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV68
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV69
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV70
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV71
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV72
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV73
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV74
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV75
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV76
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV77
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV78
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV79
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV80
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV81
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV82
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV83
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV84
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV85
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV86
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV87
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV88
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV89
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV90
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV91
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV92
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV93
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV94
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV95
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV96
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV97
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV98
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV99
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AV100
    ORA-00942: table or view does not exist
    DROP VIEW FND_PROFILE_OPTION_VALUE_AC1
    ORA-00942: table or view does not exist
    ----->Drop Shadow Table
    DROP TABLE FND_PROFILE_OPTION_VALUE_A
    ORA-00942: table or view does not exist
    Error in fdasql, continuing...
    /oracleferp/FERP/APPS/apps_st/appl/fnd/12.0.0/bin/FNDATUPD
    Program was terminated by signal 11
    Executing request completion options...
    Output file size:
    0
    Output is not being printed because:
    The print option has been disabled for this report.
    Finished executing request completion options.
    Concurrent request completed
    Current system time is 02-APR-2013 04:19:44
    Regards,
    S.Malik

  • ORA-06502: PL/SQL: numeric or value error: character string buffer too smal

    Hi Guys I am getting error ORA-06502: PL/SQL: numeric or value error: character string buffer too small as it said i thought it would be issue with length of feild but i tried to change is nothihg work i am posing code here if any one can please help me on this
    PROCEDURE REPORT
    p_rpt_from_dt in varchar2,
    p_rpt_to_dt in varchar2,
    p_apvr_id in tc_wkr.tc_row_id%type default NULL,
    p_rpt_type in varchar2 default NULL,
    p_backto_pg in varchar2 default NULL
    IS
    v_rpt_from_dt date := var_to_date(p_rpt_from_dt);
    v_rpt_to_dt date := var_to_date(p_rpt_to_dt);
    v_time_str varchar2(15);
    cursor period_cur
    cp_from_dt date,
    cp_to_dt date
    is
    select beg_dt, end_dt
    from jmcs_wk_tprd
    where beg_dt <= cp_to_dt -- report end date
    and end_dt >= cp_from_dt -- report start date
    BEGIN
    if sys_security('tcsys', 'tc_reports') != 'GRANTED' then
    apps_main.access_denied;
    return;
    end if;
    if lg_debug_fl then
    v_time_str := to_char(lg_sysdate, 'hh:mi:ss a.m.');
    else
    v_time_str := tc_time(lg_sysdate);
    end if;
    /* get the time card time periods applicable to the report */
    lga_tc_strt_dt := lga_null_date;
    for recs in period_cur(v_rpt_from_dt, v_rpt_to_dt) loop
    lga_tc_strt_dt(lga_tc_strt_dt.count+1) := recs.beg_dt;
    lga_tc_end_dt(lga_tc_end_dt.count+1) := recs.end_dt;
    end loop;
    --if p_apvr_id is NULL then
    if p_rpt_type != 'D' then
    tc_reporting.reports_header
    1,
    'Time Card Status Report',
    'for '||dd_mon_yyyy(v_rpt_from_dt)||' through '||dd_mon_yyyy(v_rpt_to_dt)||'<BR>'||
    'Report Date: '||dd_mon_yyyy(lg_sysdate)||' Time: '||v_time_str,
    NULL,
    NULL,
    NULL,
    'javascript:window.close()', /* Backto */
    'alert(''Reminder! Click on logo when you are ready to return to previous page'')'
    end if;
    if p_apvr_id is NULL then
    sub_STATUS_BD_ALPHA (v_rpt_from_dt, v_rpt_to_dt, TRUE, p_rpt_type, p_apvr_id);
    else
    htp.p('<!-- Selected Approver ('||p_apvr_id||') -->');
    sub_STATUS_BD_APVR (v_rpt_from_dt, v_rpt_to_dt, p_rpt_type, p_apvr_id);
    end if;
    htp.p('</body></html>');
    EXCEPTION
    WHEN OTHERS THEN
    error_proc(SQLERRM, SQLCODE, owa_util.get_cgi_env('PATH_INFO'));
    htp.p('Error Code is :'||SQLERRM);
    END REPORT;
    This package in trun call other procedure like below
    PROCEDURE sub_STATUS_BD_ALPHA
    p_rpt_from_dt in date,
    p_rpt_to_dt in date,
    p_display_hdr in boolean,
    p_rpt_type in varchar2 default 'B',
    p_apvr_id in tc_wkr.tc_row_id%type default NULL,
    p_tcs_user_id in tc_wkr.tc_row_id%type default NULL
    IS
    v_time_str varchar2(15);
    v_apvr_id tc_wkr.tc_row_id%type := 0;
    v_a_user_id tc_wkr.tc_row_id%type; -- approver tcs_user_id
    v_cnt integer := 0;
    v_people_cnt integer := 0;
    v_stat_cd varchar2(2000);
    v_display_fl boolean := FALSE;
    /*===========================================================================*/
    cursor people_cur
    cp_from_dt in date,
    cp_to_dt in date
    is
    select
    d_full_nm_lfm as name,
    tc_row_id as tcs_user_id,
    tcw_typ as pay_typ,
    tcw_id as pay_id,
    sys_strt_date as sys_strt_dt,
    sys_end_dt
    from tc_wkr
    where sys_strt_date <= cp_to_dt
    and nvl(sys_end_dt, cp_to_dt) >= cp_from_dt
    order by upper(d_full_nm_lfm);
    /* find the current or the most recent (if no current) approver */
    cursor apvr_cur
    cp_tcs_user_id in tc_wkr.tc_row_id%type
    is
    select
    a.f_tc_apvr_id as fk_tcs_apvr_id,
    w.d_full_nm_lfm as apvr_name,
    w.tcw_typ as apvr_pay_typ,
    w.tcw_id as apvr_pay_id,
    a.strt_dt,
    a.end_dt
    from tc_wkr w, tc_ap_asmt a
    where a.f_tc_wkr_id = cp_tcs_user_id
    and w.tc_row_id = a.f_tc_apvr_id
    order by a.strt_dt desc;
    /* list of existing time cards UNION required time cards */
    cursor tc_cur
    cp_tcs_user_id in tc_wkr.tc_row_id%type, /* who's time cards */
    cp_from_dt in date, /* report period from date */
    cp_to_dt in date /* report period to date */
    is
    select
    stat_cd,
    strt_dt,
    end_dt
    from tc
    where strt_dt <= cp_to_dt
    and end_dt >= cp_from_dt
    and fk_tc_wkrtcw_id = cp_tcs_user_id
    UNION
    select
    'Required' as stat_cd,
    beg_dt as strt_dt,
    end_dt
    from jmcs_wk_tprd
    where beg_dt <= cp_to_dt
    and end_dt >= cp_from_dt
    and beg_dt not in (
    select strt_dt
    from tc
    where strt_dt <= cp_to_dt
    and end_dt >= cp_from_dt
    and fk_tc_wkrtcw_id = cp_tcs_user_id
    order by strt_dt;
    BEGIN
    if lg_debug_fl then
    v_time_str := to_char(lg_sysdate, 'hh:mi:ss a.m.');
    else
    v_time_str := tc_time(lg_sysdate);
    end if;
    if p_apvr_id > 0 then
    lga_report_out := lga_report_out_null;
    v_apvr_id := p_apvr_id;
    lga_apvr := lga_apvr_null;
    select
    d_full_nm_lfm,
    tc_row_id,
    tcw_id,
    tcw_typ
    into
    lga_apvr(1).apvr_name,
    lga_apvr(1).apvr_tcs_id,
    lga_apvr(1).apvr_pay_id,
    lga_apvr(1).apvr_pay_typ
    from tc_wkr
    where tc_row_id = v_apvr_id;
    if lga_apvr(1).apvr_pay_typ != 'S' then
    select decode(bend_empl_fl, 'Y', 'E', 'W')
    into lga_apvr(1).apvr_pay_typ
    from empl
    where empl_id = lga_apvr(1).apvr_pay_id;
    end if;
    end if;
    if p_display_hdr then
    if lga_tc_strt_dt.count > 6 then /* more than 6 time periods (1 month) */
    lga_width(1) := to_char(.15 * lg_page_width_standard);
    lga_width(2) := to_char(.08 * lg_page_width_standard);
    for i in 1..lga_tc_strt_dt.count loop
    lga_width(lga_width.count+1) := to_char(.09 * lg_page_width_standard);
    end loop;
    lg_page_width_standard := to_number(lga_width(1)) + to_number(lga_width(2));
    if nvl(p_apvr_id, 0) = 0 then
    lg_page_width_standard := lg_page_width_standard * 2;
    end if;
    htp.p('<!-- page width = '||lg_page_width_standard||'-->');
    for i in 3..lga_width.count loop
    lg_page_width_standard := lg_page_width_standard + to_number(lga_width(i));
    htp.p('<!-- page width = '||lg_page_width_standard||'-->');
    end loop;
    lg_page_width := to_char(lg_page_width_standard);
    else
    lga_width(1) := '15%';
    lga_width(2) := '8%';
    lga_width(3) := '9%';
    lga_width(4) := '9%';
    lga_width(5) := '9%';
    lga_width(6) := '9%';
    lga_width(7) := '9%';
    lga_width(8) := '9%';
    end if;
    sub_DETAIL_PAGE_HD(p_apvr_id);
    end if;
    /* cursor loop */
    for p in people_cur(p_rpt_from_dt, p_rpt_to_dt) loop
    /* is/was this person assigned to the selected approver for the report period */
    v_display_fl := FALSE;
    if nvl(p_tcs_user_id, 0) > 0 then
    if p_tcs_user_id = p.tcs_user_id then
    htp.p('<br>Selected User');
    v_display_fl := TRUE;
    end if;
    elsif nvl(p_apvr_id, 0) = 0 then
    if nvl(p_apvr_id, 0) = 0 then
    v_display_fl := TRUE;
    elsif p_apvr_id > 0 or p_apvr_id = -1 then
    v_display_fl := fct_ASSIGNED_APVR(p.tcs_user_id, p_apvr_id, p_rpt_from_dt, p_rpt_to_dt);
    end if;
    if v_display_fl then
    v_people_cnt := v_people_cnt + 1;
    lg_tcs_owner_info.USER_ID := p.tcs_user_id;
    lg_tcs_owner_info.PAY_ID := p.pay_id;
    lg_tcs_owner_info.PAY_TYPE := p.pay_typ;
    lg_tcs_owner_info.SYS_STRT_DT := p.sys_strt_dt;
    lg_tcs_owner_info.TERM_DT := p.sys_end_dt;
    if p.pay_typ = 'S' then
    begin
    select wrk_hire_dt
    into lg_tcs_owner_info.hire_dt
    from subcntr
    where sub_id = p.pay_id;
    exception
    when no_data_found then
    tc_debug.html_message('subcntr.pay_id('||p.pay_id||')');
    end;
    else
    select
    wrk_hire_dt,
    decode(bend_empl_fl, 'Y', 'E', 'W')
    into
    lg_tcs_owner_info.hire_dt,
    lg_tcs_owner_info.pay_type
    from empl
    where empl_id = lg_tcs_owner_info.PAY_ID;
    end if;
    if lga_report_out.count = 0 then
    lga_report_out(lga_report_out.count+1) := '<table border="1" cellpadding="3" width="'||lg_page_width||'">';
    end if;
    if mod(v_people_cnt,2) = 1 then
    lga_report_out(lga_report_out.count+1) := ('<tr bgcolor="'||lg_odd_bgcolor||'">');
    else
    lga_report_out(lga_report_out.count+1) := ('<tr bgcolor="'||lg_even_bgcolor||'">');
    end if;
    lga_report_out(lga_report_out.count+1) := ('<td valign="top"><font size=-2>'||p.name||'</font></td >');
    lga_report_out(lga_report_out.count+1) := ('<td valign="top"><font size=-2>'||p.pay_typ||'-'||lpad(p.pay_id,4,'0')||'</font></td >');
    if nvl(p_apvr_id, 0) > 0 then /* Single Approver */
    /* need approver ID for time card "status" */
    lga_apvr := lga_apvr_null; /* clear the approver id array */
    lga_apvr(1).apvr_tcs_id := p_apvr_id;
    elsif nvl(p_apvr_id, 0) = 0 then /* ALL Approvers */
    lga_apvr := lga_apvr_null; /* clear the approver id array */
    v_cnt := 0;
    for ap in apvr_cur (p.tcs_user_id) loop
    if v_cnt = 0 then
    /* most recent approver may not be the applicable approver */
    v_cnt := 1;
    lga_apvr(v_cnt).apvr_name := ap.apvr_name; -- identify multiple approvers for the "status"
    lga_apvr(v_cnt).apvr_tcs_id := ap.fk_tcs_apvr_id; -- identify multiple approvers for the "status"
    lga_apvr(v_cnt).apvr_pay_id := ap.apvr_pay_id; -- identify multiple approvers for the "status"
    v_apvr_id := ap.fk_tcs_apvr_id;
    if ap.apvr_pay_typ = 'S' then
    lga_apvr(v_cnt).apvr_pay_typ := ap.apvr_pay_typ; -- identify multiple approvers for the "status"
    else
    select decode(bend_empl_fl, 'Y', 'E', 'W')
    into lga_apvr(1).apvr_pay_typ
    from empl
    where empl_id = lga_apvr(1).apvr_pay_id;
    end if;
    end if;
    if ap.strt_dt <= p_rpt_to_dt and nvl(ap.end_dt, p_rpt_to_dt) >= p_rpt_from_dt then
    /* approver record */
    lg_tcs_owner_info.APVR_ID := ap.fk_tcs_apvr_id;
    lg_tcs_owner_info.APVR_STRT_DT := ap.strt_dt;
    lg_tcs_owner_info.APVR_END_DT := ap.end_dt;
    don't enter same approver name multiple times
    when same approver has been assigned more than once
    Example: approver1, approver_2, approver_1 (change back to approver 1)
    for i in 1..lga_apvr.count loop
    v_apvr_id := ap.fk_tcs_apvr_id;
    if lga_apvr(i).apvr_tcs_id = ap.fk_tcs_apvr_id then
    /* don't add again */
    v_apvr_id := NULL;
    exit;
    end if;
    end loop;
    if v_apvr_id is not NULL then
    v_cnt := v_cnt + 1;
    lga_apvr(v_cnt).apvr_name := ap.apvr_name; -- identify multiple approvers for the "status"
    lga_apvr(v_cnt).apvr_tcs_id := ap.fk_tcs_apvr_id; -- identify multiple approvers for the "status"
    lga_apvr(v_cnt).apvr_pay_id := ap.apvr_pay_id; -- identify multiple approvers for the "status"
    lga_apvr(v_cnt).apvr_pay_typ := ap.apvr_pay_typ; -- identify multiple approvers for the "status"
    end if;
    end if;
    end loop;
    /* list approver pay IDs */
    lga_report_out(lga_report_out.count+1) := ('<td valign="top"><font size=-2>');
    if lga_apvr.count = 0 then
    lga_report_out(lga_report_out.count+1) := 'Approver Unassigned';
    else
    for i in 1..lga_apvr.count loop
    if i > 1 then
    lga_report_out(lga_report_out.count+1) := '<br>';
    end if;
    lga_report_out(lga_report_out.count+1) := (lga_apvr(i).apvr_name);
    end loop;
    end if;
    lga_report_out(lga_report_out.count+1) := ('<td valign="top"><font size=-2>');
    if lga_apvr.count = 0 then
    lga_report_out(lga_report_out.count+1) := 'N/A';
    else
    for i in 1..lga_apvr.count loop
    if i > 1 then
    lga_report_out(lga_report_out.count+1) := '<br>';
    end if;
    lga_report_out(lga_report_out.count+1) := (lga_apvr(i).apvr_pay_typ)||'-'||lpad(lga_apvr(i).apvr_pay_id,4,'0');
    end loop;
    end if;
    lga_report_out(lga_report_out.count+1) := ('</font></td >');
    end if;
    for t in tc_cur(p.tcs_user_id, p_rpt_from_dt, p_rpt_to_dt) loop
    htp.p('<! '||t.strt_dt||', '||t.end_dt||', '||t.stat_cd||' -->');
    --lga_report_out(lga_report_out.count+1) := ('<td valign="top"><font size=-2>');
    --lga_report_out(lga_report_out.count+1) := (t.stat_cd);
    --lga_report_out(lga_report_out.count+1) := ('</font></td >');
    /* has the selected approver has completed processing */
    if p_apvr_id > 0
    and v_apvr_id = p_apvr_id
    and v_a_user_id != p_apvr_id
    then
    exit;
    end if;
    for ap in apvr_cur (p.tcs_user_id) loop
    if apvr_cur%rowcount = 1 then
    /* most recent approver assigned */
    lg_tcs_owner_info.apvr_id := ap.fk_tcs_apvr_id;
    end if;
    if ap.strt_dt <= t.end_dt and nvl(ap.end_dt, t.end_dt) >= t.strt_dt then
    /* approver assigned during time card period */
    lg_tcs_owner_info.apvr_id := ap.fk_tcs_apvr_id;
    exit;
    end if;
    end loop;
    lg_tc_status.strt_dt := t.strt_dt;
    lg_tc_status.end_dt := t.end_dt;
    lg_tc_status.stat_cd := t.stat_cd;
    v_stat_cd := fct_TC_STATUS(nvl(p_apvr_id, 0));
    lga_report_out(lga_report_out.count+1) := ('<td align="center" valign="top" bgcolor="'||lg_tc_status.bg_color||'">');
    lga_report_out(lga_report_out.count+1) := ('<font size=-2 color='||lg_tc_status.font_color||'>');
    lga_report_out(lga_report_out.count+1) := v_stat_cd;
    lga_report_out(lga_report_out.count+1) := ('</font></td >');
    end loop;
    lga_report_out(lga_report_out.count+1) := '</tr>';
    end if; /* v_display_fl */
    end loop;
    if p_rpt_type in ('B', 'S') then
    lg_page_cnt := lg_page_cnt + 1;
    sub_DISPLAY_STATUS_SUMMARY;
    end if;
    if lga_report_out.count > 0 then
    lga_report_out(lga_report_out.count+1) := '</table>';
    end if;
    if lga_report_out.count > 0 then
    if p_rpt_type = 'B' or p_apvr_id > 0 then
    if p_display_hdr then
    if lg_page_cnt > 0 then
    if p_apvr_id > 0 then /* selected individual approver */
    htp.p('</table>');
    end if;
    htp.p('<br style="page-break-after:always">');
                        htp.p('<!-- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& -->');
                        htp.p('<!-- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& -->');
    end if;
    lg_page_cnt := lg_page_cnt + 1;
    tc_reporting.reports_header
    1,
    'Time Card Status Report',
    'for '||dd_mon_yyyy(p_rpt_from_dt)||' through '||dd_mon_yyyy(p_rpt_to_dt)||'<BR>'||
    'Report Date: '||dd_mon_yyyy(lg_sysdate)||' Time: '||v_time_str,
    NULL,
    NULL,
    NULL,
    NULL, -- p_backto_pg, /* Backto */
    'focus()',
    lg_page_cnt
    end if;
    end if;
    if p_rpt_type in ('B', 'D') then
    for i in 1..lga_report_out.count loop
    htp.p(lga_report_out(i));
    end loop;
    end if;
    end if;
    END sub_STATUS_BD_ALPHA;
    Some veriable
    type report_tc_rec is record
    tc_owner_name tc_wkr.d_full_nm_lfm%type,
    o_user_id tc_wkr.tc_row_id%type,
    o_pay_id varchar2(10),
    o_sys_strt_dt date,
    o_sys_end_dt date,
    tc_apvr_name tc_wkr.d_full_nm_lfm%type,
    a_pay_id varchar2(10),
    a_user_id tc_wkr.tc_row_id%type,
    tc_strt_dt date,
    tc_end_dt date,
    tc_stat_cd varchar2(50),
    ap_strt_dt date,
    ap_end_dt date
    /* time card owner information */
    TYPE tcs_owner_info_rec IS RECORD
    USER_ID tc_wkr.tc_row_id%type,
    PAY_ID tc_wkr.tcw_id%type,
    PAY_TYPE tc_wkr.tcw_typ%type,
    HIRE_DT date,
    SYS_STRT_DT date,
    TERM_DT date,
    APVR_ID tc_wkr.tc_row_id%type,
    APVR_STRT_DT date,
    APVR_END_DT date
    /* status code determines report cell font and background colors */
    TYPE tc_status_rec IS RECORD
    STRT_DT date,
    END_DT date,
    STAT_CD tc.stat_cd%type,
    FONT_COLOR varchar2(16),
    BG_COLOR varchar2(16)
    /* count of all time card status for report summary */
    TYPE tc_status_summary_rec IS RECORD
    APPROVED_CNT integer := 0,
    REJECTED_CNT integer := 0,
    SUBMITTED_CNT integer := 0,
    POSTED_CNT integer := 0,
    VERIFIED_CNT integer := 0,
    OPEN_CNT integer := 0,
    NEW_CNT integer := 0,
    REQUIRED_CNT integer := 0,
    TOTAL_CNT integer := 0
    /* determine multiple approvers for individual for selected report period */
    TYPE apvr_rec IS RECORD
    apvr_name tc_wkr.d_full_nm_lfm%type,
    apvr_tcs_id tc_wkr.tc_row_id%type,
    apvr_pay_id tc_wkr.tcw_id%type,
    apvr_pay_typ tc_wkr.tcw_typ%type
    TYPE apvr_id_array_table IS TABLE OF apvr_rec
    index by binary_integer;
    type output_array is table of varchar2(1000)
    index by binary_integer;
    type date_array is table of date
    index by binary_integer;
    type status_array is table of varchar2(1000)
    index by binary_integer;
    type apvr_array is table of number(8)
    index by binary_integer;
    lga_report_out output_array; /* array of HTML code to be output to browser */
    lga_report_out_null output_array; /* null array of HTML code */
    lga_tc_status status_array;
    lga_null_status status_array;
    lga_tc_strt_dt date_array;
    lga_tc_end_dt date_array;
    lga_tc_disp date_array; /* start dates of displayed TC for selected user */
    lga_null_date date_array; /* null array used to clear other date arrays */
    /* LOCAL GLOBAL VARIABLES */
    lg_tcs_owner_info tcs_owner_info_rec; /* time card owner information */
    lg_tc_status tc_status_rec; /* time card status information */
    lg_tc_status_summary tc_status_summary_rec; /* time card count by status */
    lg_tc_rec report_tc_rec; /* time card */
    lga_apvr apvr_id_array_table; /* array of approver Names and Payroll IDs */
    lga_apvr_null apvr_id_array_table; /* clear the lga_apvr array for each user */
    lg_sysdate date := sysdate;
    lg_debug_fl boolean := FALSE;
    lg_debug_owner_id tc_wkr.tc_row_id%type := 9905;
    lg_debug_apvr_id tc_wkr.tc_row_id%type := 1000;
    The chnages i have done its in bold
    Please Advice
    Thanks
    Edited by: Purvik on Aug 25, 2009 11:59 AM

    There is not a chance in the world, especially not knowing column definitions that I, and I suspect most anyone else, is going to wade through this much unformated code looking for an error you couldn't bother to copy in full.
    Either tell us, specifically, the line on which the error is occurring or, better yet, start whacking stuff out of your code until you find the offending definition. That is certainly what I would do. Commenting out sections is a marvelous way to quickly find an issue.
    Before you post again please read the FAQ. It will explain to you how to properly post and use the tags.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to skip(do not wnat to get display) save dialogue box for file download

    I am having servlet for downlading a file from server. When I call this servelt I am able to get the file from server but I get a save dialog box which I do not want. I want that this file should be stored at a specific location given by me in a servlet.
    So haoe I can avoid that save dialog box and where I should specify the specific location?
    Thanks in advance
    package com.txcs.sms.server.servlet;
    import java.io.*;
    import java.util.zip.GZIPOutputStream;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class DownloadServlet extends HttpServlet
        public DownloadServlet()
            separator = "/";
            root = ".";
        public void init(ServletConfig servletconfig)
            throws ServletException
            super.init(servletconfig);
            context = servletconfig.getServletContext();
            String s;
            if((s = getInitParameter("dir")) == null)
                s = root;
            separator = System.getProperty("file.separator");
            if(!s.endsWith(separator) && !s.endsWith("/"))
                s = s + separator;
            root = s;
        public void doGet(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
            throws ServletException, IOException
            doPost(httpservletrequest, httpservletresponse);
        public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
            throws ServletException, IOException
            Object obj = null;
            String s = "";
            s = HttpUtils.getRequestURL(httpservletrequest).toString();
            int i;
            if((i = s.indexOf("?")) > 0)
                s = s.substring(0, i);
            String s1;
            if((s1 = httpservletrequest.getQueryString()) == null)
                s1 = "";
            else
                s1 = decode(s1);
            if(s1.length() == 0)
                httpservletresponse.setContentType("text/html");
                PrintWriter printwriter = httpservletresponse.getWriter();
                printwriter.println("<html>");
                printwriter.println("<br><br><br>Could not get file name ");
                printwriter.println("</html>");
                printwriter.flush();
                printwriter.close();
                return;
            if(s1.indexOf(".." + separator) >= 0 || s1.indexOf("../") >= 0)
                httpservletresponse.setContentType("text/html");
                PrintWriter printwriter1 = httpservletresponse.getWriter();
                printwriter1.println("<html>");
                printwriter1.println("<br><br><br>Could not use this file name by the security restrictions ");
                printwriter1.println("</html>");
                printwriter1.flush();
                printwriter1.close();
                return;
            File file = lookupFile(root + s1);
            if(file == null)
                httpservletresponse.setContentType("text/html");
                PrintWriter printwriter2 = httpservletresponse.getWriter();
                printwriter2.println("<html>");
                printwriter2.println("<br><br><br>Could not read file " + s1);
                printwriter2.println("</html>");
                printwriter2.flush();
                printwriter2.close();
                return;
            if(!file.exists() || !file.canRead())
                httpservletresponse.setContentType("text/html");
                PrintWriter printwriter3 = httpservletresponse.getWriter();
                printwriter3.println("<html><font face=\"Arial\">");
                printwriter3.println("<br><br><br>Could not read file " + s1);
                printwriter3.print("<br>Reasons are: ");
                if(!file.exists())
                    printwriter3.println("file does not exist");
                else
                    printwriter3.println("file is not readable at this moment");
                printwriter3.println("</font></html>");
                printwriter3.flush();
                printwriter3.close();
                return;
            String s2 = httpservletrequest.getHeader("Accept-Encoding");
            boolean flag = false;
            if(s2 != null && s2.indexOf("gzip") >= 0 && "true".equalsIgnoreCase(getInitParameter("gzip")))
                flag = true;
            if(flag)
                httpservletresponse.setHeader("Content-Encoding", "gzip");
                httpservletresponse.setHeader("Content-Disposition", "attachment;filename=\"" + s1 + "\"");
                javax.servlet.ServletOutputStream servletoutputstream = httpservletresponse.getOutputStream();
                GZIPOutputStream gzipoutputstream = new GZIPOutputStream(servletoutputstream);
                dumpFile(root + s1, gzipoutputstream);
                gzipoutputstream.close();
                servletoutputstream.close();
            } else
                httpservletresponse.setContentType("application/octet-stream");
                httpservletresponse.setHeader("Content-Disposition", "attachment;filename=\"" + s1 + "\"");
                javax.servlet.ServletOutputStream servletoutputstream1 = httpservletresponse.getOutputStream();
                dumpFile(root + s1, servletoutputstream1);
                servletoutputstream1.flush();
                servletoutputstream1.close();
        private String getFromQuery(String s, String s1)
            if(s == null)
                return "";
            int i = s.indexOf(s1);
            if(i < 0)
                return "";
            String s2 = s.substring(i + s1.length());
            if((i = s2.indexOf("&")) < 0)
                return s2;
            else
                return s2.substring(0, i);
        private void dumpFile(String s, OutputStream outputstream)
            String s1 = s;
            byte abyte0[] = new byte[4096];
            try
                BufferedInputStream bufferedinputstream = new BufferedInputStream(new FileInputStream(lookupFile(s1)));
                int i;
                while((i = bufferedinputstream.read(abyte0, 0, 4096)) != -1)
                    outputstream.write(abyte0, 0, i);
                bufferedinputstream.close();
            catch(Exception exception) { }
        private String decode(String s)
            StringBuffer stringbuffer = new StringBuffer(0);
            for(int i = 0; i < s.length(); i++)
                char c = s.charAt(i);
                if(c == '+')
                    stringbuffer.append(' ');
                else
                if(c == '%')
                    char c1 = '\0';
                    for(int j = 0; j < 2; j++)
                        c1 *= '\020';
                        c = s.charAt(++i);
                        if(c >= '0' && c <= '9')
                            c1 += c - 48;
                            continue;
                        if((c < 'A' || c > 'F') && (c < 'a' || c > 'f'))
                            break;
                        switch(c)
                        case 65: // 'A'
                        case 97: // 'a'
                            c1 += '\n';
                            break;
                        case 66: // 'B'
                        case 98: // 'b'
                            c1 += '\013';
                            break;
                        case 67: // 'C'
                        case 99: // 'c'
                            c1 += '\f';
                            break;
                        case 68: // 'D'
                        case 100: // 'd'
                            c1 += '\r';
                            break;
                        case 69: // 'E'
                        case 101: // 'e'
                            c1 += '\016';
                            break;
                        case 70: // 'F'
                        case 102: // 'f'
                            c1 += '\017';
                            break;
                    stringbuffer.append(c1);
                } else
                    stringbuffer.append(c);
            return stringbuffer.toString();
        public String getServletInfo()
            return "A DownloadServlet servlet ";
        private File lookupFile(String s)
            File file = new File(s);
            return file.isAbsolute() ? file : new File(context.getRealPath("/"), s);
        private static final String DIR = "dir";
        private static final String GZIP = "gzip";
        private ServletContext context;
        private String separator;
        private String root;
        private static final String VERSION = "ver. 1.6";
        private static final String CPR = "A DownloadServlet servlet ";
    }

    Can't be done, for obvious security reasons.
    Would you want someone downloading something into your windows\system directory when you navigate to their webpage?

  • Working Sample Code: File Download Servlet

    Pardon the cross-posting (Java Servlet Technology), but when I was researching this problem I found alot of people asking this question in here as well as in the servlet forum. So I thought this code would be helpful here too.
    Here is a complete working servlet for downloading virtually any type of file to a browser.
    It uses a file called application.properties to specify the location of the folder where the files to be downloaded reside. Of course you could modify this to allow the users to select the location as well.
    A sample URL to call the Servlet would look like this:
    http://localhost/website/servlet/DownloadAssistant?YourFileName.ext
    I tested this with varying filenames. It did have some issues if the file contained special characters like # symbol. This should be manageable however.
    Hope someone finds this useful.
    import java.io.*;
    import java.util.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.zip.GZIPOutputStream;
    public class DownloadAssistant extends HttpServlet
    private static final String DIR = "dir";
    private String separator;
    private String root;
    public DownloadAssistant()
    Properties propFile = null;
    FileInputStream in = null;
    String JAVA_HOME = "C:\\jrun\\servers\\default\\filetest\\application.properties";
    // Get a handle on the peoperties file
    try{
    in = new FileInputStream(JAVA_HOME);
    propFile = new Properties();
    propFile.load(in);
    catch (IOException ignore){}
    separator = "/";
    // Get the directory from the application.properties file
    // e.g. C:\\Temp\\Files\\
    root = propFile.getProperty("app.directory");
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    processRequest(request, response);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    processRequest(request, response);
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    PrintWriter out = null;
    ServletOutputStream stream = null;
    GZIPOutputStream zipstream = null;
    Object obj = null;
    String s = "";
    //determine if there is a filename appended to the url
    // If so, then decode it
    s = HttpUtils.getRequestURL(request).toString();
    int i;
    if((i = s.indexOf("?")) > 0)
    s = s.substring(0, i);
    String s1;
    if((s1 = request.getQueryString()) == null)
    s1 = "";
    else
    //s1 = decode(s1);
    s1 = URLDecoder.decode(s1);
    // No filename, so set contentType and generate error message
    if(s1.length() == 0)
    response.setContentType("text/html");
    out = response.getWriter();
    out.println("<html>");
    out.println("<p>Could not get file name ");
    out.println("</html>");
    out.flush();
    out.close();
    return;
    // Restriction while gaining access to the file
    if(s1.indexOf(".." + separator) > 0)
    response.setContentType("text/html");
    out = response.getWriter();
    out.println("<html>");
    out.println("<br><br><br>Restrictions on filename");
    out.println("</html>");
    out.flush();
    out.close();
    return;
    // Try to get a handle on the file
    File file = new File(root + s1);
    // Couldn't get the file, return an error message
    if(file == null)
    response.setContentType("text/html");
    out = response.getWriter();
    out.println("<html>");
    out.println("<p>Could not read file: " + s1);
    out.println("</html>");
    out.flush();
    out.close();
    return;
    // Either the file doesn't exist or it can't be read, return an error message
    if(!file.exists() || !file.canRead())
    response.setContentType("text/html");
    out = response.getWriter();
    out.println("<html><font face=\"Arial\" size=\"+1\">");
    out.println("<p>Could not read file " + s1);
    out.print("<br>Reasons are: ");
    if(!file.exists())
    out.println("file does not exist");
    else
    out.println("file is not readable at this moment");
    out.println("</font></html>");
    out.flush();
    out.close();
    return;
    // Looks like we can read/access the file, determine its type
    String s2 = request.getHeader("Accept-Encoding");
    // Is this a zip file?
    boolean flag = false;
    if(s2 != null && s2.indexOf("gzip") >= 0)
    flag = true;
    flag = false;
    if(flag)
    response.setHeader("Content-Encoding", "gzip");
    response.setHeader("Content-disposition", "attachment;filename=" + s1);
    stream = response.getOutputStream();
    zipstream = new GZIPOutputStream(stream);
    downloadFile(root + s1, zipstream);
    zipstream.close();
    stream.close();
    // It's not a zip file so treat it as any other file
    else
    response.setContentType("application/force-download");
    response.setHeader("Content-disposition", "attachment;filename=" + s1);
    stream = response.getOutputStream();
    downloadFile(root + s1, stream);
    stream.flush();
    stream.close();
    }// end processRequest()
    // This method downloads the file to the browser
    private void downloadFile(String s, OutputStream outstream)
    String s1 = s;
    byte abyte0[] = new byte[4096];
    try
    BufferedInputStream instream = new BufferedInputStream(new FileInputStream(s1));
    int i;
    while((i = instream.read(abyte0, 0, 4096)) != -1)
    outstream.write(abyte0, 0, i);
    instream.close();
    catch(Exception _ex) { }
    }//end downloadFile()
    public void init(ServletConfig servletconfig)
    throws ServletException
    super.init(servletconfig);
    String s;
    if((s = getInitParameter("dir")) == null)
    s = root;
    separator = System.getProperty("file.separator");
    if(!s.endsWith(separator))
    s = s + separator;
    root = s;
    }//end init()
    }//end servlet()

    Yes - it is useful

  • Base64 class

    Here is a Base64 class. I'm not the author, but it's not important, the important thing is that you can use it for encode and decode. It's very useful!!!. Enjoy it!!.
    package yourPackage;
    import java.io.*; // needed only for main() method.
    * Provides encoding of raw bytes to base64-encoded characters, and
    * decoding of base64 characters to raw bytes.
    public class Base64
    * returns an array of base64-encoded characters to represent the
    * passed data array.
    * @param data the array of bytes to encode
    * @return base64-coded character array.
    static public char[] encode(byte[] data)
    char[] out = new char[((data.length + 2) / 3) * 4];
    // 3 bytes encode to 4 chars. Output is always an even
    // multiple of 4 characters.
    for (int i = 0, index = 0; i < data.length; i += 3, index += 4)
    boolean quad = false;
    boolean trip = false;
    int val = (0xFF & (int) data);
    val <<= 8;
    if ((i + 1) < data.length)
    val |= (0xFF & (int) data[i + 1]);
    trip = true;
    val <<= 8;
    if ((i + 2) < data.length)
    val |= (0xFF & (int) data[i + 2]);
    quad = true;
    out[index + 3] = alphabet[(quad ? (val & 0x3F) : 64)];
    val >>= 6;
    out[index + 2] = alphabet[(trip ? (val & 0x3F) : 64)];
    val >>= 6;
    out[index + 1] = alphabet[val & 0x3F];
    val >>= 6;
    out[index + 0] = alphabet[val & 0x3F];
    return out;
    * Decodes a BASE-64 encoded stream to recover the original
    * data. White space before and after will be trimmed away,
    * but no other manipulation of the input will be performed.
    * As of version 1.2 this method will properly handle input
    * containing junk characters (newlines and the like) rather
    * than throwing an error. It does this by pre-parsing the
    * input and generating from that a count of VALID input
    * characters.
    static public byte[] decode(char[] data)
    // as our input could contain non-BASE64 data (newlines,
    // whitespace of any sort, whatever) we must first adjust
    // our count of USABLE data so that...
    // (a) we don't misallocate the output array, and
    // (b) think that we miscalculated our data length
    // just because of extraneous throw-away junk
    int tempLen = data.length;
    for (int ix = 0; ix < data.length; ix++)
    if ((data[ix] > 255) || codes[data[ix]] < 0)
    --tempLen; // ignore non-valid chars and padding
    // calculate required length:
    // -- 3 bytes for every 4 valid base64 chars
    // -- plus 2 bytes if there are 3 extra base64 chars,
    // or plus 1 byte if there are 2 extra.
    int len = (tempLen / 4) * 3;
    if ((tempLen % 4) == 3)
    len += 2;
    if ((tempLen % 4) == 2)
    len += 1;
    byte[] out = new byte[len];
    int shift = 0; // # of excess bits stored in accum
    int accum = 0; // excess bits
    int index = 0;
    // we now go through the entire array (NOT using the 'tempLen' value)
    for (int ix = 0; ix < data.length; ix++)
    int value = (data[ix] > 255) ? -1 : codes[data[ix]];
    if (value >= 0)// skip over non-code
    accum <<= 6; // bits shift up by 6 each time thru
    shift += 6; // loop, with new bits being put in
    accum |= value; // at the bottom.
    if (shift >= 8)// whenever there are 8 or more shifted in,
    shift -= 8; // write them out (from the top, leaving any
    out[index++] = // excess at the bottom for next iteration.
    (byte)((accum >> shift) & 0xff);
    // we will also have skipped processing a padding null byte ('=') here;
    // these are used ONLY for padding to an even length and do not legally
    // occur as encoded data. for this reason we can ignore the fact that
    // no index++ operation occurs in that special case: the out[] array is
    // initialized to all-zero bytes to start with and that works to our
    // advantage in this combination.
    // if there is STILL something wrong we just have to throw up now!
    if (index != out.length)
    throw new Error("Miscalculated data length (wrote " +
    index + " instead of " + out.length + ")");
    return out;
    // code characters for values 0..63
    static private char[] alphabet =
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" .toCharArray();
    // lookup table for converting base64 characters to value in range 0..63
    static private byte[] codes = new byte[256];
    static
    for (int i = 0; i < 256; i++)
    codes[i] = -1;
    for (int i = 'A'; i <= 'Z'; i++)
    codes[i] = (byte)(i - 'A');
    for (int i = 'a'; i <= 'z'; i++)
    codes[i] = (byte)(26 + i - 'a');
    for (int i = '0'; i <= '9'; i++)
    codes[i] = (byte)(52 + i - '0');
    codes['+'] = 62;
    codes['/'] = 63;
    public static void main(String[] args)
    boolean decode = false;
    if (args.length == 0)
    System.out.println("usage: java Base64 [-d[ecode]] filename");
    System.exit(0);
    for (int i = 0; i < args.length; i++)
    if ("-decode".equalsIgnoreCase(args[i]))
    decode = true;
    else if ("-d".equalsIgnoreCase(args[i]))
    decode = true;
    String filename = args[args.length - 1];
    File file = new File(filename);
    if (!file.exists())
    System.out.println("Error: file '" + filename + "' doesn't exist!");
    System.exit(0);
    if (decode)
    char[] encoded = readChars(file);
    byte[] decoded = decode(encoded);
    writeBytes(file, decoded);
    else
    byte[] decoded = readBytes(file);
    char[] encoded = encode(decoded);
    writeChars(file, encoded);
    * @param file
    * @return
    private static byte[] readBytes(File file)
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try
    InputStream fis = new FileInputStream(file);
    InputStream is = new BufferedInputStream(fis);
    int count = 0;
    byte[] buf = new byte[16384];
    while ((count = is.read(buf)) != -1)
    if (count > 0)
    baos.write(buf, 0, count);
    is.close();
    catch (Exception e)
    e.printStackTrace();
    return baos.toByteArray();
    * @param file
    * @return
    private static char[] readChars(File file)
    CharArrayWriter caw = new CharArrayWriter();
    try
    Reader fr = new FileReader(file);
    Reader in = new BufferedReader(fr);
    int count = 0;
    char[] buf = new char[16384];
    while ((count = in.read(buf)) != -1)
    if (count > 0)
    caw.write(buf, 0, count);
    in.close();
    catch (Exception e)
    e.printStackTrace();
    return caw.toCharArray();
    * @param file
    * @param data
    private static void writeBytes(File file, byte[] data)
    try
    OutputStream fos = new FileOutputStream(file);
    OutputStream os = new BufferedOutputStream(fos);
    os.write(data);
    os.close();
    catch (Exception e)
    e.printStackTrace();
    * @param file
    * @param data
    private static void writeChars(File file, char[] data)
    try
    Writer fos = new FileWriter(file);
    Writer os = new BufferedWriter(fos);
    os.write(data);
    os.close();
    catch (Exception e)
    e.printStackTrace();

    Ok.
    The main reason of my message was that in the beginning I didn't know anything for Base64 class and I needed one for my project. I was looking for it and when I had found it I thought in do post a new topic in this forum to help to the people that they should have the same problem. Now I can see more solutions for this issue.
    Thank you very much.
    Bye

  • Problem in using aggregate functions inside case statement

    Hi All,
    I am facing problem while using aggregate functions inside case statement.
    CASE WHEN PSTYPE='S' THEN MAX(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) ELSE SUM(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) END,
    how can I achieve above requirement ? Con anyone help me.
    Thanks and Regards
    DG

    Hi All,
    Below is my query:
            SELECT
            CASE WHEN p_reportid IN ('POS_RV_SN','POS_PB') THEN POS.PACCT
            ELSE POS.PACCT || '-' || DECODE(POS.SYSTEMCODE,'GMI1','1', 'GMI2','2', 'GMI3','4', 'GMI4','3', '0') ||POS.PFIRM|| NVL(POS.POFFIC,'000') END,
            CASE WHEN p_reportid IN ('POS_RV_SN','POS_PB') THEN POS.PACCT||POS.PCUSIP||DECODE(POS.PBS,1,'+',2,'-')
            ELSE POS.PFIRM||POS.POFFIC||POS.PACCT||POS.PCUSIP||DECODE(POS.PBS,1,'+',2,'-') END,POS.SYSTEMCODE,CASE WHEN POS.PSTYPE='S' THEN POS.PSYMBL ELSE POS.PFC END,POS.PEXCH||DECODE(POS.PSUBEX,'<NULL>',''),
            POS.PCURSY,
            CASE WHEN POS.PSBCUS IS NULL THEN SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) ELSE POS.PSBCUS || SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) END ,
            NVL(POS.PSUBTY,'F') ,POS.PSTRIK,*SUM(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) ,SUM(DECODE(POS.PBS,2,ABS(POS.PPRTQ),0))* ,
            POS.PCLOSE,SUM(POS.PMKVAL) ,
            TO_CHAR(CASE WHEN INSTR(POS.PUNDCP,'.') > 0 OR LENGTH(POS.PUNDCP) < 15 THEN POS.PUNDCP ELSE TO_CHAR(TO_NUMBER(POS.PUNDCP) / 100000000) END),
            POS.UBS_ID,POS.BBG_EXCHANGE_CODE,POS.BBG_TICKER ,POS.BBG_YELLOW_KEY,POS.PPCNTY,POS.PMULTF,TO_CHAR(POS.BUSINESS_DATE,'YYYYMMDD'),
            POS.SOURCE_GMI_LIB,
            --DECODE(POS.SYSTEMCODE,'GMI1','euro','GMI2','namr','GMI3','aust','GMI4','asia','POWERBASE','aust','SINACOR','namr',POS.SYSTEMCODE),
            DECODE(p_reportid,'RVPOS_SING','euro','RVPOS_AUSTDOM','aust','RVPOS_AUSTEOD','euro','RVPOS_GLBLAPAC','asia','POS_RV_SN','namr','POS_PB','aust',POS.SYSTEMCODE),
            POS.RIC,
            CASE WHEN PSUBTY = 'S' THEN POS.TYPE ELSE NULL END,
            DECODE(POS.UBS_ID,NULL,POS.PCUSP2,POS.ISIN),POS.UNDERLYING_BBG_TICKER,POS.UNDERLYING_BBG_EXCHANGE,POS.PRODUCT_CLASSIFICATION,
            CASE WHEN PSUBTY = 'S' THEN POS.PSDSC2 ELSE NULL END,
            CASE WHEN PSUBTY = 'S' THEN C.SSDSC3 ELSE NULL END,
            NVL(C.SSECID,POS.PCUSIP),
            NULL,
            POS.PYSTMV,
            POS.PMINIT,
            POS.PEXPDT,
            CASE WHEN POS.PSUBTY='S' THEN  SUBSTR(C.ZDATA2,77,1) ELSE NULL END,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL
            FROM POSITIONS_WRK POS LEFT OUTER JOIN
            (SELECT * FROM CDS_PRODUCTS CP INNER JOIN FUTURE_MASTER FM ON
            (CP.STRXCH=FM.ZEXCH AND CP.SFC=FM.ZFC AND CP.BUSINESS_DATE = FM.BUSINESS_DATE )) C ON POS.PCUSIP = C.SCUSIP
            AND NVL(POS.PCUSP2,'X') = NVL(C.SCUSP2,'X')
            WHERE
            POS.PEXCH NOT IN ('A1','A2','A3','B1','B3','C2','D1','H1','K1','L1','M1','M3','P1','S1')
            AND (POS.PSBCUS IS NOT NULL OR POS.PCTYM IS NOT NULL OR POS.PSTYPE ='S')
            AND POS.BUSINESS_DATE = run_date_char
            GROUP BY
            POS.UBS_ID,POS.SYSTEMCODE,POS.RECIPIENTCODE,POS.BUSINESS_DATE,POS.PACCT,POS.PFIRM,POS.POFFIC,POS.PCUSIP,POS.PBS,CASE WHEN POS.PSTYPE='S' THEN POS.PSYMBL ELSE POS.PFC END,
            POS.PEXCH,POS.PSUBEX,POS.PCURSY,
            CASE WHEN POS.PSBCUS IS NULL THEN SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) ELSE POS.PSBCUS || SUBSTR(POS.PCTYM,5,2)  || SUBSTR(POS.PCTYM,1,4) END,
            NVL(POS.PSUBTY,'F') ,POS.PSTRIK,POS.PCLOSE,TO_CHAR(CASE WHEN INSTR(POS.PUNDCP,'.') > 0 OR LENGTH(POS.PUNDCP) < 15 THEN POS.PUNDCP ELSE TO_CHAR(TO_NUMBER(POS.PUNDCP) / 100000000) END),
            POS.BBG_EXCHANGE_CODE,POS.BBG_TICKER,POS.BBG_YELLOW_KEY,POS.PPCNTY,POS.PMULTF,POS.PSUBTY,POS.SOURCE_GMI_LIB,RIC,
            CASE WHEN PSUBTY = 'S' THEN POS.TYPE ELSE NULL END,
            DECODE(POS.UBS_ID,NULL,POS.PCUSP2,POS.ISIN),POS.UNDERLYING_BBG_TICKER,POS.UNDERLYING_BBG_EXCHANGE,POS.PRODUCT_CLASSIFICATION,
            CASE WHEN PSUBTY = 'S' THEN POS.PSDSC2 ELSE NULL END,
            CASE WHEN PSUBTY = 'S' THEN C.SSDSC3 ELSE NULL END,
            NVL(C.SSECID,POS.PCUSIP),
            POS.PYSTMV,
            POS.PMINIT,
            POS.PEXPDT,
            CASE WHEN PSUBTY = 'S'  THEN  SUBSTR(C.ZDATA2,77,1) ELSE NULL END;Now, could you plz help me in replacing the bold text in the query with the requirement.
    Thanks and Rgds
    DG
    Edited by: BluShadow on 16-May-2011 09:39
    added {noformat}{noformat} tags.  Please read: {message:id=9360002} for details on how to post code/data                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Scalar Select stmt in Case causing problems

    Hello,
    here is some background followed by my question
    I have two tables, headerx and detailx which are joined
    Detailx has a sequence number column
    I would like to query detailx such that if for any header there are more than one details, it should return the highest sequence with state = passed.
    If there is only one detail, then it should return that detail row.
    So, I came up with this SQL:
    select DTL.ID, DTL.TSTAMP
    from HEADERX hdr inner join
         DETAILX dtl on DTL.HDR_FK = hdr.id
    where dtl.seq =
         (select case max(seq) when 1 then 1
                                       else (select max(seq) from DETAILX dtl3 where dtl3.hdr_fk = hdr.id and dtl3.state='PASSED')
                                       end
           from DETAILX dtl2
           where dtl2.hdr_fk = hdr.id)
    ; The above threw a ORA 937 - Not a single-group group function
    If I remove the embedded select inside the case and replace it with an arbitrary value, there is no error and some rows are returned
    select DTL.ID, DTL.TSTAMP
    from HEADERX hdr inner join
         DETAILX dtl on DTL.HDR_FK = hdr.id
    where dtl.seq =
         (select case max(seq) when 1 then 1 else 2 end from DETAILX dtl2 where dtl2.hdr_fk = hdr.id)
    ; Not really understanding why, I added a group by which appears to work
    select DTL.ID, DTL.TSTAMP
    from HEADERX hdr inner join
         DETAILX dtl on DTL.HDR_FK = hdr.id
    where dtl.seq =
         (select case max(seq) when 1 then 1
                                        else (select max(seq) from DETAILX dtl3 where dtl3.hdr_fk = hdr.id and dtl3.state='PASSED')
                                        end
          from DETAILX dtl2
          where dtl2.hdr_fk = hdr.id
          group by 1)
    ; Question: Why is the group by required? Clearly there is only one scalar value that will be returned
    If anyone cares to suggest, is there a more elegant solution?

    Instead of joining the same table too many times,
    You can do this,
    Not tested,
    SELECT DTL.ID, DTL.TSTAMP
      FROM    HEADERX hdr
           INNER JOIN
              (SELECT dtl.*, CASE WHEN MAX (seq) OVER (PARTITION BY ID) = 1
                                  THEN 1
                                  ELSE MAX (DECODE (state, 'PASSED', seq)) OVER (PARTITION BY ID)
                              END mx
                 FROM DETAILX dtl) dtl
           ON (DTL.HDR_FK = hdr.ID
           AND hdr.seq = dtl.mx)
    G.

  • MERGE JOIN CARTESIAN

    Hi,
    I have a query which is using MERGE JOIN CARTESIAN (see step 4 and 11 in execution plan bellow) and i believe this is the culprit and query is never returning. Stats are up to date on all tables. This query involves two remote databases which are accessed using VIEWs from local database. Is there any hint which i can use here to avoid merge join Cartesian and test. Thanks. Also pasting query if any one can have any idea.
        Select  distinct
         substr(Revenue.FKDAT,5,2) || '/' || substr(Revenue.FKDAT,7,2) || '/' || substr(Revenue.FKDAT,1,4) INVOICE_DATE
        , Revenue.VBELN INVOICE_NR
        , Revenue.ARKTX CUSTDEVICE
        , (case Revenue.ZU_LOTID
        when null then hstg_partinfo_cust_dw.CUSTPARTOUT
        when '' then hstg_partinfo_cust_dw.CUSTPARTOUT
        Else
        (case decode(trim(zodss1b2.biztype),'TNR-E330-BAKE','TNR','')
        when 'TNR' then
        (case when (select CUSTPARTOUT from hstg_partinfo_cust_dw Where lotid = 'U' || substr(Revenue.ZU_LOTID,2,7) || '.' || substr(Revenue.ZU_LOTID,9) and stage = 'T998-TFIN' and rownum = 1)
         is null then (select CUSTPARTOUT from hstg_partinfo_cust_dw Where lotid = (select parentid from hstg_partinfo_cust_dw where lotid = 'U' || substr(Revenue.ZU_LOTID,2,7) || '.' || substr(Revenue.ZU_LOTID,9) and stage = 'E330-BAKE' and rownum = 1) and stage = 'T998-TFIN' and rownum = 1)
        else (select CUSTPARTOUT from hstg_partinfo_cust_dw Where lotid = 'U' || substr(Revenue.ZU_LOTID,2,7) || '.' || substr(Revenue.ZU_LOTID,9) and stage = 'T998-TFIN' and rownum = 1)
        end)
        else hstg_partinfo_cust_dw.CUSTPARTOUT
        end)
        end) CUSTPARTOUT
        , Revenue.PONUM DO_NR
        , Revenue.BSTKD PO_NR
        , Revenue.FKIMG GD_QTY
        , Revenue.zkbetr GD_PRICE
        , Revenue.NETWR GD_AMT
        , '' REJ_QTY
        , '' REJ_PRICE
        , '' REJ_AMT
        , Revenue.ZU_LOTID LOTTYPE
        ,(case Revenue.ZU_LOTID
        when null then substr(Revenue.ZU_PRTID,1,instr(Revenue.ZU_PRTID,'.') -1)
        when '' then substr(Revenue.ZU_PRTID,1,instr(Revenue.ZU_PRTID,'.') -1)
        Else
        (case decode(trim(zodss1b2.biztype),'TNR-E330-BAKE','TNR','')
        when 'TNR' then
       (case when (select substr(PARTID,1,instr(PARTID,'.') -1) from hstg_partinfo_cust_dw Where lotid = 'U' || substr(Revenue.ZU_LOTID,2,7) || '.' || substr(Revenue.ZU_LOTID,9) and stage = 'T998-TFIN' and  rownum = 1)
         is null then (select substr(PARTID,1,instr(PARTID,'.') -1) from hstg_partinfo_cust_dw Where lotid = (select parentid from hstg_partinfo_cust_dw where lotid = 'U' || substr(Revenue.ZU_LOTID,2,7) || '.' || substr(Revenue.ZU_LOTID,9) and stage = 'E330-BAKE' and rownum = 1) and stage = 'T998-TFIN' and rownum = 1)
        else (select substr(PARTID,1,instr(PARTID,'.') -1) from hstg_partinfo_cust_dw Where lotid = 'U' || substr(Revenue.ZU_LOTID,2,7) || '.' || substr(Revenue.ZU_LOTID,9) and stage = 'T998-TFIN' and rownum = 1)
        end)
        else substr(Revenue.ZU_PRTID,1,instr(Revenue.ZU_PRTID,'.') -1)
        end)
        end) PARTID
        , '' TESTER
        , substr(zodss1b2.BSTDK,5,2) || '/' || substr(zodss1b2.BSTDK,7,2) || '/' || substr(zodss1b2.BSTDK,1,4) DO_DATE
        , hstg_partinfo_cust_dw.package package
        , hstg_partinfo_cust_dw.pincount pincount
        , (select c.catg07 from ops$ods_adm.catg c where c.partid=revenue.zu_prtid) as package_size
        , (select c.catg09 from ops$ods_adm.catg c where c.partid=revenue.zu_prtid) as wafer_size
        , decode(trim(zodss1b2.biztype),'TNR-E330-BAKE','TNR','') BIZTYPE
         --from revenue, zodss1b2,dim_partinfo
         from revenue, zodss1b2,hstg_partinfo_cust_dw
         where Revenue.Remarks <> 'CANCELLED'
         and Revenue.FKART in ('ZUF2')
         and Revenue.KUNNR in ('BC1001','BC1002','BC1003')
         and Revenue.FKDAT like '201008%'
         and Revenue.FKIMG > 0
         and Revenue.kpein > 0
         and Revenue.ZU_LOTID = zodss1b2.charg
         and Revenue.MATNR = zodss1b2.matnr
         --and Revenue.ZU_PRTID = dim_partinfo.partid
         and hstg_partinfo_cust_dw.lotid='U' || substr(Revenue.ZU_LOTID,2,7) || '.' || substr(Revenue.ZU_LOTID,9)
        Union all
         Select distinct
         substr(Revenue.FKDAT,5,2) || '/' || substr(Revenue.FKDAT,7,2) || '/' || substr(Revenue.FKDAT,1,4) INVOICE_DATE
        , Revenue.VBELN INVOICE_NR
        , Revenue.ARKTX CUSTDEVICE
        , hstg_partinfo_cust_dw.CUSTPARTOUT CUSTPARTOUT
        , Revenue.PONUM DO_NR
        , Revenue.BSTKD PO_NR
        , Revenue.FKIMG GD_QTY
        , Revenue.zkbetr GD_PRICE
        , Revenue.NETWR GD_AMT
        , '' REJ_QTY
        , '' REJ_PRICE
        , '' REJ_AMT
        , Revenue.ZU_LOTID LOTTYPE
        , substr(Revenue.ZU_PRTID,1,instr(Revenue.ZU_PRTID,'.') -1) PARTID
        , '' TESTER
        , substr(zodsscrap.BSTDK,5,2) || '/' || substr(zodsscrap.BSTDK,7,2) || '/' || substr(zodsscrap.BSTDK,1,4) DO_DATE
        , hstg_partinfo_cust_dw.package package
        , hstg_partinfo_cust_dw.pincount pincount
        , (select c.catg07 from ops$ods_adm.catg c where c.partid=revenue.zu_prtid) as package_size
        , (select c.catg09 from ops$ods_adm.catg c where c.partid=revenue.zu_prtid) as wafer_size
         --from revenue, zodsscrap,dim_partinfo
         from revenue, zodsscrap,hstg_partinfo_cust_dw
         where Revenue.Remarks <> 'CANCELLED'
         and Revenue.FKART in ('ZUF2')
         and Revenue.KUNNR in ('BC1001','BC1002','BC1003')
         and Revenue.FKDAT like '201008%'
         and Revenue.FKIMG > 0
         and Revenue.kpein > 0
         and Revenue.ZU_LOTID = zodsscrap.charg
         --and Revenue.ZU_PRTID = dim_partinfo.partid
         and hstg_partinfo_cust_dw.lotid='U' || substr(Revenue.ZU_LOTID,2,7) || '.' || substr(Revenue.ZU_LOTID,9);hstg_partinfo_cust_dw is a view which is on remote database USGDWDBP and is queried using synonym in the local database.
    revenue is also a view which is in another remote database which is queried using synonym in local database.
    ODS Plan
    | Id  | Operation               |  Name       | Rows  | Bytes | Cost  | Inst   |IN-OUT|
    |   0 | SELECT STATEMENT        |             |     2 |  8532 |   999 |        |      |
    |   1 |  UNION-ALL              |             |       |       |       |        |      |
    |   2 |   SORT UNIQUE           |             |     1 |  4277 |   985 |        |      |
    |   3 |    NESTED LOOPS         |             |     1 |  4277 |   983 |        |      |
    |   4 |     MERGE JOIN CARTESIAN|             |     1 |  4107 |   980 |        |      |
    |   5 |      REMOTE             |             |     1 |  4076 |     2 | USGDW~ | R->S |
    |   6 |      BUFFER SORT        |             |   918K|    27M|   978 |        |      |
    |   7 |       TABLE ACCESS FULL | ZODSS1B2    |   918K|    27M|   978 |        |      |
    |   8 |     REMOTE              |             |     1 |   170 |     3 | SAPP0~ | R->S |
    |   9 |   SORT UNIQUE           |             |     1 |  4255 |    14 |        |      |
    |  10 |    NESTED LOOPS         |             |     1 |  4255 |    12 |        |      |
    |  11 |     MERGE JOIN CARTESIAN|             |     1 |  4096 |     9 |        |      |
    |  12 |      REMOTE             |             |     1 |  4076 |     2 | USGDW~ | R->S |
    |  13 |      BUFFER SORT        |             |  1755 | 35100 |     7 |        |      |
    |  14 |       TABLE ACCESS FULL | ZODSSCRAP   |  1755 | 35100 |     7 |        |      |
    |  15 |     REMOTE              |             |     1 |   159 |     3 | SAPP0~ | R->S |
    ---------------------------------------------------------------------------------------Thanks in advance
    Salman

    Dear Salman Qureshi,
    First of all please see Jonathan Lewis' post about the merge join cartesian;
    http://jonathanlewis.wordpress.com/2006/12/13/cartesian-merge-join/
    You may also check the Thomas Kyte's thread;
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4105951726381
    You merge join cartesian cost is so low that the impact will not be that high.
    Yes, there are ways to avoid the merge join cartesian. First you have to check the where conditions. Merge join cartesian steps are happening because of the bad SQL algorithm OR sometimes Oracle needs to have a merge join cartesian. At the end, it is up to your SQL.
    After than that, you can also use the ORDERED CBO hint to avoid the merge join cartesian.
    Please add below line after the SELECT clause and see the new execution plan;
    /*+ ORDERED */I hope your problem will be fixed when you show the CBO to use the ORDERED Oracle hint.
    About the ORDERED Oracle hint, please check it out;
    http://download.oracle.com/docs/cd/B14117_01/server.101/b10752/hintsref.htm#5555
    ORDERED
    The ORDERED hint causes Oracle to join tables in the order in which they appear in the FROM clause.
    If you omit the ORDERED hint from a SQL statement performing a join, then the optimizer chooses the order in which to join the tables. You might want to use the ORDERED hint to specify a join order if you know something about the number of rows selected from each table that the optimizer does not. Such information lets you choose an inner and outer table better than the optimizer could.Hope That Helps.
    Ogan

  • Working Sample Code: FileDownload Servlet

    Here is a complete working servlet for downloading virtually any type of file to a browser.
    It uses a file called application.properties to specify the location of the folder where the files to be downloaded reside. Of course you could modify this to allow the users to select the location as well.
    A sample URL to call the Servlet would look like this:
    http://localhost/website/servlet/DownloadAssistant?YourFileName.ext
    I tested this with varying filenames. It did have some issues if the file contained special characters like # symbol. This should be manageable however.
    Hope someone finds this useful.
    import java.io.*;
    import java.util.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.zip.GZIPOutputStream;
    public class DownloadAssistant extends HttpServlet
    private static final String DIR = "dir";
    private String separator;
    private String root;
    public DownloadAssistant()
    Properties propFile = null;
    FileInputStream in = null;
    String JAVA_HOME = "C:\\jrun\\servers\\default\\filetest\\application.properties";
    // Get a handle on the peoperties file
    try{                         
    in = new FileInputStream(JAVA_HOME);
    propFile = new Properties();
    propFile.load(in);
    catch (IOException ignore){}
    separator = "/";
    // Get the directory from the application.properties file
    // e.g. C:\\Temp\\Files\\
    root = propFile.getProperty("app.directory");
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    processRequest(request, response);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    processRequest(request, response);
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    PrintWriter out = null;
    ServletOutputStream stream = null;
    GZIPOutputStream zipstream = null;
    Object obj = null;
    String s = "";
    //determine if there is a filename appended to the url
    // If so, then decode it
    s = HttpUtils.getRequestURL(request).toString();
    int i;
    if((i = s.indexOf("?")) > 0)
    s = s.substring(0, i);
    String s1;
    if((s1 = request.getQueryString()) == null)
    s1 = "";
    else
    //s1 = decode(s1);
    s1 = URLDecoder.decode(s1);
    // No filename, so set contentType and generate error message
    if(s1.length() == 0)
    response.setContentType("text/html");
    out = response.getWriter();
    out.println("<html>");
    out.println("<p>Could not get file name ");
    out.println("</html>");
    out.flush();
    out.close();
    return;
    // Restriction while gaining access to the file
    if(s1.indexOf(".." + separator) > 0)
    response.setContentType("text/html");
    out = response.getWriter();
    out.println("<html>");
    out.println("<br><br><br>Restrictions on filename");
    out.println("</html>");
    out.flush();
    out.close();
    return;
    // Try to get a handle on the file
    File file = new File(root + s1);
    // Couldn't get the file, return an error message
    if(file == null)
    response.setContentType("text/html");
    out = response.getWriter();
    out.println("<html>");
    out.println("<p>Could not read file: " + s1);
    out.println("</html>");
    out.flush();
    out.close();
    return;
    // Either the file doesn't exist or it can't be read, return an error message
    if(!file.exists() || !file.canRead())
    response.setContentType("text/html");
    out = response.getWriter();
    out.println("<html><font face=\"Arial\" size=\"+1\">");
    out.println("<p>Could not read file " + s1);
    out.print("<br>Reasons are: ");
    if(!file.exists())
    out.println("file does not exist");
    else
    out.println("file is not readable at this moment");
    out.println("</font></html>");
    out.flush();
    out.close();
    return;
    // Looks like we can read/access the file, determine its type
    String s2 = request.getHeader("Accept-Encoding");
    // Is this a zip file?
    boolean flag = false;
    if(s2 != null && s2.indexOf("gzip") >= 0)
    flag = true;
    flag = false;
    if(flag)
    response.setHeader("Content-Encoding", "gzip");
    response.setHeader("Content-disposition", "attachment;filename=" + s1);
    stream = response.getOutputStream();
    zipstream = new GZIPOutputStream(stream);
    downloadFile(root + s1, zipstream);
    zipstream.close();
    stream.close();
    // It's not a zip file so treat it as any other file
    else
    response.setContentType("application/force-download");
    response.setHeader("Content-disposition", "attachment;filename=" + s1);
    stream = response.getOutputStream();
    downloadFile(root + s1, stream);
    stream.flush();
    stream.close();
    }// end processRequest()
    // This method downloads the file to the browser
    private void downloadFile(String s, OutputStream outstream)
    String s1 = s;
    byte abyte0[] = new byte[4096];
    try
    BufferedInputStream instream = new BufferedInputStream(new FileInputStream(s1));
    int i;
    while((i = instream.read(abyte0, 0, 4096)) != -1)
    outstream.write(abyte0, 0, i);
    instream.close();
    catch(Exception _ex) { }
    }//end downloadFile()
    public void init(ServletConfig servletconfig)
    throws ServletException
    super.init(servletconfig);
    String s;
    if((s = getInitParameter("dir")) == null)
    s = root;
    separator = System.getProperty("file.separator");
    if(!s.endsWith(separator))
    s = s + separator;
    root = s;
    }//end init()
    }//end servlet()

    Instead of hardcoding the directory where the files are located, I keep that in a file called application.properties.
    there is a property there which looks like this
    app.directory=C:\\Temp\Files\\
    It's easier to change this rather than recompiling the servlet.
    I also use that file to hold things like the JDBC driver I will be using as well as other application specific properties I don't want to hardcode.
    HTH

  • Help With Error in Code Generated by WSDL Wizard

    I generated code using the webservice wizard, and then wrote
    a simple mxml file to test the code. I get this error:
    1061: Call to a possibly undefined method getClass through a
    reference with static type Class.
    It occurs in the following code:
    * Internal event handler to process a successful operation
    call from the server
    * The result is decoded using the schema and operation
    settings and then the
    * events get passed on to the actual facade that the user
    employs in the application
    * @private
    private function
    processResult(result:Object,wrappedData:Object):void
    var token:AsyncToken = wrappedData.returnToken;
    var currentOperation:WSDLOperation = wrappedData.operation;
    var decoder:SOAPDecoder = new SOAPDecoder();
    decoder.resultFormat="object";
    decoder.ignoreWhitespace = true;
    decoder.makeObjectsBindable=true;
    decoder.wsdlOperation = currentOperation;
    decoder.schemaManager = currentOperation.schemaManager;
    var body:Object = result.message.body;
    var stringResult:String = String(body);
    if (stringResult == null || stringResult == "")
    return;
    var soapResult:SOAPResult =
    decoder.decodeResponse(result.message.body);
    if (soapResult.isFault)
    var faults:Array = soapResult.result as Array;
    for each (var soapFault:Fault in faults)
    var soapFaultEvent:FaultEvent =
    FaultEvent.createEvent(soapFault,token,null);
    token.dispatchEvent(soapFaultEvent);
    } else {
    result = decoder.decodeResponse(result.message.body).result;
    if (result is ArrayCollection)
    //shoud upcast to specific type here
    var arrayTypedClass:Class =
    SchemaTypeRegistry.getClass(currentOperation.outputMessage.parts[0].type);
    result = new arrayTypedClass(result.source);
    var event:ResultEvent =
    ResultEvent.createEvent(result,token,null);
    token.dispatchEvent(event);
    The statement where the error occurs is in
    bold above. The comment above that line says I should upcast
    to a specific type here, but I don't know what that means. Which
    specific type? How do I determine what type to upcast to?
    Any help would be appreciated.
    TIA,
    Randy

    Hi Martin,
    From the error you showed it seems you have upgraded your SDK
    version, but not the builder. The problem you are experiencing
    comes from the fact that the one of the SDK classes (the
    SchemaTypeRegistry) has been updated from a static to a dynamic
    class. Therefore, using the getClass() call on it will not work any
    more. Also, the lines that register type mappings won't work.
    We've updated the generated code, but it seems you are
    running on an older version. Now, to fix your code you have to:
    1. Locate all occurences where the SchemaTypeRegistry class
    is called as a static class.
    2. Replace the SchemaTypeRegistry part from the method calls
    with SchemaTypeRegistry.getInstance(), like this:
    SchemaTypeRegistry.registerClass(params) becomes
    SchemaTypeRegistry.getInstance().registerClass(params)
    The problem is that when you re-generate the code you will
    have to re-do all these changes again.
    Hope this helps,
    Cristian

Maybe you are looking for

  • Wallpaper not showing up in "Change Desktop Background" window

    I just noticed an odd issue today on my Mac Pro. When browsing the built-in wallpaper folders (Nature, Plants, etc) in the Change Desktop Background window they are empty. My "Pictures Folder" one shows all the images correctly as well as browsing th

  • How to create a standards folder

    I'd like to create a standards folder to appear every time I open up FCP or start a new project. We have 4 or 5 pretty standard graphic and short Quicktime files for intros and outros, watermarks, etc, for nearly every project we do. Rather then drag

  • I need help my late 2007 imac will go black after I start it up ?

    i Start the computer up it shows the grey aand the apple shows. it loads and then goes black and the cursor still shows. I was thinKing my graphics cards was shot But I booted it in recovery mode and to shows all the colors and acts like nothing's is

  • Create URL with multiple values for one parameter

    Post Author: cbamberg CA Forum: General While I have no problems to create the URL to open a report with a single value for a parameter from my Java application, I don't know how to format multiple values for a parameter when I want to pass the "&pro

  • Virtual Key Figures

    I have already searched for and could not find the basic steps of Creating a Virtual KeyFigure, Can someone provide these? Thanks