Pl/sql  code  help required

i have 3 string like below
string1  varchar2(3000) := ' fonction code=''33'' and the limit for the subfunction is 300. it may have function_code=''100'' ) ) ) )';
string2  varchar2(2000):='function_code=''100''';
string3  varchar2(3000);requirement is
if i found string2 in string1 preceded by four brackets ,example function_code=''100'' ) ) ) )' then
i have replace to replace the 4th bracket with
function code is null  )the string1 now will be
' fonction code=''33'' and the limit for the subfunction is 300. it may have function_code=''100'' ) ) ) function code is null  )Pls help
NOte: bracket may or may not have spaces between them
S

SQL> declare
  2  string1  varchar2(3000) := 'AND NOT  (     (       (   FUNCTION_CODE = ''88''  )  OR  (   FUNCTION_CODE = ''21''  )  OR  (   FUNCTION_CODE = ''51'' )  OR  (   FUNCTION_CODE = ''85'' )  )  )  )' ;
  3  string2  varchar2(2000):='FUNCTION_CODE = ''85''';
  4  string3  varchar2(3000);
  5  begin
  6  string3 :=regexp_replace(string1,'^(.*)('||string2||')(([[:blank:]]?\)[[:blank:]]?){3})([[:blank:]]?\))(.*)$','\1\2\3function code is null\4\5');
  7  dbms_output.put_line(string3);
  8  end;
  9  /
AND NOT  (  (  (   FUNCTION_CODE = '88'  )  OR  (   FUNCTION_CODE = '21'  )  OR  (   FUNCTION_CODE = '51' )  OR  (
FUNCTION_CODE = '85' )  )  ) function code is null )  )
PL/SQL procedure successfully completed.Best regards
Maxim

Similar Messages

  • SQL Code help

    Hi There,
    We have a table "ALL_POS" that looks like the following:
    ROHO@rohopr> desc all_pos
    Name                                                  Null?    Type
    OFFICE_TYPE_DESCRIPTION                                        VARCHAR2(60)
    POSITION_ABBREVIATION                                          VARCHAR2(10)
    POSITION                                                       VARCHAR2(60)
    SD                                                             VARCHAR2(43)
    HIRED                                                          NUMBER
    OPEN                                                           NUMBERHere is the table sample data:
    pss@pssd> select * from all_pos where ed = 'SD-100'
    OFFICE_TYPE_DESCRIPTION                            POSITION_A POSITION                                 ED          HIRED       OPEN
    DISTRICT                                           RL         Revision Lead                            SD-100          1          1
    DISTRICT                                           SBHV       SBO - Home Visits                        SD-100          1          0
    DISTRICT                                           SBS        SBO - Standby                            SD-100          0          1
    DISTRICT                                           SBO        Special Ballot Officer                   SD-100          2          0
    DISTRICT                                           TS         TECHNICAL SUPPORT                        SD-100          1          0
    DISTRICT                                           TO         TRAINING OFFICER                         SD-100          3          0
    DISTRICT                                           ICC                                                 SD-100          0          1
    DISTRICT                                           EC         EVENT CLERK                              SD-100          1          0
    DISTRICT                                           FO         Finance Officer                          SD-100          1          0
    DISTRICT                                           APIA       Info. Asst - Adv Offices                 SD-100          4          0
    DISTRICT                                           REC        RECRUITMENT OFFICER                      SD-100          2          0
    DISTRICT                                           RES        RESOURCE STAFF                           SD-100         13          0
    DISTRICT                                           RO         RETURNING OFFICER                        SD-100          1          1
    DISTRICT                                           RA         REVISING AGENT                           SD-100         25         53
    DISTRICT                                           RAS        REVISION ASSISTANT                       SD-100          0          2
    DISTRICT                                           RC         Recruitment Clerk                        SD-100          0          2
    OFFICE                                             DRO        RETURNING OFFICER                        SD-100        261          0
    OFFICE                                             SBDRO      RETURNING OFFICER ON STAND-BY            SD-100         15          1
    OFFICE                                             PC         OFFICE CLERK CC                          SD-100        261          0
    AREA                                               APAM       AREA AREA MANAGER                        SD-100          1          0
    AREA                                               AM         AREA MANAGER                             SD-100          5          0
    LOCATION                                           IA         INFORMATION ASSISTANT                    SD-100         60          0
    LOCATION                                           PDRA       DAY REVISION ASSISTANT                   SD-100         79          0
    LOCATION                                           SDRO       SUPERVISING DEPUTY RETURNING OFFICER     SD-100         43          0
    LOCATION                                           TD         Tabulator-DRO                            SD-100          1          0
    OFFICE                                             APC        OFFICE CLERK                             SD-100         10          4
    OFFICE                                             APDRO      OFFICE RETURNING OFFICER                 SD-100          5          2
    27 rows selected.The SDs goes from SD-01 all through to SD-100. There are 40 distinct values for POSITION_ABBREVIATION as per the following:
    pss@pssd> select distinct(POSITION_ABBREVIATION),POSITION from all_pos order by 1;
    POSITION_A POSITION
    ALO        ABORIGINAL L. OFFICER
    AM         AREA MANAGER
    APAM       OFFICE AREA MANAGER
    APC        OFFICE CLERK
    APC-R      OFFICE CLERK - REPLACEMENT
    APDRO      OFFICE RETURNING OFFICER
    APDRO-R    OFFICE RETURNING OFFICER - REPLACEMENT
    APIA       Info. Asst - Adv OFFICEs
    CLO        Community Liaison Officer
    DRO        RETURNING OFFICER
    DRO-R      RETURNING OFFICER - REPLACEMENT
    EC         ELECTION CLERK
    FO         Finance Officer
    HLO        HOME L. OFFICER
    IA         INFORMATION ASSISTANT
    ICC
    OEO        Other Election Officer
    PC         OFFICE CLERK
    PC-R       OFFICE CLERK - REPLACEMENT
    PDRA       OFFICEING DAY REVISION ASSISTANT
    PDRA-R     OFFICEING DAY REVISION ASSISTANT - REPLACEMENT
    RA         REVISING AGENT
    RAS        REVISION ASSISTANT
    RC         Recruitment Clerk
    REC        RECRUITMENT OFFICER
    RES        RESOURCE STAFF
    RL         Revision Lead
    RO         RETURNING OFFICER
    SBDRO      RETURNING OFFICER ON STAND-BY
    SBHO       SBO - Hospital
    SBHV       SBO - Home Visits
    SBO        Special Ballot Officer
    SBS        SBO - Standby
    SDRO       SUPERVISING RETURNING OFFICER
    SDRO-R     SUPERVISING RETURNING OFFICER - REPLACEMENT
    SLO        Student L. Officer
    TD         Tabulator-DRO
    TD-R       Tabulator-DRO-Replacement
    TO         TRAINING OFFICER
    TS         TECHNICAL SUPPORTWe need to create a report that takes the POSITION_ABBREVIATION data displaying it in columns (horizontally), for all the SDs (1 to 100) something like the following:
    SD      total_open  total_hired   ABO L. OFFICER   AREA MANAGER   OFFICE AREA MANAGER   OFFICE CLERK   OFFICE CLERK - REPLACEMENT   ...etc
    SD-1           125            35              10              5                    10              10                          8 
    SD-2           110            87              10             10                    25               3                          0
    ..etc
    SD-100         300           120              20             22                    20              15                         28Can you kindly help us with the sql code to do that please.
    P.S. oracle version 11.2.0.1 x64.
    Thanks
    Edited by: rsar001 on Nov 4, 2011 6:56 AM

    Hi Frank,
    Here is the table DDL, and inserts for 2 SDs (SD-1 and SD-2).
    CREATE TABLE "ALL_POS"
    (    "OFFICE_TYPE_DESCRIPTION" VARCHAR2(60),
          "POSITION_ABBREVIATION" VARCHAR2(10),
          "POSITION" VARCHAR2(60),
          "SD" VARCHAR2(43),
          "HIRED" NUMBER,
          "OPEN" NUMBER
    insert into all_pos values ('DISTRICT'         ,'TS',     'TECHNICAL SUPPORT',              'SD-1',    2,0);
    insert into all_pos values ('DISTRICT'         ,'TO',     'TRAINING OFFICER',               'SD-1',    1,0);
    insert into all_pos values ('DISTRICT'         ,'EC',     'EVENT CLERK',                    'SD-1',    1,0);
    insert into all_pos values ('DISTRICT'         ,'FO',     'Finance Officer',                'SD-1',    1,0);
    insert into all_pos values ('DISTRICT'         ,'REC',    'RECRUITMENT OFFICER',            'SD-1',    1,0);
    insert into all_pos values ('DISTRICT'         ,'RES',    'RESOURCE STAFF',                 'SD-1',   19,3);
    insert into all_pos values ('DISTRICT'         ,'RO',     'RETURNING OFFICER',              'SD-1',    1,0);
    insert into all_pos values ('DISTRICT'         ,'RA',     'REVISING AGENT',                 'SD-1',   25,9);
    insert into all_pos values ('DISTRICT'         ,'RAS',    'REVISION ASSISTANT',             'SD-1',    2,0);
    insert into all_pos values ('OFFICE'           , 'DRO',   'RETURNING OFFICER',              'SD-1',  218,4);
    insert into all_pos values ('OFFICE'           , 'PC',    'OFFICE CLERK',                   'SD-1',  221,1);
    insert into all_pos values ('OFFICE'           , 'APC',   'ADVANCE OFFICE CLERK',           'SD-1',    7,1);
    insert into all_pos values ('OFFICE'           , 'APC-R', 'ADVANCE OFFICE CLERK - REPLACEMENT','SD-1', 2,0);
    insert into all_pos values ('OFFICE'           , 'APDRO', 'OFFICE RETURNING OFFICER',           'SD-1',    5,0);
    insert into all_pos values ('EVENT AREA'       , 'AM',    'AREA MANAGER',                   'SD-1',    4,0);
    insert into all_pos values ('EVENT LOCATION'   , 'IA',    'INFORMATION ASSISTANT',          'SD-1',   28,0);
    insert into all_pos values ('EVENT LOCATION'   , 'PDRA',  'OFFICEING DAY REVISION ASSISTANT','SD-1',   55,0);
    insert into all_pos values ('EVENT LOCATION'   , 'SDRO',  'SUPERVISING RETURNING OFFICER',  'SD-1',   36,0);
    insert into all_pos values ('DISTRICT',            'RL',     'Revision Lead',                  'SD-2',     1,   0);
    insert into all_pos values ('DISTRICT',            'SBHV',   'SBO - Home Visits',              'SD-2',     2,   6);
    insert into all_pos values ('DISTRICT',            'SBHO',   'SBO - Hospital',                 'SD-2',     5,   4);
    insert into all_pos values ('DISTRICT',            'SBO',    'Special B Officer',              'SD-2',     7,   0);
    insert into all_pos values ('DISTRICT',            'TS',     'TECHNICAL SUPPORT',              'SD-2',     1,   0);
    insert into all_pos values ('DISTRICT',            'TO',     'TRAINING OFFICER',               'SD-2',     3,   0);
    insert into all_pos values ('DISTRICT',            'ALO',    'AB L. OFFICER',                       'SD-2',     1,   0);
    insert into all_pos values ('DISTRICT',            'EC',     'EVENT CLERK',                    'SD-2',     0,   1);
    insert into all_pos values ('DISTRICT',            'FO',     'Finance Officer',                'SD-2',     1,   0);
    insert into all_pos values ('DISTRICT',            'APIA',   'Info. Asst - Adv OFFICEs',       'SD-2',    15,   1);
    insert into all_pos values ('DISTRICT',            'OEO',    'Other EVENT Officer',            'SD-2',     3,   0);
    insert into all_pos values ('DISTRICT',            'REC',    'RECRUITMENT OFFICER',            'SD-2',     1,   0);
    insert into all_pos values ('DISTRICT',            'RES',    'RESOURCE STAFF',                 'SD-2',    41,   0);
    insert into all_pos values ('DISTRICT',            'RO',     'RETURNING OFFICER',              'SD-2',     0,   1);
    insert into all_pos values ('DISTRICT',            'RA',     'REVISING AGENT',                 'SD-2',    16,  62);
    insert into all_pos values ('DISTRICT',            'RAS',    'REVISION ASSISTANT',             'SD-2',     1,   1);
    insert into all_pos values ('DISTRICT',            'RC',     'Recruitment Clerk',              'SD-2',     0,   1);
    insert into all_pos values ('OFFICE',           'APDRO',  'OFFICE RETURNING OFFICER',            'SD-2',    15,   1);
    insert into all_pos values ('OFFICE',           'DRO',    'RETURNING OFFICER',              'SD-2',   161,   0);
    insert into all_pos values ('OFFICE',           'SBDRO',  'RETURNING OFFICER ON STAND-BY',  'SD-2',    31,  22);
    insert into all_pos values ('OFFICE',           'PC',     'OFFICE CLERK',                   'SD-2',   161,   0);
    insert into all_pos values ('EVENT AREA',       'AM',     'AREA MANAGER',                   'SD-2',    22,   0);
    insert into all_pos values ('EVENT LOCATION',   'IA',     'INFORMATION ASSISTANT',          'SD-2',    73,   0);
    insert into all_pos values ('EVENT LOCATION',   'PDRA',   'OFFICEING DAY REVISION ASSISTANT','SD-2',   23,   0);
    insert into all_pos values ('EVENT LOCATION',   'SDRO',   'SUPERVISING RETURNING OFFICER',  'SD-2',    16,   0);
    insert into all_pos values ('EVENT LOCATION',   'TD',     'Tabulator-DRO',                  'SD-2',     4,   0);
    insert into all_pos values ('EVENT LOCATION',   'TD-R',   'Tabulator-DRO-Replacement',      'SD-2',     4,   0);
    insert into all_pos values ('OFFICE',           'APC',    'ADVANCE OFFICE CLERK',           'SD-2',    30,   2);
    commit;So, we're trying to display the data like so:
    We need to create a report that takes the POSITION_ABBREVIATION data displaying it in columns (horizontally), for all the SDs (1 to 100) something like the following:
    SD      total_open  total_hired   ABO L. OFFICER   AREA MANAGER   OFFICE AREA MANAGER   OFFICE CLERK   OFFICE CLERK - REPLACEMENT   ...etc
    SD-1           125            35              10              5                    10              10                          8 
    SD-2           110            87              10             10                    25               3                          0Thanks
    Edited by: rsar001 on Nov 4, 2011 8:52 AM

  • Dynamic PL/SQL - Urgent help required

    Hi there
    I am trying to write a packaged function which takes the table name and column name as arguments and build a pl/sql table which the function returns.
    Please do find the code below:
    Create or Replace Package Pk_valid_values
    is
    TYPE list_rec is record ( lc_list_desc varchar2(50));
    TYPE list_tab is TABLE of list_rec
    index by binary_integer;
    FUNCTION Fn_fetch_values
    ( p_table_name varchar2,
    p_column_name varchar2 )
    return list_tab;
    End Pk_valid_values;
    Create or Replace Package Body Pk_valid_values
    as
    FUNCTION Fn_fetch_values
    ( p_table_name varchar2,
    p_column_name varchar2 )
    return list_tab
    is
    l_values Pk_valid_values.list_tab;
    i binary_integer := 0;
    lc_element varchar2(50);
    ln_dummy number;
    v_cursor integer;
    lc_string varchar2(2000);
    ln_count number;
    BEGIN
    ln_count := Pk_count_record.Count_record(p_table_name);
    v_cursor := dbms_sql.open_cursor;
    lc_string := 'begin select p_column_name into :felement from '||
    p_table_name||' ; end;';
    dbms_sql.parse( v_cursor,
    lc_string,
    dbms_sql.native );
    dbms_sql.bind_variable( v_cursor,
    ':felement',
    lc_element );
    ln_dummy := dbms_sql.execute( v_cursor );
    for i in 1..ln_count loop
    dbms_sql.variable_value( v_cursor,
    ':felement',
    lc_element );
    l_values(i) := lc_element;
    end loop;
    dbms_sql.close_cursor( v_cursor );
    return( l_values );
    END Fn_fetch_values;
    End Pk_valid_values;
    I get an error "PLS-00382: expression is of wrong type" when I try to create this package.
    Could anyone please let me know where I have gone wrong?
    I have really burst my heads against this.
    Thanks in advance
    Rajeev

    Hi,
    I think it is that you declare a PL/SQL block, not a cursor.
    Try to replace :
    lc_string := 'begin select p_column_name into :felement from '||
    p_table_name||' ; end;';
    with :
    lc_string := 'select ' || p_column_name || ' from ' || p_table_name;
    Or an easier way :
    declare
    TYPE RefCurTyp IS REF CURSOR;
    cr RefCurTyp;
    lc_element varchar2(50);
    begin
    OPEN cr FOR 'select ' || p_column_name || ' from ' || p_table_name;
    LOOP
    FETCH cr INTO lc_element;
    EXIT WHEN cr%NOTFOUND;
    END LOOP;
    CLOSE cr;
    end;
    /Uffe

  • Importing 30 tables into one SQL Table (Help Required)

    Dear Experts,
    I am new in SQL server, actually i need to gather 30 different excel file in one sql server table and i have imported all excel file in different databases, all tables have 186 different columns and datatypes. I couldnt change data type while conversion.
    Now all columns have different data type which are occupying extra space in my database.
    Now the problem is that i need to convert all databases into one database or table. Although i have created a table but i dont have idea how to import all table into one table  and defining datatype in new table while importing the old tables.
    Please help me in this matter or if any body has skype or any other chatting id please do let me know so that i may explain it better.
    Thanking you in advance.
    Best Regards,
    SQL_beginner

    There are several things you can try.  If you have SSIS, take a look at this.
    http://www.singhvikash.in/2013/06/ssis-how-to-load-multiple-excel-files.html
    https://www.simple-talk.com/sql/ssis/importing-excel-data-into-sql-server-via-ssis-questions-you-were-too-shy-to-ask/
    Also, if your files have virtually the same name, like files with dates in the name, you can loop through files in your folder, and increment the loop with each run through.
    DECLARE @intFlag
    INT
    SET @intFlag
    = 1
    WHILE (@intFlag
    <=30)
    BEGIN
    PRINT @intFlag
    declare @fullpath1
    varchar(1000)
    select @fullpath1
    = '''\\path to your files\'
    + convert(varchar,
    getdate()- @intFlag
    , 112)
    + '_your-text-file-name.txt'''
    declare @cmd1
    nvarchar(1000)
    select @cmd1
    = 'bulk insert [dbo].[your-table-name] from '
    + @fullpath1 +
    ' with (FIELDTERMINATOR = ''\t'', FIRSTROW = 2, ROWTERMINATOR=''0x0a'')'
    exec (@cmd1)
    SET @intFlag
    = @intFlag + 1
    END
    GO
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • SQL Code help... not functioning correctly

    Hi I have the following code
    Select * FROM ACTIONS a, CUSTOMER b
    WHERE b.ID = 74
    AND b.ID = a.CUST_ID
    AND a.DATE BETWEEN '01/APR/2007' AND '31/MAR/2008';
    This works as expected and returns 2 actions - again as expected (actions were both on 22 May 2007 for customer 74)
    Then I want to update certain customers with the following...
    UPDATE CUSTOMER a
    SET a.CUSTOMER_ACTION = '0000'
    WHERE a.id = 74
    AND exists (
    select 1 from ACTIONS b
    WHERE b.DATE NOT BETWEEN '01-APR-07' AND '30-JUN-07'
    AND b.DATE NOT BETWEEN '01-JUL-07' AND '30-SEP-07'
    AND b.DATE NOT BETWEEN '01-OCT-07' AND '31-DEC-07'
    AND b.DATE NOT BETWEEN '01-JAN-08' AND '31-MAR-08'
    AND b.CUST_ID = a.ID);
    This then updates Customer 74 (this id no. will be dynamically called in - testing at moment with '74') with '0000' in its CUSTOMER_ACTION - however - I dont want it to update this customer as the dates say 'NOT BETWEEN' - so it shouldnt be returning anything thus shouldnt be updating this customer...but it does!!! Why?
    Can anyone see what's wrong with the code?

    and 74 did have some dates outside of the criteria so
    ive added
    AND b.DATE > '01-APR-07'
    think this has helped
    SCOTT@soti_10> desc customer
    Name                                      Null?    Type
    ID                                                 NUMBER(38)
    CUSTOMER_ACTION                                    VARCHAR2(4)
    SCOTT@soti_10> select * from customer;
            ID CUST
            74 1234
    SCOTT@soti_10> desc actions
    Name                                      Null?    Type
    ID                                                 NUMBER(38)
    A_DATE                                             DATE
    SCOTT@soti_10> select * from actions;
            ID A_DATE
            74 22-may-07
            74 22-may-07
            74 22-may-05
    SCOTT@soti_10> Select * FROM ACTIONS a, CUSTOMER b
      2  WHERE b.ID = 74
      3    AND b.ID = a.ID
      4    AND a.a_DATE BETWEEN '01/APR/2007' AND '31/MAR/2008';
            ID A_DATE            ID CUST
            74 22-may-07         74 1234
            74 22-may-07         74 1234
    SCOTT@soti_10>
    SCOTT@soti_10> Select * FROM ACTIONS a, CUSTOMER b
      2  WHERE b.ID = 74
      3    AND b.ID = a.ID
      4    AND a.a_DATE NOT BETWEEN '01/APR/2007' AND '31/MAR/2008';
            ID A_DATE            ID CUST
            74 22-may-05         74 1234
    SCOTT@soti_10> select * from customer a
      2  WHERE a.id = 74
      3    AND exists (
      4      select 1 from ACTIONS b
      5      WHERE b.a_DATE NOT BETWEEN '01-APR-07' AND '30-JUN-07'
      6        AND b.a_DATE NOT BETWEEN '01-JUL-07' AND '30-SEP-07'
      7        AND b.a_DATE NOT BETWEEN '01-OCT-07' AND '31-DEC-07'
      8        AND b.a_DATE NOT BETWEEN '01-JAN-08' AND '31-MAR-08'
      9        AND b.ID = a.ID
    10    )
    11  ;
            ID CUST
            74 1234
    SCOTT@soti_10> select * from customer a
      2  WHERE a.id = 74
      3    AND exists (
      4      select 1 from ACTIONS b
      5      WHERE b.a_DATE NOT BETWEEN '01-APR-07' AND '30-JUN-07'
      6        AND b.a_DATE NOT BETWEEN '01-JUL-07' AND '30-SEP-07'
      7        AND b.a_DATE NOT BETWEEN '01-OCT-07' AND '31-DEC-07'
      8        AND b.a_DATE NOT BETWEEN '01-JAN-08' AND '31-MAR-08'
      9        AND b.a_DATE > '01-APR-07'
    10        AND b.ID = a.ID
    11    )
    12  ;
    no rows selected
    SCOTT@soti_10> UPDATE CUSTOMER a
      2    SET a.CUSTOMER_ACTION = '0000'
      3  WHERE a.id = 74
      4    AND exists (
      5      select 1 from ACTIONS b
      6      WHERE b.a_DATE NOT BETWEEN '01-APR-07' AND '30-JUN-07'
      7        AND b.a_DATE NOT BETWEEN '01-JUL-07' AND '30-SEP-07'
      8        AND b.a_DATE NOT BETWEEN '01-OCT-07' AND '31-DEC-07'
      9        AND b.a_DATE NOT BETWEEN '01-JAN-08' AND '31-MAR-08'
    10        AND b.ID = a.ID
    11    )
    12  ;
    1 row updated.
    SCOTT@soti_10> rollback;
    Rollback complete.
    SCOTT@soti_10> UPDATE CUSTOMER a
      2    SET a.CUSTOMER_ACTION = '0000'
      3  WHERE a.id = 74
      4    AND exists (
      5      select 1 from ACTIONS b
      6      WHERE b.a_DATE NOT BETWEEN '01-APR-07' AND '30-JUN-07'
      7        AND b.a_DATE NOT BETWEEN '01-JUL-07' AND '30-SEP-07'
      8        AND b.a_DATE NOT BETWEEN '01-OCT-07' AND '31-DEC-07'
      9        AND b.a_DATE NOT BETWEEN '01-JAN-08' AND '31-MAR-08'
    10        AND b.a_DATE > '01-APR-07'
    11        AND b.ID = a.ID
    12    )
    13  ;
    0 rows updated.
    SCOTT@soti_10> rollback;
    Rollback complete.Have I missed something?
    Regards,
    Dima

  • SQL Loader Help required

    HI Team,
    I have requirement to load data in to table using sqlloader, as i am having three level's(Header, Detail, Trailer')
    first two position of data file represents the level like
    00-Header
    01 to 98 -Detail
    99 -Trailer
    each level will have different data structure and we should insert in to the same table
    i Have created table like
    CREATE TABLE APPS.XXD_TEST1
    AA NUMBER,
    TEST12 VARCHAR2(10 BYTE),
    testdt VARCHAR2(10 BYTE),
    testtr VARCHAR2(10 BYTE),
    RECORD_ID NUMBER
    and created sequence for record_id column
    --CREATE SEQUENCE APPS.XXD_TEST1_S
    i have data in the data file like below, i want to load the data in the same order
    000012
    010012
    010012
    020012
    030012
    990012
    000013
    010013
    020013
    030013
    990013
    i was using the folowwing control file
    LOAD DATA
    INFILE Test
    APPEND
    INTO TABLE xxd_test1
    WHEN (1:2) = '00'
    TRAILING NULLCOLS
    test12 POSITION(3:6) CHAR,
    aa POSITION(1:2) INTEGER EXTERNAL "lpad(:aa,2,'0')",
    record_id "xxd_test1_s.nextval"
    INTO TABLE xxd_test1
    WHEN (1:2) != '99' and (1:2) !='00'
    TRAILING NULLCOLS
    testdt POSITION(3:6) CHAR,
    aa POSITION(1:2) INTEGER EXTERNAL "lpad(:aa,2,'0')",
    record_id "xxd_test1_s.nextval"
    INTO TABLE xxd_test1
    WHEN (1:2) ='99'
    TRAILING NULLCOLS
    testtr POSITION(3:6) CHAR,
    aa POSITION(1:2) INTEGER EXTERNAL ,
    record_id "xxd_test1_s.nextval"
    But it was inserted in the following order
    000012
    000013
    010012
    010012
    020012
    020013
    030012
    030013
    990012
    990013
    Please help me with the solution.
    Thanks
    Sriram.

    Hi Karthick,
    we can do the order by caluse if we are having any column common to all the three levels
    here, for me record_type(first two positions) is the only common. but they may be duplicated in the file.
    Sample Data file
    000012
    01
    01
    02
    03
    99
    000013
    01
    02
    03
    99
    (first two positions represent the heirarchy like 00-header,(01-10)-Detail, 99-Trailer)
    this is sample file,it(detail,trailer) contains some extra fields also...but nothing is common to the header, detail and trailer.Can we generate any value which is common to the three levels? with respective to the header value!
    Looking for you solution..
    Regards,
    Sriram.

  • PL/SQL Code help

    please can anyone explain this code? I need to add some lines to include more dates...
    UPDATE donor_report_t
         SET CUMULATIVE_EXP = (select round(sum (nvl(PERIOD_ACTIVITY_A,0) + nvl(PERIOD_ACTIVITY_E,0) + nvl(PRDOPEN_A,0) + nvl(PRDOPEN_E,0) ),0)
         from PAYMAN.SNP_OP_DETAIL@OFA
    where segment3= p_cc
         and segment2 in (select gl_acct from DONOR_REPORT_ACCT_MAPPING_T
         where cc= p_cc and category = x.category and gl_acct is not null)
         and substr(period_name,-2) < substr(p_period_name,-2) and period_name like 'DEC_ADJ-%' and period_name <> p_period_name )
         where category = x.category and category <> 'Total Receipts';

    Hi,
    Start by formatting the code, so that you can easily see the separate sub-queries and their clauses:
    UPDATE  donor_report_t
    SET      cumulative_exp = (
                               SELECT  ROUND ( SUM ( NVL (period_activity_a, 0)
                                                + NVL (period_activity_e, 0)
                                   + NVL (prdopen_a,        0)
                                   + NVL (prdopen_e,        0)
                                 , 0
                        FROM    payman.snp_op_detail@ofa
                        WHERE   segment3     = p_cc
                        AND     segment2     IN (
                                                   SELECT  gl_acct
                                         FROM    donor_report_acct_mapping_t
                                         WHERE   cc     = p_cc
                                         AND     category = x.category
                                         AND     gl_acct     IS NOT NULL
                        AND     SUBSTR (period_name, -2) < SUBSTR (p_period_name, -2)
                        AND     period_name            LIKE 'DEC_ADJ-%'
                        AND     period_name            != p_period_name     -- I'm guessing this is what you meant
    WHERE    category = x.category
    AND      category != 'Total Receipts'     -- I'm guessing this is what you meant
    ; What exactly does it do? That depends on which columns are in which tables. You should qualify all columns with the table name or alias.
    Is this part of a PL/SQL routine, where x is defined and set before this statement is run? Post the complete routine, or a simplified version that works.

  • Convert decode oracle pl/sq to ms sql and help required on logic

    I have below oracle query need to converted to ms sql. I also want to add a record into journal table when a 
     insert portion is executed  "caseidinserted" and update portion executed then "caseidupdate".
    Update table1 target
    set curr =
    decode(
        select efforts from (
        select source.efforts efforts
          from
            SELECT     a.aid,a.efforts,ab.lcs
                FROM     CIP a, DC ab
                WHERE    a id = ab.id
                AND    a.id = @id
          ) source
          where target.caseid = @caseidupd
          and target.aid = source.aid
        ) tmp, 0, tmp.efforts, curr
    modi = getdate( )
    where exists
    select 1
    from table1 tgt
    where tgt.aid = target.aid
    and tgt.caseid = @caseidupd
    insert into table1 values(caseid, aid, modi)
        select @caseidupd, source.aid, getdate()
          from
            SELECT     a.aid,a.efforts,ab.lcs
                FROM     CIP a, DC ab
                WHERE    a id = ab.id
                AND    a.id = @id
          ) source
        where not exists
            select 1
            from table1 target
            where target.aid = source.aid
            and target.caseid = @caseidupd
    something like this...
    INSERT (caseid,aid,modi)
     select @caseidupd,'appupdated'+source.aid,getdate()
     INSERT (caseid,aid,modi)
      select (@caseidupd,'appinserted'+source.aid,getdate()

    Hello,
    I am not familiar with Oracle Function. If I understand correctly, you can MERGE to perform INSERT and UPDATE operations on a table in a single statement. Please refer to the following statements:
    MERGE INTO table1 AS Target
    USING (select @caseidupd, source.aid, getdate()
    from
    SELECT a.aid,a.efforts,ab.lcs
    FROM CIP a, DC ab
    WHERE a id = ab.id
    AND a.id = @id
    ) As Source (caseidupd,aid,date )
    ON Target.aid = source.aid and target.caseid =source.caseidupd
    WHEN MATCHED THEN
    UPDATE SET Target.curr=...,--query for get values
    Target.modi=getdate()
    WHEN NOT MATCHED BY TARGET THEN
    INSERT (caseid,aid,modi) values (caseidupd,'appupdated'+source.aid,getdate())
    Reference:http://msdn.microsoft.com/en-us/library/bb510625.aspx
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Java inheritance and interface code help required

    please help me I need your 30 mins only,,, working on assignment and I am trying to understand interface and inheritance might not need even 30 mins, please add me on skype *[deleted by moderator]*
    Or add me on
    yahoo msgr *[deleted by moderator]*
    waiting for your help.
    I have no single person friend or I can ask help from who knows java or programming. pretty much want to learn need a friend who can guide me in java.
    unfortunately have to submit assignment tomorrow.
    Thank you in advance for your time and consideration.
    Akee
    *Edited by moderator: EJP on 10/11/2012 10:38: removed your private contact details. This is a public forum, not a personal help desk. Ask your questions here or not at all.*

    Hi,
    there are lot of thread alredy posted please serach
    check following link
    http://help.sap.com/saphelp_nw04/helpdata/en/ce/1d753cab14a909e10000000a11405a/frameset.htm
    XSLT Mapping:
    http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm
    Java Mapping:
    http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/content.htm
    Links of blogs on java mapping...
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-iii
    blog
    /people/sap.user72/blog/2005/03/15/using-xslt-mapping-in-a-ccbpm-scenario
    /people/anish.abraham2/blog/2005/12/22/file-to-multiple-idocs-xslt-mapping(file to xslt mapping)
    /people/pooja.pandey/blog/2005/06/27/xslt-mapping-with-java-enhancement-for-beginners(xslt with java enhancement function)
    Regards,
    Amit

  • SQL Join help required!

    Hi all
    I need help with a join.
    If you click the image link below, I need to find a way to join table 1 and table 2 to get table3:
    http://img229.imageshack.us/img229/1401/83192078uq8.jpg
    Help would be very much appreciated!
    Thanks in advance.

    with Table1 as(select 1234 as ProjectID,'Smith' as LastName from dual
    union select 1234,'Maria' from dual
    union select 1234,'Victo' from dual),
    Table2 as (select 1234 as ProjectID,200 as Val from dual
    union select 1234,300 from dual
    union select 1234,400 from dual)
    select nvl(a.ProjectID,b.ProjectID) as ProjectID,a.LastName,b.Val
      from Table1 a full join Table2 b
        on 1=0;
    PROJECTID  LASTN  VAL
         1234  Maria  null
         1234  Smith  null
         1234  Victo  null
         1234  null    200
         1234  null    300
         1234  null    400

  • User exit code -  help required

    Hi Experts,
    I need to write a user exit for the field Posting level in the query. The logic is ,when posting level is either 10 or 20 for an ITEM then Key figure "Period value GC" should be divided by two and the result shouls be stored in the same Key figure.
    Technical names of the fields are as follows:
    Posting Level - 0cs_plevel . We have created a user exit variable ZBSUSER.
    Item - 0ITEM
    Period Value GC - 0cs_per_gc.
    Please let me know  the code to be written in CMOD to achieve the above result.
    Thanks,
    Kavitha Jagannath

    Hi,
    I need to write a user exit for the field Posting level in the query. The logic is ,when posting level is either 10 or 20 for an ITEM then Key figure "Period value GC" should be divided by two and the result shouls be stored in the same Key figure.
    You can do it in report it self you don't need EXIT CODE.
    Steps:
    1. Create a RKF and restrict (Include)ITEM = 10 and 20 &  drag and dropn Period value GC   " RKF -1
    2. Create another RKF and EXCLUDE ITEM = 10 and 20 &  drag and dropn Period value GC.  " RKF -2
    3. In Columns display both and create Formula-1 and divide RKF-1 with 2.
    4. Create a Formula and add Formula-1 and RKF -2  
    5. Hide unwanted calculations
    Your problem is resloved.
    Thanks
    Reddy
    Edited by: Surendra Reddy on Dec 14, 2009 2:25 PM

  • Help with SQL code

    Hi having a slight problem with some SQL code -
    We store a number of actions they get given a date_done, a Y if we Met_Customer, a Y if we had an Upsell_Apps , a Y if we Upsell_Other, a Y if there was a reference and a Y if there was an issue. The action must have a date, but can have none to any of the Y's
    We want SQL to report back the number of actions (so the count) broken down into the months of the date_done - so Aug 07, Sep 07 etc etc. And this again broken down for Met_customer, Upsell_apps, upsell_other, reference and issue.
    We want it to look something like this...
    Action Type-------------------- Oct06 | Nov06 | Dec06 | Jan07
    Met Customer--------------------12--------8-----------4----------2
    Upsell App-------------------------21--------0-----------1----------3
    Upsell Other-----------------------0---------1-----------3----------1
    Reference---------------------------2---------6----------7----------3
    Issue---------------------------------0----------0----------1----------0
    So if an action on 12-Oc-06 had a Y in Met_customer and Y in Upsell_app it would be counted twice in the above - whereas below it does not work like that...
    At the moment the code is producing something like the following...
    MET_CUST | USPELL_APP | UPSELL_OTHER | REFERENCE | ISSUE | Oct06 | Nov06
    ------Y------------------------------------------------------------------------------------------------------12--------2
    ------Y-------------------Y---------------------------------------------------------------------------------11--------0
    ---------------------------Y----------------------------------------------------------------------------------1---------3
    ------------------------------------------------------Y-------------------------------------------Y----------6---------0
    --------------------------------------------------------------------------------Y-----------------------------2---------1
    ---------------------------------------------------------------------------------------------------Y----------0----------1
    ---------------------------------------------------------------------------------------------------------------1---------1
    This is the code we're using
    SELECT
    ACTION_MET_CUSTOMER,
    ACTION_UPSELL_APPS,
    ACTION_UPSELL_OTHER,
    ACTION_REFERENCE,
    ACTION_ISSUE,
    SUM ( decode( substr(DATE_DONE,-3,1), '-', cnt, null ) ) TOTAL,
    SUM ( decode( substr(DATE_DONE,-6,6), 'OCT-06', cnt, null ) ) OCT06,
    SUM ( decode( substr(DATE_DONE,-6,6), 'NOV-06', cnt, null ) ) NOV06,
    SUM ( decode( substr(DATE_DONE,-6,6), 'DEC-06', cnt, null ) ) DEC06,
    SUM ( decode( substr(DATE_DONE,-6,6), 'JAN-07', cnt, null ) ) JAN07,
    SUM ( decode( substr(DATE_DONE,-6,6), 'FEB-07', cnt, null ) ) FEB07,
    SUM ( decode( substr(DATE_DONE,-6,6), 'MAR-07', cnt, null ) ) MAR07,
    SUM ( decode( substr(DATE_DONE,-6,6), 'APR-07', cnt, null ) ) APR07,
    SUM ( decode( substr(DATE_DONE,-6,6), 'MAY-07', cnt, null ) ) MAY07,
    SUM ( decode( substr(DATE_DONE,-6,6), 'JUN-07', cnt, null ) ) JUN07,
    SUM ( decode( substr(DATE_DONE,-6,6), 'JUL-07', cnt, null ) ) JUL07,
    SUM ( decode( substr(DATE_DONE,-6,6), 'AUG-07', cnt, null ) ) AUG07,
    SUM ( decode( substr(DATE_DONE,-6,6), 'SEP-07', cnt, null ) ) SEP07,
    SUM ( decode( substr(DATE_DONE,-6,6), 'OCT-07', cnt, null ) ) OCT07,
    SUM ( decode( substr(DATE_DONE,-6,6), 'NOV-07', cnt, null ) ) NOV07,
    SUM ( decode( substr(DATE_DONE,-6,6), 'DEC-07', cnt, null ) ) DEC07,
    SUM ( decode( substr(DATE_DONE,-6,6), 'JAN-08', cnt, null ) ) JAN08,
    SUM ( decode( substr(DATE_DONE,-6,6), 'FEB-08', cnt, null ) ) FEB08,
    SUM ( decode( substr(DATE_DONE,-6,6), 'MAR-08', cnt, null ) ) MAR08,
    SUM ( decode( substr(DATE_DONE,-6,6), 'APR-08', cnt, null ) ) APR08,
    SUM ( decode( substr(DATE_DONE,-6,6), 'MAY-08', cnt, null ) ) MAY08
    FROM
    (SELECT ACTION_MET_CUSTOMER, ACTION_UPSELL_APPS, ACTION_UPSELL_OTHER, ACTION_REFERENCE, ACTION_ISSUE, DATE_DONE, COUNT(*) CNT FROM ACTIONS, EMPLOYEE
    WHERE ACTION_OWNER = NAME
    GROUP BY ACTION_MET_CUSTOMER, ACTION_UPSELL_APPS, ACTION_UPSELL_OTHER, ACTION_REFERENCE, ACTION_ISSUE, DATE_DONE)
    GROUP BY
    ACTION_MET_CUSTOMER, ACTION_UPSELL_APPS, ACTION_UPSELL_OTHER, ACTION_REFERENCE, ACTION_ISSUE
    Any ideas to get it looking how id ideally like it?
    Cheers, would be a great help
    S

    select 'Met Customer' action_type,
    to_char(date_done,'MON-YY') date_done,
    action_owner,
    COUNT(1)
    from ff_actions
    where action_met_customer = 'Y'
    group by action_met_customer
    UNION
    select 'Upsell Apps' action_type,
    to_char(date_done,'MON-YY') date_done,
    action_owner,
    COUNT(1)
    from ff_actions
    where action_upsell_apps = 'Y'
    group by action_upsell_apps
    UNION
    select 'Upsell Other' action_type,
    to_char(date_done,'MON-YY') date_done,
    action_owner,
    COUNT(1)
    from ff_actions
    where action_upsell_other = 'Y'
    group by action_upsell_other
    UNION
    select 'Reference' action_type,
    to_char(date_done,'MON-YY') date_done,
    action_owner,
    COUNT(1)
    from ff_actions
    where action_reference = 'Y'
    group by action_reference
    UNION
    select 'Issue' action_type,
    to_char(date_done,'MON-YY') date_done,
    action_owner,
    COUNT(1)
    from ff_actions
    where action_issue = 'Y'
    group by action_issue
    now error...
    ORA-00979: not a GROUP BY expression

  • Help Required with PL/SQL loading logic

    Hi All,
    We have a simple pl/sql code which does loading(insertions) of records into the table. This pl/sql code actually refers to an translation website URL(microsoft based) and inserts the translated text into our table. What happens is sometimes this URL gets blocked out due to some issue. So we are forced to restart our entire operation of loading once again. Actually we have a commit at the end(outside the loop). on the other hand we cant keep commit inside the loop as it may pose an overhead to performance since its commiting once every insert happens.
    What we are expecting is something like this. Say we have 10,000 records. the loading fails at 5500 record. next time when we start again we want to start from 5501 record and NOT from beginning. In informatica kind of ETL tools we have an option to do this. However not sure if we can do this through PL/SQL.
    we thought of keeping counter variable and keep it incrementing for each and every insert happens. but before doing this we have to order by our table according to primary key. This is taking huge amount of time since the table is very big.
    can you please tell any alternative to this?
    Regards,
    Paul

    If I understand correctly, you are doing something as follows:
    // process a defined data set
    for c in (select .. some data... ) 
    loop
        // translate the data (via a web service call)
        Translate( c, translatedOutput )
        // insert the translated data
        insert into some_table translatedOutput
    end loop
    commitIn principle, nothing wrong with this approach. And yes, committing inside the loop for every x number of rows will increase the complexity of code and could perhaps violate ANSI SQL standards of fetching across commits.
    A better approach would be to consider parallelising this process. Run multiple copies of that code - but provide each copy of the code with a small and unique data set to process. So instead of doing 10,000 rows in serial, you schedule a 100 jobs and give each a unique set of a 100 rows to translate.
    Let's say your job queue size is set to 20. This means up to 20 of these processes will run in parallel. Should one fail, the job manager will automatically reschedule it for execution (up to 16 times after which it will be marked as broken).
    So not only does this type of approach enables you spread the processing load, it also enables you to scale your processing (you can handle much larger data volumes like this, and more powerful server h/w will enable you to use more parallel processes). In addition, restart is automated courtesy of the Oracle job manager.
    Compare this type approach with committing inside a loop.. The latter buys you what ito flexibility and performance and scalability? Nothing really - it only makes the process a lot more complex as it needs to be able to correctly restart after a failure. You will not be able to process bigger volumes of data. You will not be able to increase existing performance.
    One needs to carefully consider the approach used to processing data - serialisation is inherently limited. Restarting serialised processes is difficult and complex.

  • Sql tuning help

    Hi,
    I need some help on tuning this sql. We run a third party application and I have to ask thrid party for any changes. I have pasted the session statistice from the run for this sql.
    SELECT DECODE( RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,
    ' ')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' '),
    RPAD(NVL(:zipout1,' '),4,' ')||RPAD(NVL(:zipin1,' '),3,' '),
    '0001', RPAD(NVL(:zipout2,' '),4,'
    ')||RPAD(SUBSTR(NVL(:zipin2,' '),0,1),3,' '), '0002',
    RPAD(NVL(:zipout3,' '),7,' '), '0003',
    RPAD('ZZ999',7,' '), '0004' ) AS CHECKER
    FROM NWKPCDREC
    WHERE NWKPCDNETWORKID = :netid
    AND NWKPCDSORTPOINT1TYPE != 'XXXXXXXX'
    AND ( (RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,' ')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' ') =
    RPAD(NVL(:zipout4,' '),4,' ')||RPAD(NVL(:zipin3,' '),3,' '))
    OR (RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,'
    ')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' ') =
    RPAD(NVL(:zipout5,' '),4,' ')||RPAD(SUBSTR(NVL(:zipin4,' '),0,
    1),3,' ')) OR (RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,'
    ')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' ') =
    RPAD(NVL(:zipout6,' '),7,' ')) OR
    (RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,'
    ')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' ') = RPAD('ZZ999',7,
    ' ')) ) ORDER BY CHECKER
    Session Statistics 09 October 2007 22:44:56 GMT+00:00
    Report Target : PRD1 (Database)
    Session Statistics
    (Chart form was tabular, see data table below)
    SID Name Value Class
    37 write clones created in foreground 0 Cache
    37 write clones created in background 0 Cache
    37 user rollbacks 16 User
    37 user commits 8674 User
    37 user calls 302838 User
    37 transaction tables consistent reads - undo records applied 0 Debug
    37 transaction tables consistent read rollbacks 0 Debug
    37 transaction rollbacks 9 Debug
    37 transaction lock foreground wait time 0 Debug
    37 transaction lock foreground requests 0 Debug
    37 transaction lock background gets 0 Debug
    37 transaction lock background get time 0 Debug
    37 total file opens 12 Cache
    37 table scans (short tables) 8062 SQL
    37 table scans (rowid ranges) 0 SQL
    37 table scans (long tables) 89 SQL
    37 table scans (direct read) 0 SQL
    37 table scans (cache partitions) 2 SQL
    37 table scan rows gotten 487042810 SQL
    37 table scan blocks gotten 7327924 SQL
    37 table fetch continued row 17 SQL
    37 table fetch by rowid 26130550 SQL
    37 switch current to new buffer 6400 Cache
    37 summed dirty queue length 0 Cache
    37 sorts (rows) 138607 SQL
    37 sorts (memory) 13418 SQL
    37 sorts (disk) 0 SQL
    37 session uga memory max 5176776 User
    37 session uga memory 81136 User
    37 session stored procedure space 0 User
    37 session pga memory max 5559884 User
    37 session pga memory 5559884 User
    37 session logical reads 115050107 User
    37 session cursor cache hits 0 SQL
    37 session cursor cache count 0 SQL
    37 session connect time 1191953042 User
    37 serializable aborts 0 User
    37 rows fetched via callback 1295545 SQL
    37 rollbacks only - consistent read gets 0 Debug
    37 rollback changes - undo records applied 114 Debug
    37 remote instance undo header writes 0 Global Cache
    37 remote instance undo block writes 0 Global Cache
    37 redo writes 0 Redo
    37 redo writer latching time 0 Redo
    37 redo write time 0 Redo
    37 redo wastage 0 Redo
    37 redo synch writes 8683 Cache
    37 redo synch time 722 Cache
    37 redo size 25463692 Redo
    37 redo ordering marks 0 Redo
    37 redo log switch interrupts 0 Redo
    37 redo log space wait time 0 Redo
    37 redo log space requests 1 Redo
    37 redo entries 81930 Redo
    37 redo buffer allocation retries 1 Redo
    37 redo blocks written 0 Redo
    37 recursive cpu usage 101 User
    37 recursive calls 84413 User
    37 recovery blocks read 0 Cache
    37 recovery array reads 0 Cache
    37 recovery array read time 0 Cache
    37 queries parallelized 0 Parallel Server
    37 process last non-idle time 1191953042 Debug
    37 prefetched blocks aged out before use 0 Cache
    37 prefetched blocks 1436767 Cache
    37 pinned buffers inspected 89 Cache
    37 physical writes non checkpoint 3507 Cache
    37 physical writes direct (lob) 0 Cache
    37 physical writes direct 3507 Cache
    37 physical writes 3507 Cache
    37 physical reads direct (lob) 0 Cache
    37 physical reads direct 2499 Cache
    37 physical reads 1591668 Cache
    37 parse time elapsed 336 SQL
    37 parse time cpu 315 SQL
    37 parse count (total) 28651 SQL
    37 parse count (hard) 1178 SQL
    37 opens requiring cache replacement 0 Cache
    37 opens of replaced files 0 Cache
    37 opened cursors current 51 User
    37 opened cursors cumulative 28651 User
    37 no work - consistent read gets 59086317 Debug
    37 no buffer to keep pinned count 0 Other
    37 next scns gotten without going to DLM 0 Parallel Server
    37 native hash arithmetic fail 0 SQL
    37 native hash arithmetic execute 0 SQL
    37 messages sent 9730 Debug
    37 messages received 0 Debug
    37 logons current 1 User
    37 logons cumulative 1 User
    37 leaf node splits 111 Debug
    37 kcmgss waited for batching 0 Parallel Server
    37 kcmgss read scn without going to DLM 0 Parallel Server
    37 kcmccs called get current scn 0 Parallel Server
    37 instance recovery database freeze count 0 Parallel Server
    37 index fast full scans (rowid ranges) 0 SQL
    37 index fast full scans (full) 210 SQL
    37 index fast full scans (direct read) 0 SQL
    37 immediate (CURRENT) block cleanout applications 4064 Debug
    37 immediate (CR) block cleanout applications 83 Debug
    37 hot buffers moved to head of LRU 20004 Cache
    37 global lock sync gets 0 Parallel Server
    37 global lock sync converts 0 Parallel Server
    37 global lock releases 0 Parallel Server
    37 global lock get time 0 Parallel Server
    37 global lock convert time 0 Parallel Server
    37 global lock async gets 0 Parallel Server
    37 global lock async converts 0 Parallel Server
    37 global cache read buffer lock timeouts 0 Global Cache
    37 global cache read buffer blocks served 0 Global Cache
    37 global cache read buffer blocks received 0 Global Cache
    37 global cache read buffer block timeouts 0 Global Cache
    37 global cache read buffer block send time 0 Global Cache
    37 global cache read buffer block receive time 0 Global Cache
    37 global cache read buffer block build time 0 Global Cache
    37 global cache prepare failures 0 Global Cache
    37 global cache gets 0 Global Cache
    37 global cache get time 0 Global Cache
    37 global cache freelist waits 0 Global Cache
    37 global cache defers 0 Global Cache
    37 global cache cr timeouts 0 Global Cache
    37 global cache cr requests blocked 0 Global Cache
    37 global cache cr blocks served 0 Global Cache
    37 global cache cr blocks received 0 Global Cache
    37 global cache cr block send time 0 Global Cache
    37 global cache cr block receive time 0 Global Cache
    37 global cache cr block flush time 0 Global Cache
    37 global cache cr block build time 0 Global Cache
    37 global cache converts 0 Global Cache
    37 global cache convert timeouts 0 Global Cache
    37 global cache convert time 0 Global Cache
    37 global cache blocks corrupt 0 Global Cache
    37 free buffer requested 1597281 Cache
    37 free buffer inspected 659 Cache
    37 execute count 128826 SQL
    37 exchange deadlocks 1 Cache
    37 enqueue waits 0 Enqueue
    37 enqueue timeouts 0 Enqueue
    37 enqueue requests 23715 Enqueue
    37 enqueue releases 23715 Enqueue
    37 enqueue deadlocks 0 Enqueue
    37 enqueue conversions 0 Enqueue
    37 dirty buffers inspected 437 Cache
    37 deferred (CURRENT) block cleanout applications 21937 Debug
    37 db block gets 230801 Cache
    37 db block changes 160407 Cache
    37 data blocks consistent reads - undo records applied 460 Debug
    37 cursor authentications 488 Debug
    37 current blocks converted for CR 0 Cache
    37 consistent gets 114819307 Cache
    37 consistent changes 460 Cache
    37 commit cleanouts successfully completed 37201 Cache
    37 commit cleanouts 37210 Cache
    37 commit cleanout failures: write disabled 0 Cache
    37 commit cleanout failures: hot backup in progress 0 Cache
    37 commit cleanout failures: cannot pin 0 Cache
    37 commit cleanout failures: callback failure 3 Cache
    37 commit cleanout failures: buffer being written 0 Cache
    37 commit cleanout failures: block lost 6 Cache
    37 cold recycle reads 0 Cache
    37 cluster key scans 17 SQL
    37 cluster key scan block gets 36 SQL
    37 cleanouts only - consistent read gets 83 Debug
    37 cleanouts and rollbacks - consistent read gets 0 Debug
    37 change write time 108 Cache
    37 calls to kcmgrs 0 Debug
    37 calls to kcmgcs 391 Debug
    37 calls to kcmgas 8816 Debug
    37 calls to get snapshot scn: kcmgss 171453 Parallel Server
    37 bytes sent via SQL*Net to dblink 0 User
    37 bytes sent via SQL*Net to client 25363874 User
    37 bytes received via SQL*Net from dblink 0 User
    37 bytes received via SQL*Net from client 29829542 User
    37 buffer is pinned count 540816 Other
    37 buffer is not pinned count 86108905 Other
    37 branch node splits 6 Debug
    37 background timeouts 0 Debug
    37 background checkpoints started 0 Cache
    37 background checkpoints completed 0 Cache
    37 Unnecesary process cleanup for SCN batching 0 Parallel Server
    37 SQL*Net roundtrips to/from dblink 0 User
    37 SQL*Net roundtrips to/from client 302837 User
    37 Parallel operations not downgraded 0 Parallel Server
    37 Parallel operations downgraded to serial 0 Parallel Server
    37 Parallel operations downgraded 75 to 99 pct 0 Parallel Server
    37 Parallel operations downgraded 50 to 75 pct 0 Parallel Server
    37 Parallel operations downgraded 25 to 50 pct 0 Parallel Server
    37 Parallel operations downgraded 1 to 25 pct 0 Parallel Server
    37 PX remote messages sent 0 Parallel Server
    37 PX remote messages recv'd 0 Parallel Server
    37 PX local messages sent 0 Parallel Server
    37 PX local messages recv'd 0 Parallel Server
    37 OS Voluntary context switches 0 OS
    37 OS User time used 0 OS
    37 OS System time used 0 OS
    37 OS Swaps 0 OS
    37 OS Socket messages sent 0 OS
    37 OS Socket messages received 0 OS
    37 OS Signals received 0 OS
    37 OS Page reclaims 0 OS
    37 OS Page faults 0 OS
    37 OS Maximum resident set size 0 OS
    37 OS Involuntary context switches 0 OS
    37 OS Integral unshared stack size 0 OS
    37 OS Integral unshared data size 0 OS
    37 OS Integral shared text size 0 OS
    37 OS Block output operations 0 OS
    37 OS Block input operations 0 OS
    37 DML statements parallelized 0 Parallel Server
    37 DFO trees parallelized 0 Parallel Server
    37 DDL statements parallelized 0 Parallel Server
    37 DBWR undo block writes 0 Cache
    37 DBWR transaction table writes 0 Cache
    37 DBWR summed scan depth 0 Cache
    37 DBWR revisited being-written buffer 0 Cache
    37 DBWR make free requests 0 Cache
    37 DBWR lru scans 0 Cache
    37 DBWR free buffers found 0 Cache
    37 DBWR cross instance writes 0 Global Cache
    37 DBWR checkpoints 0 Cache
    37 DBWR checkpoint buffers written 0 Cache
    37 DBWR buffers scanned 0 Cache
    37 Commit SCN cached 0 Debug
    37 Cached Commit SCN referenced 1 Debug
    37 CR blocks created 203 Cache
    37 CPU used when call started 280528 Debug
    37 CPU used by this session 280528 User
    Regards
    Raj
    --------------------------------------------------------------------------------

    Thank you everybody for helping me out while tuning the query. I have managed to bring down the run time from 60 minutes to 12 minutes.
    I am posting the exisitng query, existing database objects ddl and the new query and new ddl to share my learning. This is my first use of forum, senior members, please letme know if I shouldn't have put all this here.
    /pre original code
    SELECT decode(rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
    a.nwkpcdinwdpostcode, ' '), 3, ' '), rpad(nvl(:zipout1, ' '), 4, ' ')
    || rpad(nvl(:zipin1, ' '), 3, ' '), '0001', rpad(nvl(:zipout2, ' '), 4,
    ' ') || rpad(substr(nvl(:zipin2, ' '), 0, 1), 3, ' '), '0002',
    rpad(nvl(:zipout3, ' '), 7, ' '), '0003', rpad('ZZ999', 7, ' '), '0004')
    AS checker, a.nwkpcdbarcode1to7 nwkpcdbarcode1to7,
    a.nwkpcdbarcode15 nwkpcdbarcode15,
    a.nwkpcdbarcodeseqkey nwkpcdbarcodeseqkey,
    a.nwkpcdsortpoint1code nwkpcdsortpoint1code,
    a.nwkpcdsortpoint1type nwkpcdsortpoint1type,
    a.nwkpcdsortpoint1name nwkpcdsortpoint1name,
    a.nwkpcdsortpoint1extra nwkpcdsortpoint1extra,
    a.nwkpcdsortpoint2type nwkpcdsortpoint2type,
    a.nwkpcdsortpoint2name nwkpcdsortpoint2name,
    a.nwkpcdsortpoint3type nwkpcdsortpoint3type,
    a.nwkpcdsortpoint3name nwkpcdsortpoint3name,
    a.nwkpcdsortpoint4type nwkpcdsortpoint4type,
    a.nwkpcdsortpoint4name nwkpcdsortpoint4name,
    b.nwkprfnetworksequence nwkprfnetworksequence,
    b.nwkprfnetworkid nwkprfnetworkid, b.nwkprfnetworkname nwkprfnetworkname,
    b.nwkprfminweight / 100 AS nwkprfminweight, b.nwkprfmaxweight / 100 AS
    nwkprfmaxweight, b.nwkprfminlengthgirth nwkprfminlengthgirth,
    b.nwkprfmaxlengthgirth nwkprfmaxlengthgirth,
    b.nwkprfminlength nwkprfminlength, b.nwkprfmaxlength nwkprfmaxlength,
    b.nwkprfparceltypecode nwkprfparceltypecode,
    b.nwkprfparceltypename nwkprfparceltypename
    FROM wh1.nwkpcdrec a, wh1.nwkprefrec b
    WHERE a.nwkpcdnetworkid = b.nwkprfnetworkid
    AND a.nwkpcdsortpoint1type != 'XXXXXXXX'
    AND (rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
    a.nwkpcdinwdpostcode, ' '), 3, ' ') = rpad(nvl(:zipout4, ' '), 4, ' '
    ) || rpad(nvl(:zipin3, ' '), 3, ' ')
    OR rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
    a.nwkpcdinwdpostcode, ' '), 3, ' ') = rpad(nvl(:zipout5, ' '), 4, ' '
    ) || rpad(substr(nvl(:zipin4, ' '), 0, 1), 3, ' ')
    OR rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
    a.nwkpcdinwdpostcode, ' '), 3, ' ') = rpad(nvl(:zipout6, ' '), 7, ' '
    OR rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
    a.nwkpcdinwdpostcode, ' '), 3, ' ') = rpad('ZZ999', 7, ' '))
    AND :weight1 >= b.nwkprfminweight
    AND :weight2 <= b.nwkprfmaxweight
    AND b.nwkprfminlengthgirth <= 60
    AND b.nwkprfmaxlengthgirth >= 60
    AND b.nwkprfminlength <= 15
    AND b.nwkprfmaxlength >= 15
    ORDER BY b.nwkprfnetworkid, checker
    CREATE TABLE "WH1"."NWKPCDREC" ("NWKPCDFILECODE" VARCHAR2(2),
    "NWKPCDRECORDTYPE" VARCHAR2(4), "NWKPCDNETWORKID" VARCHAR2(2),
    "NWKPCDOUTWDPOSTCODE" VARCHAR2(4), "NWKPCDINWDPOSTCODE"
    VARCHAR2(3), "NWKPCDSORTPOINT1CODE" VARCHAR2(2),
    "NWKPCDSORTPOINT1TYPE" VARCHAR2(8), "NWKPCDSORTPOINT1NAME"
    VARCHAR2(16), "NWKPCDSORTPOINT1EXTRA" VARCHAR2(16),
    "NWKPCDSORTPOINT2TYPE" VARCHAR2(8), "NWKPCDSORTPOINT2NAME"
    VARCHAR2(8), "NWKPCDSORTPOINT3TYPE" VARCHAR2(8),
    "NWKPCDSORTPOINT3NAME" VARCHAR2(8), "NWKPCDSORTPOINT4TYPE"
    VARCHAR2(8), "NWKPCDSORTPOINT4NAME" VARCHAR2(8), "NWKPCDPPI"
    VARCHAR2(8), "NWKPCDBARCODE1TO7" VARCHAR2(7),
    "NWKPCDBARCODE15" VARCHAR2(1), "NWKPCDBARCODESEQKEY"
    VARCHAR2(7), "NWKPCDFILLER1" VARCHAR2(7), "NWKPCDFILLER2"
    VARCHAR2(30),
    CONSTRAINT "UK_NWKPCDREC" UNIQUE("NWKPCDNETWORKID",
    "NWKPCDOUTWDPOSTCODE", "NWKPCDINWDPOSTCODE")
    USING INDEX
    TABLESPACE "WH1_INDEX"
    STORAGE ( INITIAL 64K NEXT 0K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
    PCTFREE 10 INITRANS 2 MAXTRANS 255)
    TABLESPACE "WH1_DATA_LARGE" PCTFREE 10 PCTUSED 40 INITRANS 1
    MAXTRANS 255
    STORAGE ( INITIAL 4096K NEXT 4096K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
    NOLOGGING
    pre original script/
    /pre modified script
    CREATE TABLE "WH1"."NWKPCEREC_OLD" ("NWKPCDFILECODE" VARCHAR2(2),
    "NWKPCDRECORDTYPE" VARCHAR2(4), "NWKPCDNETWORKID" VARCHAR2(2),
    "NWKPCDOUTWDPOSTCODE" VARCHAR2(4), "NWKPCDINWDPOSTCODE"
    VARCHAR2(3), "NWKPCDSORTPOINT1CODE" VARCHAR2(2),
    "NWKPCDSORTPOINT1TYPE" VARCHAR2(8), "NWKPCDSORTPOINT1NAME"
    VARCHAR2(16), "NWKPCDSORTPOINT1EXTRA" VARCHAR2(16),
    "NWKPCDSORTPOINT2TYPE" VARCHAR2(8), "NWKPCDSORTPOINT2NAME"
    VARCHAR2(8), "NWKPCDSORTPOINT3TYPE" VARCHAR2(8),
    "NWKPCDSORTPOINT3NAME" VARCHAR2(8), "NWKPCDSORTPOINT4TYPE"
    VARCHAR2(8), "NWKPCDSORTPOINT4NAME" VARCHAR2(8), "NWKPCDPPI"
    VARCHAR2(8), "NWKPCDBARCODE1TO7" VARCHAR2(7),
    "NWKPCDBARCODE15" VARCHAR2(1), "NWKPCDBARCODESEQKEY"
    VARCHAR2(7), "NWKPCDFILLER1" VARCHAR2(7), "NWKPCDFILLER2"
    VARCHAR2(30))
    TABLESPACE "WH1_DATA_LARGE" PCTFREE 10 PCTUSED 40 INITRANS 1
    MAXTRANS 255
    STORAGE ( INITIAL 4096K NEXT 4096K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
    NOLOGGING
    insert into wh1.nwkpcdrec_old select * from wh1.nwkpcdrec;
    drop table wh1.nwkpcdrec;
    CREATE TABLE "WH1"."NWKPCDREC" ("NWKPCDFILECODE" VARCHAR2(2),
    "NWKPCDRECORDTYPE" VARCHAR2(4), "NWKPCDNETWORKID" VARCHAR2(2),
    "NWKPCDOUTINWDPOSTCODE" VARCHAR2(7) NOT NULL,
    "NWKPCDOUTWDPOSTCODE" VARCHAR2(4), "NWKPCDINWDPOSTCODE"
    VARCHAR2(3), "NWKPCDSORTPOINT1CODE" VARCHAR2(2),
    "NWKPCDSORTPOINT1TYPE" VARCHAR2(8), "NWKPCDSORTPOINT1NAME"
    VARCHAR2(16), "NWKPCDSORTPOINT1EXTRA" VARCHAR2(16),
    "NWKPCDSORTPOINT2TYPE" VARCHAR2(8), "NWKPCDSORTPOINT2NAME"
    VARCHAR2(8), "NWKPCDSORTPOINT3TYPE" VARCHAR2(8),
    "NWKPCDSORTPOINT3NAME" VARCHAR2(8), "NWKPCDSORTPOINT4TYPE"
    VARCHAR2(8), "NWKPCDSORTPOINT4NAME" VARCHAR2(8), "NWKPCDPPI"
    VARCHAR2(8), "NWKPCDBARCODE1TO7" VARCHAR2(7),
    "NWKPCDBARCODE15" VARCHAR2(1), "NWKPCDBARCODESEQKEY"
    VARCHAR2(7), "NWKPCDFILLER1" VARCHAR2(7), "NWKPCDFILLER2"
    VARCHAR2(30))
    TABLESPACE "WH1_DATA_LARGE" PCTFREE 10 PCTUSED 40 INITRANS 1
    MAXTRANS 255
    STORAGE ( INITIAL 4096K NEXT 4096K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
    NOLOGGING
    INSERT INTO WH1.NWKPCDREC SELECT
                   NWKPCDFILECODE,
                   NWKPCDRECORDTYPE,
                   NWKPCDNETWORKID,
                   rpad(nvl(nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(nwkpcdinwdpostcode, ' '), 3, ' '),
                   nwkpcdoutwdpostcode,
                   nwkpcdinwdpostcode,
                   NWKPCDSORTPOINT1CODE,
                   NWKPCDSORTPOINT1TYPE,
                   NWKPCDSORTPOINT1NAME,
                   NWKPCDSORTPOINT1EXTRA,
                   NWKPCDSORTPOINT2TYPE,
                   NWKPCDSORTPOINT2NAME,
                   NWKPCDSORTPOINT3TYPE,
                   NWKPCDSORTPOINT3NAME,
                   NWKPCDSORTPOINT4TYPE,
                   NWKPCDSORTPOINT4NAME,
                   NWKPCDPPI,
                   NWKPCDBARCODE1TO7,
                   NWKPCDBARCODE15,
                   NWKPCDBARCODESEQKEY,
                   NWKPCDFILLER1,
                   NWKPCDFILLER2
    FROM WH1.NWKPCDREC_OLD;
    CREATE UNIQUE INDEX "WH1"."UK_NWKPCDREC"
    ON "WH1"."NWKPCDREC" ("NWKPCDNETWORKID",
    "NWKPCDOUTINWDPOSTCODE")
    TABLESPACE "WH1_INDEX" PCTFREE 10 INITRANS 2 MAXTRANS
    255
    STORAGE ( INITIAL 8192K NEXT 8192K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
    LOGGING
    begin
    dbms_stats.gather_table_stats(ownname=> 'WH1', tabname=> 'NWKPCDREC', partname=> NULL);
    end;
    begin
    dbms_stats.gather_index_stats(ownname=> 'WH1', indname=> 'UK_NWKPCDREC', partname=> NULL);
    end;
    SELECT decode(a.nwkpcdoutinwdpostcode, rpad(nvl(:zipout1, ' '), 4, ' ') ||
    rpad(nvl(:zipin1, ' '), 3, ' '), '0001', rpad(nvl(:zipout2, ' '), 4, ' '
    ) || rpad(substr(nvl(:zipin2, ' '), 0, 1), 3, ' '), '0002', rpad(
    nvl(:zipout3, ' '), 7, ' '), '0003', rpad('ZZ999', 7, ' '), '0004') AS
    checker, a.nwkpcdbarcode1to7 nwkpcdbarcode1to7,
    a.nwkpcdbarcode15 nwkpcdbarcode15,
    a.nwkpcdbarcodeseqkey nwkpcdbarcodeseqkey,
    a.nwkpcdsortpoint1code nwkpcdsortpoint1code,
    a.nwkpcdsortpoint1type nwkpcdsortpoint1type,
    a.nwkpcdsortpoint1name nwkpcdsortpoint1name,
    a.nwkpcdsortpoint1extra nwkpcdsortpoint1extra,
    a.nwkpcdsortpoint2type nwkpcdsortpoint2type,
    a.nwkpcdsortpoint2name nwkpcdsortpoint2name,
    a.nwkpcdsortpoint3type nwkpcdsortpoint3type,
    a.nwkpcdsortpoint3name nwkpcdsortpoint3name,
    a.nwkpcdsortpoint4type nwkpcdsortpoint4type,
    a.nwkpcdsortpoint4name nwkpcdsortpoint4name,
    b.nwkprfnetworksequence nwkprfnetworksequence,
    b.nwkprfnetworkid nwkprfnetworkid, b.nwkprfnetworkname nwkprfnetworkname,
    b.nwkprfminweight / 100 AS nwkprfminweight, b.nwkprfmaxweight / 100 AS
    nwkprfmaxweight, b.nwkprfminlengthgirth nwkprfminlengthgirth,
    b.nwkprfmaxlengthgirth nwkprfmaxlengthgirth,
    b.nwkprfminlength nwkprfminlength, b.nwkprfmaxlength nwkprfmaxlength,
    b.nwkprfparceltypecode nwkprfparceltypecode,
    b.nwkprfparceltypename nwkprfparceltypename
    FROM wh1.nwkpcdrec a, wh1.nwkprefrec b
    WHERE a.nwkpcdnetworkid = b.nwkprfnetworkid
    AND a.nwkpcdoutinwdpostcode IN (rpad(nvl(:zipout4, ' '), 4, ' ') ||
    rpad(nvl(:zipin3, ' '), 3, ' '), rpad(nvl(:zipout5, ' '), 4, ' ')
    || rpad(substr(nvl(:zipin4, ' '), 0, 1), 3, ' '), rpad(nvl(:zipout6,
    ' '), 7, ' '), rpad('ZZ999', 7, ' '))
    AND a.nwkpcdsortpoint1type != 'XXXXXXXX'
    AND :weight1 >= b.nwkprfminweight
    AND :weight2 <= b.nwkprfmaxweight
    AND b.nwkprfminlengthgirth <= 60
    AND b.nwkprfmaxlengthgirth >= 60
    AND b.nwkprfminlength <= 15
    AND b.nwkprfmaxlength >= 15
    ORDER BY b.nwkprfnetworkid, checker
    pre modified script/

  • Getting error while compiling this pl/sql code

    Hi,
    I am trying to execute the below block of pl/sql code and i encountering an error. i tried all possible combination of paranthesis and quotes. still giving error. can someone please help?
    IF inserting THEN
    pk_imdb_audit.p_ins_characteristic_a_t
    (in_'||rpad(column_name,35,' ')||'=> pk_imdb_audit.v_action_inserting,'
    WHEN max_col = column_id THEN
    in_'||rpad(column_name,35,' ')||'=> '||lower(in_col_value)||');'
    ELSE
    ' in_'||rpad(column_name,35,' ')||'=> '||lower(in_col_value)||','
    END text,
    table_name,
    column_id,
    2 disp_ord
    error snapshot:-
    ORA-06550: line 14, column 14:
    PLS-00103: Encountered the symbol "||rpad(column_name,35," when expecting one of the following:
    . ( ) , * @ % & | = - + < / > at in is mod remainder not
    range rem => .. <an exponent (**)> <> or != or ~= >= <= <>
    and or like LIKE2_ LIKE4_ LIKEC_ as between from using ||
    multiset member SUBMULTISET_
    The symbol "( was inserted before "||rpad(column_name,35," to continue.
    ORA-06550: line 15, column 13:
    PLS-00103: Encountered the symbol "WHEN" when expecting one of th

    Hi,
    here is a 'parseable' version of your query, but there is numerous ways to improve what you want to do (not sure even if the query is giving you what you're expecting from it):
    SELECT text
    FROM   (SELECT (CASE
                       WHEN min_col = max_col THEN    'CREATE OR REPLACE TRIGGER '
                                                   || SUBSTR(column_name,
                                                             1,
                                                             4
                                                   || 'aud
    AFTER INSERT
    OR UPDATE
    OF '
                                                   || column_name
                                                   || ',
    OR DELETE ON imdb.'
                                                   || table_name
                                                   || '
    FOR EACH ROW'
                       ELSE(CASE
                               WHEN min_col = column_id THEN    'CREATE OR REPLACE TRIGGER '
                                                             || SUBSTR(column_name,
                                                                       1,
                                                                       4
                                                             || 'aud
    AFTER INSERT
    OR UPDATE
    OF '
                                                             || column_name
                                                             || ','
                               ELSE(CASE
                                       WHEN max_col = column_id THEN    ' '
                                                                     || column_name
                                                                     || '
    OR DELETE ON imdb.'
                                                                     || table_name
                                                                     || '
    FOR EACH ROW'
                                       ELSE(CASE
                                               WHEN column_id IS NULL THEN    'CREATE OR REPLACE TRIGGER '
                                                                           || SUBSTR
                                                                                 (column_name,
                                                                                  1,
                                                                                  4
                                                                           || 'aud
    AFTER INSERT
    OR UPDATE
    OR DELETE ON imdb.'
                                                                           || table_name
                                               ELSE    ' '
                                                    || column_name
                                                    || ','
                                            END
                                    END
                            END
                    END
                   ) text,
                   table_name1 table_name,
                   column_id,
                   1 disp_ord
            FROM   (SELECT LOWER(REPLACE(column_name,
                                         'O_',
                                        )) column_name,                   /*changing O to O_*/
                           LOWER(REPLACE(t.table_name,
                                         '_A_',
                                        )) table_name,
                           LOWER(t.table_name) table_name1,
                           c.column_id,
                           MIN(column_id) OVER(PARTITION BY c.table_name) min_col,
                           MAX(column_id) OVER(PARTITION BY c.table_name) max_col
                    FROM   all_tab_columns c,
                           (SELECT object_name table_name
                            FROM   all_objects
                            WHERE  TRUNC(created) = TRUNC(SYSDATE)
                            AND    object_name = 'CHARACTERISTIC_A_T') t
    --AND object_name LIKE 'IMDB/_A/_%' ESCAPE '/') t /*commented this line for testing*/
                    WHERE  c.table_name(+) = t.table_name
                    AND    SUBSTR(column_name(+),
                                  1,
                                  2
                                 ) = 'O_'))
              /*changed the substring condition to match new changes*/
    UNION ALL
    SELECT (CASE
               WHEN min_col = column_id THEN    'DECLARE
    BEGIN
    IF inserting THEN
    pk_imdb_audit.p_ins_characteristic_a_t
    (in_'
                                             || RPAD(column_name,
                                                     35,
                                             || '=> pk_imdb_audit.v_action_inserting,'
               ELSE(CASE
                       WHEN max_col = column_id THEN    'in_'
                                                     || RPAD(column_name,
                                                             35,
                                                     || '=> '
                                                     || LOWER(in_col_value)
                                                     || ');'
                       ELSE    ' in_'
                            || RPAD(column_name,
                                    35,
                            || '=> '
                            || LOWER(in_col_value)
                            || ','
                    END
            END
           ) text /*,
           table_name,
           column_id,
           2 disp_ord*/
    FROM   (SELECT table_name,
                   column_name,
                   column_id,
                   min_col,
                   max_col,
                   in_col_value,
                   trg_header,
                      'in_'
                   || RPAD(column_name,
                           35,
                   || '=> '
                   || LOWER(in_col_value)
                   || ',' in_col
            FROM   (SELECT   LOWER(c.column_name) column_name,
                             LOWER(c.table_name) table_name,
                             c.column_id,
                             (CASE
                                 WHEN SUBSTR(column_name,
                                             1,
                                             2
                                            ) = 'N_' THEN
                                   /*changed the substring condition to match the new change*/
                                                            ':NEW.'
                                                         || REPLACE
                                                               (column_name,
                                                                'N_',
                                                                'N_'
                                            /*changed the condition to match new requirement*/
                                 WHEN SUBSTR(column_name,
                                             1,
                                             2
                                            ) = 'O_' THEN
                                   /*changed the substring condition to match the new change*/
                                                         'NULL'
                                 ELSE    ':NEW.'
                                      || REPLACE(column_name,
                                                 '_A_',
                              END
                             ) in_col_value,
                             LOWER(SUBSTR(column_name,
                                          1,
                                          3
                                         )) trg_header,
                             MIN(column_id) OVER(PARTITION BY c.table_name) min_col,
                             MAX(column_id) OVER(PARTITION BY c.table_name) max_col
                    FROM     all_tab_columns c
                    WHERE    c.table_name IN(
                                SELECT object_name
                                FROM   all_objects
                                WHERE  TRUNC(created) = TRUNC(SYSDATE)
                                AND    object_name = 'CHARACTERISTIC_A_T')
                    ORDER BY c.table_name,
                             c.column_id))

Maybe you are looking for

  • IPhone 4 call quality

    So me and my partner upgraded our o2 contracts yesterday and got the iPhone 4. We had iPhone 3GS' before that. When talking to other people and hearing them through the ear piece, it was crystal clear. (With iPhone 3GS') People used to comment on how

  • Quicksilver 800mhz stopped booting after unplugging IDE ribbon

    Hello all, I just purchased a used Quicksilver D. Processor 800 machine which came preloaded with a very working OS X 10.3.9. Upon my receiving this system, I noticed it was extremely dusty, dirty, and had a few small spots of oxidation/rust on the m

  • Psuedo commit feature in Oracle 8i?

    I would like to know if there is a "psuedo commit" in either the oracle 8i or 9i. I have a process that will write the request to a temporary table. I would like other processes to see the records in this table but I cannot do a commit at this point.

  • Undeliverable mail question

    hi, What does this dsn mean? And could it be spam? the subject is "Undeliverable mail" Message body: Failed to deliver to '[email protected]' SMTP module(domain yyyyy.com) reports: yyyyy.com: no response Two attachments came along with the message. O

  • Irrational fear of scriplets - revisited

    hey all this is a continuation of a very long thread that begins here http://forum.java.sun.com/thread.jsp?forum=45&thread=318105. (if you read it, remember to post any continuations on this thread. My basic contention is that small scriptlets which