Ora-06502:pl/sql :numeric or value error:host bind array too small

declare
    v_dr_narrative varchar2(1000);
begin
v_dr_narrative:=f_gen_acct_narration_test(fiv_module=>'C' ,
                                             fiv_handoff_type=>'T',
                                             fiv_acct_freq=>NULL   ,
                                             fiv_acct_type =>NULL  ,
                                             fiv_acct_name=>NULL   ,
                                             fiv_acct_level=>'I',
                                             fiv_applicable_for=>NULL,
                                             fiv_client_code =>NULL  ,
                                             fiv_product_code=>NULL ,
                                             fiv_account_nmbr=>NULL  ,
                                             fiv_pir_dep_acct_nmbr =>NULL    ,
                                             fiv_pir_dep_acct_int_nmbr=> NULL);
  v_dr_narrative:=f_gen_acct_narration_wrapper(fiv_module=>'C' ,
                                             fiv_handoff_type=>'T',
                                             fiv_acct_freq=>NULL   ,
                                             fiv_acct_type =>NULL  ,
                                             fiv_acct_name=>NULL   ,
                                             fiv_acct_level=>'I',
                                             fiv_applicable_for=>NULL,
                                             fiv_client_code =>NULL  ,
                                             fiv_product_code=>NULL ,
                                             fiv_account_nmbr=>NULL  ,
                                             fiv_pir_dep_acct_nmbr =>NULL    ,
                                             fiv_pir_dep_acct_int_nmbr=> NULL,
                                             fiv_event_code=>'DATAENTRY',
                                             fiv_source_of_entry=>'T',
                                             fiv_transaction_journal_nmbr=>'11031800007V',
                                             fiv_seq_nmbr=>'001' ,
                                             fiv_entity_type=>'CLIENT' ,
                                             fiv_txn_reference_type=>'D' ,
                                             fiv_txn_reference_nmbr=>'11031800002L');
dbms_output.put_line(v_dr_narrative);
end;

Do you have a question?
SQL> declare
  2      v_dr_narrative varchar2(1000);
  3  begin
  4
  5  v_dr_narrative:=f_gen_acct_narration_test(fiv_module=>'C' ,
  6                                               fiv_handoff_type=>'T',
  7                                               fiv_acct_freq=>NULL   ,
  8                                               fiv_acct_type =>NULL  ,
  9                                               fiv_acct_name=>NULL   ,
10                                               fiv_acct_level=>'I',
11                                               fiv_applicable_for=>NULL,
12                                               fiv_client_code =>NULL  ,
13                                               fiv_product_code=>NULL ,
14                                               fiv_account_nmbr=>NULL  ,
15                                               fiv_pir_dep_acct_nmbr =>NULL    ,
16                                               fiv_pir_dep_acct_int_nmbr=> NULL);
17
18  /*
19    v_dr_narrative:=f_gen_acct_narration_wrapper(fiv_module=>'C' ,
20                                               fiv_handoff_type=>'T',
21                                               fiv_acct_freq=>NULL   ,
22                                               fiv_acct_type =>NULL  ,
23                                               fiv_acct_name=>NULL   ,
24                                               fiv_acct_level=>'I',
25                                               fiv_applicable_for=>NULL,
26                                               fiv_client_code =>NULL  ,
27                                               fiv_product_code=>NULL ,
28                                               fiv_account_nmbr=>NULL  ,
29                                               fiv_pir_dep_acct_nmbr =>NULL    ,
30                                               fiv_pir_dep_acct_int_nmbr=> NULL,
31                                               fiv_event_code=>'DATAENTRY',
32                                               fiv_source_of_entry=>'T',
33                                               fiv_transaction_journal_nmbr=>'11031800007V',
34                                               fiv_seq_nmbr=>'001' ,
35                                               fiv_entity_type=>'CLIENT' ,
36                                               fiv_txn_reference_type=>'D' ,
37                                               fiv_txn_reference_nmbr=>'11031800002L');
38  */
39
40  dbms_output.put_line(v_dr_narrative);
41
42  end;
43
44
45
46
47
48  /
v_dr_narrative:=f_gen_acct_narration_test(fiv_module=>'C' ,
ERROR at line 5:
ORA-06550: line 5, column 17:
PLS-00201: identifier 'F_GEN_ACCT_NARRATION_TEST' must be declared
ORA-06550: line 5, column 1:
PL/SQL: Statement ignoredBecause you've not supplied the code that anyone would need to reproduce the error in the subject of your post.

Similar Messages

  • Error: ORA-06502: PL/SQL: numeric or value error: host bind array too small

    Hello,
    I am getting this error when i am trying to execute a PL/SQL script using an Oracle API
    We are using Oracle 10g release 2 database. I am getting this error only on some instances. This script is running fine in Development instances.
    Script:
    SET VERIFY OFF;
    SET serveroutput on size 100000;
    SET linesize 300;
    EXEC FND_STATS.GATHER_COLUMN_STATS ('AR', 'HZ_LOCATIONS', 'COUNTRY');
    SELECT
    hl.location_id,hl.state, hl.country,
    hcasa.org_id
    FROM hz_cust_site_uses_all hcsua,
    hz_cust_acct_sites_all hcasa,
    hz_party_sites hps, apps.hz_locations hl,
    hz_parties hp,
    hz_cust_accounts hca
    WHERE hcsua.cust_acct_site_id = hcasa.cust_acct_site_id
    AND hcasa.party_site_id = hps.party_site_id
    AND hps.location_id = hl.location_id
    AND hp.party_id = hps.party_id
    AND hca.cust_account_id = hcasa.cust_account_id
    AND hca.party_id = hp.party_id
    AND hl.country NOT IN ('US','CA')
    AND hps.party_site_number NOT LIKE 'M%';
    --PROMPT Dropping Table pmr13286_temptable
    DROP TABLE pmr13286_temptable;
    CREATE TABLE pmr13286_temptable AS (SELECT
    hp.attribute_category , hl.address_lines_phonetic,
    hps.party_site_number,hca.cust_account_id,
    hcsua.site_use_code, hcsua.primary_flag, hcsua.status,
    hl.address1, hl.address2, hl.address3, hl.address4,
    hl.city, hl.state, hl.postal_code, hl.country,
    hl.county, hl.province, hcasa.org_id,
    hl.creation_date
    FROM hz_cust_site_uses_all hcsua,
    hz_cust_acct_sites_all hcasa,
    hz_party_sites hps, apps.hz_locations hl,
    hz_parties hp,
    hz_cust_accounts hca
    WHERE hcsua.cust_acct_site_id = hcasa.cust_acct_site_id
    AND hcasa.party_site_id = hps.party_site_id
    AND hps.location_id = hl.location_id
    AND hp.party_id = hps.party_id
    AND hca.cust_account_id = hcasa.cust_account_id
    AND hca.party_id = hp.party_id
    AND hl.country NOT IN ('US','CA')
    AND hps.party_site_number NOT LIKE 'M%');
    DECLARE
    l_location_rec hz_location_v2pub.location_rec_type;
    l_object_version_number hz_locations.object_version_number%TYPE;
    p_status_code NUMBER;
    l_api_status VARCHAR2 (2000);
    l_msg_count NUMBER (15);
    l_msg_data VARCHAR2 (2000);
    v_total_count NUMBER (15);
    v_prvi_count NUMBER (15);
    v_countr_count NUMBER (15);
    v_null_count NUMBER (15);
    v_rem_recs          NUMBER (15);
    v_status_code VARCHAR2 (2000);
    l_sql_errmsg VARCHAR2 (500);
    CURSOR c_cust_addr
    IS
    SELECT
    hl.*
    FROM hz_cust_site_uses_all hcsua,
    hz_cust_acct_sites_all hcasa,
    hz_party_sites hps, apps.hz_locations hl,
    hz_parties hp,
    hz_cust_accounts hca
    WHERE hcsua.cust_acct_site_id = hcasa.cust_acct_site_id
    AND hcasa.party_site_id = hps.party_site_id
    AND hps.location_id = hl.location_id
    AND hp.party_id = hps.party_id
    AND hca.cust_account_id = hcasa.cust_account_id
    AND hca.party_id = hp.party_id
    AND hl.country NOT IN ('US','CA')
    AND hps.party_site_number NOT LIKE 'M%';
    BEGIN
    v_total_count := 0;
    v_prvi_count := 0;
    v_countr_count := 0;
    v_null_count := 0;
    dbms_output.put_line('Total Count'||v_total_count );
    dbms_output.put_line('PR/VI Conversion Count'||v_prvi_count );
    dbms_output.put_line('PR/VI to US Conversion Count'||v_countr_count );
    dbms_output.put_line('Non US/CA State Null Count'||v_null_count );
    FOR i IN c_cust_addr
    LOOP
    l_location_rec := NULL;
    v_total_count := v_total_count + 1;
    l_location_rec.location_id := i.location_id;
    l_location_rec.state := i.state;
    l_location_rec.country := i.country;
    dbms_output.put_line('Location_id '||l_location_rec.location_id||' '||'State '||l_location_rec.state||' '||'Country '||l_location_rec.country);
    BEGIN
    SELECT hl.object_version_number
    INTO l_object_version_number
    FROM hz_locations hl
    WHERE hl.location_id = l_location_rec.location_id;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    raise_application_error (
    -20059,
    'object_version_number not found for location = '
    || TO_CHAR (l_location_rec.location_id)
    END;
    Update 1 - Update Addresses of 3 records that have wrong country names
    BEGIN
    IF (l_location_rec.location_id IN (1436720,119456,604649)) THEN
    dbms_output.put_line(' 3 records Location_id '||l_location_rec.location_id);
    IF ( l_location_rec.location_id = 1436720) THEN
    l_location_rec.state := 'OH';
    l_location_rec.country := 'US';
    ELSIF ( l_location_rec.location_id = 119456) THEN
    l_location_rec.country := 'US';
    ELSIF ( l_location_rec.location_id = 604649) THEN
         l_location_rec.country := 'PK';
    END IF;
    hz_location_v2pub.update_location (
    fnd_api.g_true,
    l_location_rec,
    l_object_version_number,
    l_api_status,
    l_msg_count,
    l_msg_data
         IF l_api_status <> fnd_api.g_ret_sts_success
    THEN
    dbms_output.put_line(' Error In API with status of '||l_api_status);
    IF l_msg_count > 1
    THEN
    FOR s IN 1 .. l_msg_count
    LOOP
    l_sql_errmsg :=
    SUBSTR (
    RTRIM (l_sql_errmsg)
    || ' , '
    || RTRIM (
    fnd_msg_pub.get (p_encoded => fnd_api.g_false)
    1,
    500
    END LOOP;
    ELSE
    l_sql_errmsg := SUBSTR (l_msg_data, 1, 500);
    END IF;
    dbms_output.put_line(' Error Message '||l_sql_errmsg);
    ROLLBACK;
    RETURN;
    END IF;
    END IF;
    END;
    Update 2 - Update state to 'VI','PR' where country is in 'VI','PR'
    BEGIN
    IF (i.country = 'PR' AND (i.state <> 'PR' OR i.state IS NULL))
    OR (i.country = 'VI' AND (i.state <> 'VI'OR i.state IS NULL)) THEN
    v_prvi_count := v_prvi_count + 1;
    dbms_output.put_line(' State to PR/VI Location_id '||l_location_rec.location_id);
    SELECT DECODE (i.country,'PR','PR','VI', 'VI') INTO l_location_rec.state
    FROM apps.hz_locations WHERE
    location_id = l_location_rec.location_id;
    hz_location_v2pub.update_location (
    fnd_api.g_true,
    l_location_rec,
    l_object_version_number,
    l_api_status,
    l_msg_count,
    l_msg_data
              IF l_api_status <> fnd_api.g_ret_sts_success
              THEN
              dbms_output.put_line(' Error In API with status of '||l_api_status);
              IF l_msg_count > 1
              THEN
              FOR s IN 1 .. l_msg_count
              LOOP
              l_sql_errmsg :=
              SUBSTR (
              RTRIM (l_sql_errmsg)
              || ' , '
              || RTRIM (
              fnd_msg_pub.get (p_encoded => fnd_api.g_false)
              1,
              500
              END LOOP;
              ELSE
              l_sql_errmsg := SUBSTR (l_msg_data, 1, 500);
              END IF;
              dbms_output.put_line(' Error Message '||l_sql_errmsg);
              ROLLBACK;
              RETURN;
    END IF;
                   dbms_output.put_line('Location_id '||l_location_rec.location_id||' '||'State '||l_location_rec.state||' '||'Country '||l_location_rec.country);
    END IF;
    END;
    Update 3 - Update Country code to 'US' where state code is either 'PR' or 'VI'
    BEGIN
    IF l_location_rec.state = 'PR' OR l_location_rec.state = 'VI'
    THEN l_location_rec.country := 'US';
    v_countr_count := v_countr_count + 1;
    dbms_output.put_line('PR/VI country to US Location_id '||l_location_rec.location_id);
    hz_location_v2pub.update_location (
    fnd_api.g_true,
    l_location_rec,
    l_object_version_number,
    l_api_status,
    l_msg_count,
    l_msg_data
    IF l_api_status <> fnd_api.g_ret_sts_success
              THEN
              dbms_output.put_line(' Error In API with status of '||l_api_status);
              IF l_msg_count > 1
              THEN
              FOR s IN 1 .. l_msg_count
              LOOP
              l_sql_errmsg :=
              SUBSTR (
              RTRIM (l_sql_errmsg)
              || ' , '
              || RTRIM (
              fnd_msg_pub.get (p_encoded => fnd_api.g_false)
              1,
              500
              END LOOP;
              ELSE
              l_sql_errmsg := SUBSTR (l_msg_data, 1, 500);
              END IF;
              dbms_output.put_line(' Error Message '||l_sql_errmsg);
              ROLLBACK;
              RETURN;
    END IF;
    dbms_output.put_line('Location_id '||l_location_rec.location_id||' '||'State '||l_location_rec.state||' '||'Country '||l_location_rec.country);
    END IF;
    END;
    Update 4 - Update state code to NULL where state code is NOT NULL and country code is not in US or CA
    IF l_location_rec.country NOT IN ('US','CA') AND l_location_rec.state IS NOT null
    THEN l_location_rec.state := FND_API.G_NULL_CHAR;
    v_null_count := v_null_count + 1;
    dbms_output.put_line('Non US/CA to Null Location_id '||l_location_rec.location_id);
    hz_location_v2pub.update_location (
    fnd_api.g_true,
    l_location_rec,
    l_object_version_number,
    l_api_status,
    l_msg_count,
    l_msg_data
    IF l_api_status <> fnd_api.g_ret_sts_success
              THEN
              dbms_output.put_line(' Error In API with status of '||l_api_status);
              IF l_msg_count > 1
              THEN
              FOR s IN 1 .. l_msg_count
              LOOP
              l_sql_errmsg :=
              SUBSTR (
              RTRIM (l_sql_errmsg)
              || ' , '
              || RTRIM (
              fnd_msg_pub.get (p_encoded => fnd_api.g_false)
              1,
              500
              END LOOP;
              ELSE
              l_sql_errmsg := SUBSTR (l_msg_data, 1, 500);
              END IF;
              dbms_output.put_line(' Error Message '||l_sql_errmsg);
              ROLLBACK;
              RETURN;
    END IF;
    dbms_output.put_line('Location_id '||l_location_rec.location_id||' '||'State '||l_location_rec.state||' '||'Country '||l_location_rec.country);
    END IF;
    END LOOP;
    v_countr_count := v_countr_count +2;
    dbms_output.put_line('Total Count'||v_total_count );
    dbms_output.put_line('PR/VI Conversion Count'||v_prvi_count );
    dbms_output.put_line('PR/VI to US Conversion Count'||v_countr_count );
    dbms_output.put_line('Non US/CA State Null Count'||v_null_count );
         BEGIN
         SELECT
         count(*) into v_rem_recs
         FROM hz_cust_site_uses_all hcsua,
         hz_cust_acct_sites_all hcasa,
         hz_party_sites hps, apps.hz_locations hl,
         hz_parties hp,
         hz_cust_accounts hca
         WHERE hcsua.cust_acct_site_id = hcasa.cust_acct_site_id
         AND hcasa.party_site_id = hps.party_site_id
         AND hps.location_id = hl.location_id
         AND hp.party_id = hps.party_id
         AND hca.cust_account_id = hcasa.cust_account_id
         AND hca.party_id = hp.party_id
         AND hl.country NOT IN ('US','CA')
         AND hps.party_site_number NOT LIKE 'M%';
    dbms_output.put_line('remaining count '||v_rem_recs );
         END;
    COMMIT;
         EXCEPTION
         WHEN OTHERS THEN     
         dbms_output.put_line('Error in Program: ' ||' Error Message ' || SQLERRM);
         ROLLBACK;
    END;
    SELECT
    hl.location_id,hl.state, hl.country,
    hcasa.org_id
    FROM hz_cust_site_uses_all hcsua,
    hz_cust_acct_sites_all hcasa,
    hz_party_sites hps, apps.hz_locations hl,
    hz_parties hp,
    hz_cust_accounts hca
    WHERE hcsua.cust_acct_site_id = hcasa.cust_acct_site_id
    AND hcasa.party_site_id = hps.party_site_id
    AND hps.location_id = hl.location_id
    AND hp.party_id = hps.party_id
    AND hca.cust_account_id = hcasa.cust_account_id
    AND hca.party_id = hp.party_id
    AND hl.country NOT IN ('US','CA')
    AND hps.party_site_number NOT LIKE 'M%';

    You may want to zero in on the part of the code that throws this error.
    (i)
    Try executing a small part of your code, while commenting out the rest. If that is successful, execute a slightly bigger part of the code, and so on successively. Once you know, where exactly the code is failing, it should be easier to create a small testcase against your data and investigate the problem.
    (ii)
    Check those local variables and the values that get assigned to them. It is a good practice to anchor local variables to database columns. That way, there will be less surprises when the table structures are altered.
    (iii)
    The script as such does not show any glaring error, but you may want to check those procedure calls e.g. -
          hz_Location_v2Pub.Update_Location(fnd_aPi.g_True,l_Location_rec,l_Object_Version_Number,
                                            l_aPi_Status,l_msg_Count,l_msg_Data);It's quite possible that the procedure is assigning a value to an output parameter that is too small to store that.
    Note that, given such a huge script and not knowing your database, we are not particularly inclined to debug it. The only person who can make things easier for himself/herself is you.
    HTH,
    isotope

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

    Hi there...
    I'm sugin 9Iasv2 Portal.
    When i clik on the "approbations" tab in the parameters of a page, i always get this error :
    Erreur : ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Could you please help me ?
    regards
    Arnaud

    Please report this problem to Oracle Support.

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

    I am encountering this 6502 error when running a report in Crystal Reports XI. I am connecting to Oracle Server. All the documentation I've read has said to update the UserSessionFormat property... how do I do that?
    Thanks in advance!

    Hi Grant,
    UserSessionFormat is a property in the Oracle OleDB driver.
    Scroll to the Solution part of tis article.
    http://blogs.msdn.com/b/dataaccesstechnologies/archive/2012/01/20/every-bug-is-a-microsoft-bug-until-proven-otherwise.aspx
    Good luck,
    Brian

  • 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

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

    Hi Everybody,
    Please, I Need of Your Help.
    We have a table with the following characteristics:
    PS_NAMES ( EMPLID VARCHAR2(33), NAME VARCHAR2(150), ... )
    In this table a Trigger exists...
    CREATE OR REPLACE TRIGGER TG_NAMES
    BEFORE UPDATE ON PS_NAMES
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    Declare
    vemplid ps_names.emplid%type;
    vname ps_names.name%type;
    Begin
    vname := substr(:new.name,1,45);
    end;
    When the register is updated and the field PS_NAMES.NAMES has a bigger or equal content that 45 characters and with a character special, happen the error: "ORA- 06502: PL/SQL: numeric or value error: character string buffer too small".
    This happens for any bigger or equal name the 45 characters and that it contains a character special.
    Thanks,
    Márcio Ap. Silveira

    paddy wrote:
    Hi,
    I have check that part. The out parameter is getting populated correctly. I tried even removing the out parameter. Still it failed.And still you haven't provided all the details.
    What about col1, col2, and the actual definition/declaration for ot_MY_OBJECT_TYPE?
    How can we see any of the datatypes and where the issue could be if you don't bother to supply us with the information. Our crystal balls are broken and in the shop for fixing at the minute.

  • ORA-6502: PL/SQL: numeric or value error: character string buffer too small WWV-11230

    Hi,
    I'm trying to create an UI Template. I've generated the html using Frontpage and am successfully able to see in a browser.
    I've copied the html to the UI form, but when I try to preview or execute the UI template, I get the following error:
    Error: ORA-06502: PL/SQL: numeric or value error: character string buffer too small (WWV-11230)
    null

    I AM FACING SIMILAR PROBLEM, THE EXACT ERROR IS:
    Error: Excepcisn de wwv_generate_component.build_procedure (WWV-01821)
    No se ha podido generar la pantalla de interfaz de usuario: ORA-06502: PL/SQL: numeric or value error: character string buffer too small (WWV-16409)
    (SORRY , PART OF THE ERROR IS IN SPANISH!)
    I CREATED A FORM , WORKED WITH IT A LOT WITHOUT PROBLEMS. NOW I NEED TO DO SOME CHANGES ON CERTAIN FIELDS AND WHEN I TRY TO SAVE IT I GET THE ABOVE ERROR.
    THEN I GO BACK TO AN OLDER VERSION, COPY AND TRY TO DO CHANGES AND AGAIN THE ERROR COMES UP.
    THE CHANGES I AM TRYING TO DO ARE TO SOME OF THE EXISTING FIELDS IN THE FORM WHICH NEED TO BE PUT AS "INSERTABLE".
    THE SCREEN LAYOUT IS DISPLAYED WITHOUT PROBLEM.
    (THE FORM IS BASED ON A TABLE WITH APROX 80 FIELDS).
    I NEED SOME URGENT HELP. PLS LET ME KNOW ANY OTHER INFO YOU MAY NEED TO HELP ME SOLVE THIS PROBLEM.
    FYI I AM WORKING ON PORTAL VERSION 3.0.9 / ON Windows 2000 (DATABASE 8.1.7.0 AND iAS ARE ON DIFFERENT MACHINES).
    TKS IN ADVANCE

  • ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bind

    Hi
    I am getting this run time error ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bind in my pl/sql . I tried evrything , changing datatypes ,etc but still this error is coming .What can be the cause , please help.
    declare
    svid xxpor_utility.p_svid@sppmig1%type;
    p_sv_id xxpor_utility.p_svid@sppmig1%type;
    tab xxpor_utility.xxpor_indextab@sppmig1;
    svid1 xxpor_utility.p_svid@sppmig1%type;
    p_sv_id1 xxpor_utility.p_svid@sppmig1%type;
    tab1 xxpor_utility.xxpor_indextab@sppmig1;
    svid2 xxpor_utility.p_svid@sppmig1%type;
    p_sv_id2 xxpor_utility.p_svid@sppmig1%type;
    tab2 xxpor_utility.xxpor_indextab@sppmig1;
    svid3 xxpor_utility.p_svid@sppmig1%type;
    p_sv_id3 xxpor_utility.p_svid@sppmig1%type;
    tab3 xxpor_utility.xxpor_indextab@sppmig1;
    v_index t2_error_table.id_value%type;
    v_code t2_error_table.error_code%type;
    p_error varchar2(600);
    k number(20):=0;
    v_msg varchar2(2000);
    v_commit_count number(10);
    v_at_gpid varchar2(512);
    v_at_oper varchar2(512);
    v_sch varchar2(512);
    v_vat varchar2(512);
    exp exception;
    exp1 exception;
    exp2 exception;
    exp3 exception;
    exp4 exception;
    v_pay varchar2(512);
    v_res varchar2(512);
    v_digit varchar2(512);
    v_agree varchar2(512);
    v_driver_licence PERSON_HISTORY.drivers_licence%TYPE;
    v_cus_gen1 number(10);
    v_cus_gen2 number(10);
    v_cus_gen3 number(10);
    svid_sr number(10);
    v_social PERSON_HISTORY.social_security_number%TYPE;
    CURSOR person_cur (p_person_id person_history.person_id%TYPE)
    IS
    SELECT drivers_licence ,social_security_number
    FROM PERSON_HISTORY@SPPMIG1
    WHERE PERSON_ID=p_person_id --p2(p).person_id
         AND EFFECTIVE_START_DATE = (SELECT MAX(EFFECTIVE_START_DATE)
         FROM PERSON_HISTORY@sppmig1
                                            WHERE PERSON_ID=p_person_id);--p2(p).person_id) ;
    --p number(20):=1;
    --j number(20);
    cursor c1 is
    select * from cus_node_his ;
    type temp_c1 is table of customer_node_history%rowtype
    index by binary_integer;
    t2 temp_c1;
    type temp_c2 is table of customer_node_history@slpmig1%rowtype
    index by binary_integer;
    p2 temp_c2;
    /*cursor c2(p_id customer_query.customer_node_id%type) is
    select general_1,general_2,general_3
    from customer_query@sppmig1 c where c.customer_query_type_id=10003 and
    c.customer_node_id(+) =p_id
    and c.open_date = (select
    max(open_date) from customer_query@sppmig1 where customer_node_id=p_id
    and customer_query_type_id=10003 and c.customer_query_id =(select max(customer_query_id) from customer_query@sppmig1
    where customer_node_id=p_id and customer_query_type_id=10003));*/
    procedure do_bulk_insert is
    bulk_errors EXCEPTION;
    PRAGMA EXCEPTION_INIT(bulk_errors, -24381);
    begin
    forall j in 1..t2.count SAVE EXCEPTIONS
    insert into aaa values t2(j);
    commit;
    --t2.delete;
    k:=0;
    v_msg:=sqlerrm;
    EXCEPTION WHEN bulk_errors THEN
    FOR L IN 1..SQL%bulk_exceptions.count
    LOOP
    v_index := SQL%bulk_exceptions(L).ERROR_INDEX;
    v_code := sqlerrm(-1 * SQL%bulk_exceptions(L).ERROR_CODE);
    --v_index := SQL%bulk_exceptions(j).ERROR_INDEX;
    --v_code := sqlerrm(-1 * SQL%bulk_exceptions(j).ERROR_CODE);
    INSERT INTO t2_error_table
    VALUES('CUSTOMER_NODE_HISTORY',
    'CUSTOMER_NODE_ID',
    v_msg,
    t2(v_index).customer_node_id,
    null,
    'DO_BULK_INSERT',
    v_code
    commit;
    END LOOP;
    end do_bulk_insert;
    begin
    select value into v_at_gpid from t2_system_parameter@sppmig1 where name='atlanta_group_id';
    select value into v_commit_count from t2_system_parameter@sppmig1 where name='batch_size';
    select value into v_sch from t2_system_parameter@sppmig1 where name='schedule_id';
    select value into v_pay from t2_system_parameter@sppmig1 where name='payment_location_code';
    select value into v_at_oper from t2_system_parameter@sppmig1 where name='atlanta_operator_id';
    select value into v_digit from t2_system_parameter@sppmig1 where name='digits_to_be_screened';
    select value into v_res from t2_system_parameter@sppmig1 where name='responsible_agent';
    select value into v_vat from t2_system_parameter@sppmig1 where name='vat_rate';
    select value into v_agree from t2_system_parameter@sppmig1 where name='bank_agreement_status';
    xxpor_utility.xxpor_loadmemory@sppmig1('CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_TYPE_ID',tab);
    xxpor_utility.xxpor_loadmemory@sppmig1('CUSTOMER_NODE_HISTORY','CREDIT_RATING_CODE',tab2);
    xxpor_utility.xxpor_loadmemory@sppmig1('CUSTOMER_NODE_HISTORY','PAYMENT_METHOD_CODE',tab3);
    xxpor_utility.xxpor_loadmemory@sppmig1('CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_STATUS_CODE',tab1);
    open c1;
    loop
    fetch c1 bulk collect into p2 limit v_commit_count;
    for p in 1..p2.count loop
    k:=K+1;
    begin
    xxpor_utility.xxpor_getsvid@sppmig1(p2(p).CUSTOMER_NODE_TYPE_ID,tab,svid);
    p_sv_id:=svid;
    xxpor_utility.xxpor_getsvid@sppmig1(p2(p).CUSTOMER_NODE_STATUS_CODE,tab1,svid1);
    p_sv_id1 :=svid1;
    xxpor_utility.xxpor_getsvid@sppmig1(p2(p).CREDIT_RATING_CODE,tab2,svid2);
    p_sv_id2:=svid2;
    xxpor_utility.xxpor_getsvid@sppmig1(p2(p).PAYMENT_METHOD_CODE,tab3,svid3);
    p_sv_id3:=svid3;
    OPEN person_cur (p2(p).person_id);
    FETCH person_cur INTO v_driver_licence, v_social;
    CLOSE person_cur;
    --select social_security_number  into v_social from person_history@sppmig1 where
    --PERSON_ID=p2(p).person_id AND EFFECTIVE_START_DATE = (SELECT MAX(EFFECTIVE_START_DATE) FROM
    --PERSON_HISTORY@sppmig1 WHERE PERSON_ID=p2(p).person_id) ;
    /*open c2(p2(p).customer_node_id);
    fetch c2 into v_cus_gen1, v_cus_gen2, v_cus_gen3;
    close c2;
    xxpor_utility.get_status_code@sppmig1(v_cus_gen1,v_cus_gen2,v_cus_gen3,svid_sr);*/
    svid_sr:=2600000;
    t2(k).CUSTOMER_NODE_ID     :=     p2(p).CUSTOMER_NODE_ID;
    t2(k).LAST_MODIFIED          :=     p2(p).LAST_MODIFIED;
    t2(k).EFFECTIVE_START_DATE     :=     p2(p).EFFECTIVE_START_DATE;
    t2(k).EFFECTIVE_END_DATE     :=     p2(p).EFFECTIVE_END_DATE;
    t2(k).CUSTOMER_NODE_TYPE_ID     := p_sv_id;
    if p_sv_id is null then
    raise exp1;
    end if;
    t2(k).PRIMARY_IDENTIFIER      :=     p2(p).PRIMARY_IDENTIFIER;
    t2(k).PRIMARY_IDENTIFIER2     :=     p2(p).PRIMARY_IDENTIFIER2;
    t2(k).NODE_NAME           :=     p2(p).NODE_NAME ;
    t2(k).NODE_NAME_UPPERCASE     :=     p2(p).NODE_NAME_UPPERCASE ;
    t2(k).NODE_NAME_SOUNDEX     :=     p2(p).NODE_NAME_SOUNDEX;
    t2(k).ATLANTA_GROUP_ID          := v_at_gpid ;
    t2(k).ATLANTA_OPERATOR_ID     :=     p2(p).ATLANTA_OPERATOR_ID;
    t2(k).GL_CODE_ID          :=     p2(p).GL_CODE_ID;
    t2(k).PARENT_CUSTOMER_NODE_ID     := p2(p).PARENT_CUSTOMER_NODE_ID ;
    t2(k).HIERARCHY_LEVEL          := p2(p).HIERARCHY_LEVEL ;
    t2(k).ROOT_CUSTOMER_NODE_ID      := p2(p).ROOT_CUSTOMER_NODE_ID ;
    t2(k).CUSTOMER_NODE_STATUS_CODE := p_sv_id1 ;
    if p_sv_id1 is null then
    raise exp2;
    end if;
    t2(k).CREATED_DATE     :=          p2(p).CREATED_DATE;
    t2(k).ACTIVE_DATE      :=          p2(p).ACTIVE_DATE ;
    t2(k).PERSON_ID     :=          p2(p).PERSON_ID ;
    t2(k).PRIME_ACCOUNT_ID :=          p2(p).PRIME_ACCOUNT_ID;
    t2(k).REPORT_LEVEL_CODE :=          p2(p).REPORT_LEVEL_CODE;
    t2(k).POSTAL_ADDRESS_ID     :=     p2(p).POSTAL_ADDRESS_ID;
    t2(k).SITE_ADDRESS_ID     :=     p2(p).SITE_ADDRESS_ID ;
    t2(k).CURRENCY_ID      :=          p2(p).CURRENCY_ID;
    t2(k).SCHEDULE_ID     :=          v_sch;
    t2(k).BILLING_PRIORITY     :=     p2(p).BILLING_PRIORITY ;
    t2(k).BILLING_COMPLEXITY:=          p2(p).BILLING_COMPLEXITY ;
    t2(k).BILLING_CONFIGURATION_CODE     := p2(p).BILLING_CONFIGURATION_CODE;
    t2(k).SUPPRESS_IND_CODE           := p2(p).SUPPRESS_IND_CODE ;
    t2(k).SUPPRESS_BILL_CYCLE_COUNT := p2(p).SUPPRESS_BILL_CYCLE_COUNT;
    t2(k).SUPPRESS_UNTIL_ISSUE_DATE := p2(p).SUPPRESS_UNTIL_ISSUE_DATE;
    t2(k).TURNOVER               := p2(p).TURNOVER;
    t2(k).TURNOVER_CURRENCY_ID      :=     p2(p).TURNOVER_CURRENCY_ID ;
    t2(k).CREDIT_LIMIT           :=     p2(p).CREDIT_LIMIT ;
    t2(k).CREDIT_LIMIT_CURRENCY_ID :=     p2(p).CREDIT_LIMIT_CURRENCY_ID;
    t2(k).EXPECTED_REVENUE      :=     p2(p).EXPECTED_REVENUE ;
    t2(k).EXPECTED_REVENUE_CURRENCY_ID     := p2(p).EXPECTED_REVENUE_CURRENCY_ID ;
    t2(k).CREDIT_RATING_CODE      :=     p_sv_id2 ;
    -- if p_sv_id2 is null then
    --raise exp3;
    -- end if;
    t2(k).CREDIT_COMMENTS           := p2(p).CREDIT_COMMENTS ;
    t2(k).TAX_CLASS_CODE          := 1     ;
    t2(k).PAYMENT_METHOD_CODE     :=     p_sv_id3;
    --if p_sv_id3 is null then
    --raise exp4;
    --end if;
    t2(k).PAYMENT_LOCATION_CODE      := v_pay ;
    t2(k).BANK_CODE           :=     NULL;
    t2(k).BRANCH_CODE           :=     NULL ;
    t2(k).BANK_ACCOUNT_NAME     :=     p2(p).NODE_NAME ;
    t2(k).BANK_ACCOUNT_NUMBER     :=     '1000000';
    t2(k).BANK_ACCOUNT_REF      :=     v_agree;
    t2(k).CARD_TYPE_CODE          := p2(p).CARD_TYPE_CODE     ;
    t2(k).CARD_NUMBER          :=     p2(p).CARD_NUMBER ;
    t2(k).CARD_EXPIRY_DATE          := NULL ;
    t2(k).ASSIGNED_OPERATOR_ID      :=     NULL ;
    t2(k).SALES_CHANNEL_CODE     :=     0;
    t2(k).COMPANY_NUMBER          := NULL;
    t2(k).INDUSTRY_CODE          :=     NULL;
    t2(k).REGION_CODE           :=     NULL;
    t2(k).GENERAL_1          :=     v_vat ;
    t2(k).GENERAL_2           :=     svid_sr ;
    if svid_sr is null then
    raise exp;
    end if;
    t2(k).GENERAL_3           :=     v_social ;
    t2(k).GENERAL_4           :=     v_driver_licence ;
    t2(k).GENERAL_5           :=     v_vat;
    t2(k).GENERAL_6           :=     v_res;
    t2(k).GENERAL_7           :=     null||':'||null||':'||'1000000'||':'||null||':'||null||':'||null||':';
    t2(k).GENERAL_8          :=     '2' ;
    t2(k).GENERAL_9           :=     v_digit;
    t2(k).GENERAL_10          :=     p2(p).CUSTOMER_NODE_ID;
    exception when exp then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,null);
    commit;
    when exp1 then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,'customer_node_type_id is null');
    commit;
    when exp2 then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,'customer_node_status_code is null');
    commit;
    /*when exp3 then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,'credit_rating_code is null');
    commit;
    when exp4 then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,null);
    commit;*/
    when others then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,null);
    commit;
    end;
    if mod(k,v_commit_count)=0 then
    do_bulk_insert;
    t2.delete;
    end if;
    end loop;
    do_bulk_insert;
    exit when c1%notfound;
    end loop;
    t2.delete;
    exception when others then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,null
    ,null,null,null);
    commit;
    RAISE;
    end;
    /

    Hi there,
    Following is the description of the error, you are getting.
    ORA-06502:VALUE_ERROR
    An arithmetic, conversion, truncation, or size-constraint error occurs. For example, when your program selects a column value into a character variable, if the value is longer than the declared length of the variable, PL/SQL aborts the assignment and raises VALUE_ERROR. In procedural statements, VALUE_ERROR is raised if the conversion of a character string into a number fails. (In SQL statements, INVALID_NUMBER is raised.)
    Hopefully this will help.

  • Error Message - ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Trunc

    This is driving me nuts!
    I am getting this error from OWB during a mapping process.
    I have checked the input data and it looks fine.
    The run time audit browser just lists all of the steps but does not make it clear which one failed. Is it the last one which is shown (does not have HIDE as selection link.)
    I also tried to determine which row was causing the problem and followed the instructions at http://www.nicholasgoodman.com/bt/blog/2005/07/, but no row_id was recorded in the views. In actual fact there wasn't very much audit info other than that the mapping ran and was complete (even though it failed).
    In the error message section it has, in order
    Map Step - blank
    Rowkey - 35204435256
    Severity - X
    Error Message - ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bind
    Object Name - N/A
    Object Column - *
    From the PL/SQL error I thought it may be trying to insert into a data field that was too small, but all of the columns that are used are full of data of length shorter than all of the target tables.
    I have even started running the cursors in the generated PLSQL but I don't get the error by doing this.
    Thanks in advance for any tips at all.

    Thanks for the response.
    I managed to work it out and it had to do with the selection criteria of one of the filters.
    For anyone else facing this error, check to see if any of the rows being inserted has the same key/identifier as some existing in the target table. If so add an extra condition to the where clause.
    This worked for me.

  • ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bink

    I have a map which worked fine in 10.2.0.1. The same map in 11.2.0.2 is giving me the error:
    'ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bink.'
    I have one source and one target. This is a straight load, no transformations.
    While debugging the map I have noticed the culprit is one column in the source which is varchar2(30),
    I have the target column with the same varchar2(30), and I tried increasing the size of
    the target column but i keep getting the same error. While searching the forum someone suggested
    to change the configuration of code generation options and runtime parameters to set based.
    But strangely it gave me an error because the set based option is not availabe in the new 11.2.0.2.
    Should the set based option be available in this version. Please suggest on how i could resolve the
    error of 'ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bink.' Thank you.

    Hi there,
    Following is the description of the error, you are getting.
    ORA-06502:VALUE_ERROR
    An arithmetic, conversion, truncation, or size-constraint error occurs. For example, when your program selects a column value into a character variable, if the value is longer than the declared length of the variable, PL/SQL aborts the assignment and raises VALUE_ERROR. In procedural statements, VALUE_ERROR is raised if the conversion of a character string into a number fails. (In SQL statements, INVALID_NUMBER is raised.)
    Hopefully this will help.

  • ORA-06502: PL/SQL: numeric or value error: raw variable length too long

    Hi All,
    Oracle 9.2.0.1.0 and Oracle 10g.
    I the following procedure:
    CREATE OR REPLACE TYPE Resource_TT AS TABLE OF RAW(16)
    CREATE OR REPLACE PROCEDURE GET_ROLEMAPPING_Temp
    RoleIds IN NVARCHAR2 DEFAULT NULL ,
    Application IN NVARCHAR2 DEFAULT NULL ,
    MappingExixts OUT NVARCHAR2
    AS
         v_Application NVARCHAR2(150) := Application;
         resource_list CONSTANT Resource_TT := Resource_TT(RoleIds);
         v_temp NUMBER(1, 0) := 0;
    BEGIN
         SELECT 1 INTO v_temp
    FROM DUAL
    WHERE EXISTS ( SELECT SecurityGroupId
    FROM SKESGResourceMapping
    WHERE APPLICATION = v_Application
    AND RoleId IN                
                                                      select column_value
                                                      from table(resource_list)
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    MappingExixts := 'NO';
    END;
    IF v_temp = 1 THEN
    MappingExixts := 'YES';
         END IF;
    END;
    while calling the procedure from sql*plus, the calling block is :
    variable MappingExixts nvarchar2(100);
    execute Get_RoleMapping_Temp('2f90e7969e0a9045aeb5b5ed7b3da9d6,363aef470e10094281e5040627e3b6f8', 'repo1', :MappingExixts);
    print MappingExixts;
    It is throwing an error saying:
    ORA-06502: PL/SQL: numeric or value error: raw variable length too long
    ORA-06512: at "ORACLE1.GET_ROLEMAPPING_TEMP", line 8
    Thanks for your valuable time and suggestions

    Hi Binoy,
    Thanks for your quick response, I increased its size to 200, but I am getting the following error
    ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error
    ORA-06512: at "ORACLE1.GET_ROLEMAPPING_TEMP", line 8

  • ORA-0605: PL/SQL: numeric or value error: character string buffer too small

    I get this error on two function activities in a workflow of mine. I don't even get into the pl/sql procedure call.
    The exact error is:
    Error Name -6502
    Error Message: ORA-0605: PL/SQL: numeric or value error: character string buffer too small
    Error Stack: @#@Wf_Engine_Util.Function_Call(MY_PACKAGE.MY_PROC, ITEM_TYPE, ITEM_KEY, 6519, RUN)
    If I retry the step (expedite -> retry) it runs until it hits the second function which does the same thing (there is a function in between the two functions that do not have any issues). I then have to retry that step as well. Any ideas?
    This seems similar to the following issue that does not have a resolution posted:
    ORA-06502 PL/SQL numeric or value error in wf process
    I've tried commenting out the bodies of the procedures called but that does not help (again -- im not getting into the bodies but im not sure what else it could be).
    Any ideas or suggestions?

    Hi,
    Does this happen on every instance of the process, or just a few?
    Are these activities in the middle, or right at the start of the flow?
    Are any other activities being performed correctly first? If so, are these standard or bespoke?
    My inclination would be that there is some kind of variable that is being populated (or concatenated onto), which is growing too big. When the process errors, it gets cleared, which is why an expedite would move the activity on.
    Matt
    WorkflowFAQ.com - the ONLY independent resource for Oracle Workflow development
    Alpha review chapters from my book "Developing With Oracle Workflow" are available via my website http://www.workflowfaq.com
    Have you read the blog at http://thoughts.workflowfaq.com ?
    WorkflowFAQ support forum: http://forum.workflowfaq.com

  • ORA-06502: PL/SQL: numeric or value error: Bulk bind: Error in define

    Hi All,
    Getting aforesaid error while executing a procedure.
    I have a procedure which takes 7 paramneters and have 13 IN OUT parameters. all the IN OUT parameters are PLSQL tables of number and varchar2.
    I Have checked there are no not null columns this procedure is just seelcting these values and assigning it to plsql table.
    Regards
    Manish

    Thanks for the reply.
    This is the procedure which returns the list of projects
    PROCEDURE DS$2342_PROC
    (P_PROJECT_ID_ARR IN DS$REF.TT_PRO_ID
    ,P_PAGE_NO IN NUMBER
    ,P_RECORDS_PER_PAGE IN NUMBER
    ,P_USER_ID IN USERS.ID%TYPE
    ,P_SORT_ORDER IN VARCHAR2
    ,P_PSE_ID IN PORTAL_SERVICES.ID%TYPE
    ,P_LAST_ACCESSED_DATE IN VARCHAR2
    ,O_PRO_ALL_ID_ARRAY IN OUT DS$REF.TT_PRO_ID
    ,O_PRO_ID_ARRAY IN OUT DS$REF.TT_PRO_ID
    ,O_NAME_ARRAY IN OUT DS$REF.TT_VARCHAR2
    ,O_TYPE_OF_WORK_ARRAY IN OUT DS$REF.TT_VARCHAR2
    ,O_STAGE_ARRAY IN OUT DS$REF.TT_VARCHAR2
    ,O_LOC_ARRAY IN OUT DS$REF.TT_VARCHAR2
    ,O_CURRENCY_ARRAY IN OUT DS$REF.TT_VARCHAR2
    ,O_VALUE_ARRAY IN OUT DS$REF.TT_NUMBER
    ,O_DISPLAY_VALUE_ARRAY IN OUT DS$REF.TT_VARCHAR2
    ,O_LATEST_UPDATED_DATE_ARRAY IN OUT DS$REF.TT_VARCHAR2
    ,O_FLAG_ARRAY IN OUT DS$REF.TT_VARCHAR2
    ,O_LOCATION IN OUT DS$REF.TT_VARCHAR2
    IS
    BEGIN
    DECLARE
    List of parameters
    1.p_project_id_arr Projects id.
    2.p_page_no Page number.
    3.p_records_per_page Records per page.
    4.p_user_id User id.
    5.p_sort_order Sorting by column.
    6.p_pse_id Portal service id.
    7.p_last_accessed_date User last accessed date
    Output parameters
    1. o_pro_all_id_array Project id array
    2. o_pro_id_array Project id array as per records to be displayed
    3. o_name_array Project title array
    4. o_type_of_work_array Project type of work array
    5. o_stage_array Project stage array
    6. o_loc_array Project location array
    7. o_currency_array Project currency array
    8. o_value_array Project values array
    9. o_display_value_array Project display values array
    10. o_latest_updated_date_array Project latest updated date
    11. o_flag_array Flags for new and updated watch icon, project notes, download leads
    12. o_location Location
    v_status CONSTANT EXTRACT_BATCH_HEADERS.STATUS%TYPE := 'OPN';
    CURSOR c_psc(qp_pse_id PORTAL_SERVICES.ID%TYPE) IS
    SELECT DISTINCT psc.LOCATION_REPORTING_LEVEL
    FROM PORTAL_SCS psc
    WHERE psc.START_DATE <= SYSDATE
    AND ( psc.END_DATE IS NULL
    OR psc.END_DATE > SYSDATE )
    AND psc.LOCATION_REPORTING_LEVEL IS NOT NULL
    AND psc.PSE_ID = qp_pse_id;
    CURSOR c_projects_name_order_asc IS
    SELECT pro.ID id
    FROM PROJECTS pro,
    TMP_PROJECTS tmp
    WHERE pro.ID = tmp.PRO_ID
    ORDER BY pro.NAME;
    CURSOR c_projects_name_order_desc IS
    SELECT pro.ID id
    FROM PROJECTS pro,
    TMP_PROJECTS tmp
    WHERE pro.ID = tmp.PRO_ID
    ORDER BY pro.NAME DESC;
    CURSOR c_projects_work_order_asc IS
    SELECT pro.ID id
    FROM PROJECTS pro,
    TMP_PROJECTS tmp
    WHERE pro.ID = tmp.PRO_ID
    ORDER BY TYPE_OF_WORK;
    CURSOR c_projects_work_order_desc IS
    SELECT pro.ID id
    FROM PROJECTS pro,
    TMP_PROJECTS tmp
    WHERE pro.ID = tmp.PRO_ID
    ORDER BY TYPE_OF_WORK DESC;
    CURSOR c_projects_stage_order_asc IS
    SELECT pro.ID id
    FROM PROJECTS pro,
    TMP_PROJECTS tmp
    WHERE pro.ID = tmp.PRO_ID
    ORDER BY pro.STAGE;
    CURSOR c_projects_stage_order_desc IS
    SELECT pro.ID id
    FROM PROJECTS pro,
         TMP_PROJECTS tmp
    WHERE pro.ID = tmp.PRO_ID
    ORDER BY pro.STAGE DESC;
    /* Cursor changed by Tushar on 08/02/2005 */
    CURSOR c_projects_loc_order_asc (cp_location PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE) IS
    SELECT pro.ID id,
    DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4) location
    FROM PROJECTS pro,
    TMP_PROJECTS tmp
    WHERE pro.ID = tmp.PRO_ID
    -- ORDER BY DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    -- ,'C',pro.ADDRESS_LINE_4),
    ORDER BY DECODE(cp_location
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
    TRUNC(pro.LATEST_UPDATED_DATE) DESC,
    pro.VALUE DESC,
    pro.ID DESC;
    /* Cursor changed by Tushar on 08/02/2005 */
    CURSOR c_projects_loc_order_desc (cp_location PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE) IS
    SELECT pro.ID id,
    DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4) location
    FROM PROJECTS pro,
    TMP_PROJECTS tmp
    WHERE pro.ID = tmp.PRO_ID
    -- ORDER BY DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    -- ,'C',pro.ADDRESS_LINE_4),
    ORDER BY DECODE(cp_location
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) DESC,
    TRUNC(pro.LATEST_UPDATED_DATE) DESC,
    pro.VALUE DESC,
    pro.ID DESC;
    /* Cursor changed by Tushar on 08/02/2005 */
    CURSOR c_projects_value_order_asc(cp_location PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE) IS
    SELECT pro.ID id,
    DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4) location
    FROM PROJECTS pro,
    TMP_PROJECTS tmp
    WHERE pro.ID = tmp.PRO_ID
    ORDER BY pro.VALUE,
    TRUNC(pro.LATEST_UPDATED_DATE),
    -- DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    -- ,'C',pro.ADDRESS_LINE_4),
    DECODE(cp_location
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
    pro.ID DESC;
    /* Cursor changed by Tushar on 08/02/2005 */
    CURSOR c_projects_value_order_desc(cp_location PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE) IS
    SELECT pro.ID id,
    DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4) location
    FROM PROJECTS pro,
    TMP_PROJECTS tmp
    WHERE pro.ID = tmp.PRO_ID
    ORDER BY pro.VALUE DESC,
    TRUNC(pro.LATEST_UPDATED_DATE) DESC,
    -- DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    -- ,'C',pro.ADDRESS_LINE_4),
    DECODE(cp_location
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
    pro.ID DESC;
    /* Cursor changed by Tushar on 08/02/2005 */
    CURSOR c_projects_lud_order_asc(cp_location PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE) IS
    SELECT pro.ID id,
    DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4) location
    FROM PROJECTS pro,
    TMP_PROJECTS tmp
    WHERE pro.ID = tmp.PRO_ID
    ORDER BY TRUNC(pro.LATEST_UPDATED_DATE),
    pro.VALUE DESC,
    -- DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    -- ,'C',pro.ADDRESS_LINE_4),
    DECODE(cp_location
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
    pro.ID DESC;
    /* Cursor changed by Tushar on 08/02/2005 */
    CURSOR c_projects_lud_order_desc(cp_location PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE) IS
    SELECT pro.ID id,
    DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4) location
    FROM PROJECTS pro,
    TMP_PROJECTS tmp
    WHERE pro.ID = tmp.PRO_ID
    ORDER BY TRUNC(pro.LATEST_UPDATED_DATE) DESC,
    pro.VALUE DESC,
    -- DECODE(cp_location,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    -- ,'C',pro.ADDRESS_LINE_4),
    DECODE(cp_location
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
    pro.ID DESC;
    /*Cursors for project details depending on order by clause */
    /* Cursor for order by name ascending */
    CURSOR c_pro_sum_name_asc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
    cp_user_id USERS.ID%TYPE,
    cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
    cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
    cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
    SELECT pro.ID id,
    pro.NAME name,
    pro.TYPE_OF_WORK type_of_work,
    pro.STAGE stage,
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
    pro.Currency currency,
    pro.VALUE value,
    pro.DISPLAY_VALUE display_value,
    TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
    DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
    'true','false')
    ||'~'||DECODE(SIGN(cp_last_accessed_date -
    TRUNC(pro.LATEST_UPDATED_DATE)
    ),0,'true'
    ,-1,'true'
    ,1,'false')
    ||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
    ||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
    ||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
    FROM PROJECTS pro,
    TMP_PROJECTS tmp,
    (SELECT wrt.PRO_ID wrt_pro_id
    FROM WATCH_REQUESTS wrt,
    TMP_PROJECTS tmp_sub
    WHERE wrt.VIEWED_DATE IS NULL
    AND wrt.PSR_PSN_PSE_ID = cp_pse_id
    AND wrt.PSR_USR_ID = cp_user_id
    AND tmp_sub.PRO_ID = wrt.PRO_ID
    GROUP BY wrt.PRO_ID) wrt_rec,
    (SELECT pne.PRO_ID pne_pro_id
    FROM PROJECT_NOTES pne,
    TMP_PROJECTS tmp_pne
    WHERE pne.USR_ID = cp_user_id
    AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
    (SELECT ebr.STATUS ebr_status,
    ebp.PRO_ID ebp_pro_id
    FROM EXTRACT_BATCH_HEADERS ebr,
    EXTRACT_BATCH_PROJECTS ebp,
    TMP_PROJECTS tmp_ebr
    WHERE ebr.ID = ebp.EBR_ID
    AND ebp.PRO_ID = tmp_ebr.PRO_ID
    AND ebr.USR_ID = cp_user_id
    AND ebr.STATUS = cp_status) ebr_rec
    WHERE pro.ID = tmp.PRO_ID
    AND pro.ID = wrt_rec.wrt_pro_id(+)
    AND pro.ID = pne_rec.pne_pro_id(+)
    AND pro.ID = ebr_rec.ebp_pro_id(+)
    ORDER BY pro.NAME;
    /* Cursor for order by name descending */
    CURSOR c_pro_sum_name_dsc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
    cp_user_id USERS.ID%TYPE,
    cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
    cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
    cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
    SELECT pro.ID id,
    pro.NAME name,
    pro.TYPE_OF_WORK type_of_work,
    pro.STAGE stage,
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
    pro.Currency currency,
    pro.VALUE value,
    pro.DISPLAY_VALUE display_value,
    TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
    DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
    'true','false')
    ||'~'||DECODE(SIGN(cp_last_accessed_date -
    TRUNC(pro.LATEST_UPDATED_DATE)
    ),0,'true'
    ,-1,'true'
    ,1,'false')
    ||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
    ||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
    ||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
    FROM PROJECTS pro,
    TMP_PROJECTS tmp,
    (SELECT wrt.PRO_ID wrt_pro_id
    FROM WATCH_REQUESTS wrt,
    TMP_PROJECTS tmp_sub
    WHERE wrt.VIEWED_DATE IS NULL
    AND wrt.PSR_PSN_PSE_ID = cp_pse_id
    AND wrt.PSR_USR_ID = cp_user_id
    AND tmp_sub.PRO_ID = wrt.PRO_ID
    GROUP BY wrt.PRO_ID) wrt_rec,
    (SELECT pne.PRO_ID pne_pro_id
    FROM PROJECT_NOTES pne,
    TMP_PROJECTS tmp_pne
    WHERE pne.USR_ID = cp_user_id
    AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
    (SELECT ebr.STATUS ebr_status,
    ebp.PRO_ID ebp_pro_id
    FROM EXTRACT_BATCH_HEADERS ebr,
    EXTRACT_BATCH_PROJECTS ebp,
    TMP_PROJECTS tmp_ebr
    WHERE ebr.ID = ebp.EBR_ID
    AND ebp.PRO_ID = tmp_ebr.PRO_ID
    AND ebr.USR_ID = cp_user_id
    AND ebr.STATUS = cp_status) ebr_rec
    WHERE pro.ID = tmp.PRO_ID
    AND pro.ID = wrt_rec.wrt_pro_id(+)
    AND pro.ID = pne_rec.pne_pro_id(+)
    AND pro.ID = ebr_rec.ebp_pro_id(+)
    ORDER BY pro.NAME DESC;
    /* Cursor for order by TYPE_OF_WORK asc*/
    CURSOR c_pro_sum_work_asc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
    cp_user_id USERS.ID%TYPE,
    cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
    cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
    cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
    SELECT pro.ID id,
    pro.NAME name,
    pro.TYPE_OF_WORK type_of_work,
    pro.STAGE stage,
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
    pro.Currency currency,
    pro.VALUE value,
    pro.DISPLAY_VALUE display_value,
    TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
    DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
    'true','false')
    ||'~'||DECODE(SIGN(cp_last_accessed_date -
    TRUNC(pro.LATEST_UPDATED_DATE)
    ),0,'true'
    ,-1,'true'
    ,1,'false')
    ||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
    ||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
    ||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
    FROM PROJECTS pro,
    TMP_PROJECTS tmp,
    (SELECT wrt.PRO_ID wrt_pro_id
    FROM WATCH_REQUESTS wrt,
    TMP_PROJECTS tmp_sub
    WHERE wrt.VIEWED_DATE IS NULL
    AND wrt.PSR_PSN_PSE_ID = cp_pse_id
    AND wrt.PSR_USR_ID = cp_user_id
    AND tmp_sub.PRO_ID = wrt.PRO_ID
    GROUP BY wrt.PRO_ID) wrt_rec,
    (SELECT pne.PRO_ID pne_pro_id
    FROM PROJECT_NOTES pne,
    TMP_PROJECTS tmp_pne
    WHERE pne.USR_ID = cp_user_id
    AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
    (SELECT ebr.STATUS ebr_status,
    ebp.PRO_ID ebp_pro_id
    FROM EXTRACT_BATCH_HEADERS ebr,
    EXTRACT_BATCH_PROJECTS ebp,
    TMP_PROJECTS tmp_ebr
    WHERE ebr.ID = ebp.EBR_ID
    AND ebp.PRO_ID = tmp_ebr.PRO_ID
    AND ebr.USR_ID = cp_user_id
    AND ebr.STATUS = cp_status) ebr_rec
    WHERE pro.ID = tmp.PRO_ID
    AND pro.ID = wrt_rec.wrt_pro_id(+)
    AND pro.ID = pne_rec.pne_pro_id(+)
    AND pro.ID = ebr_rec.ebp_pro_id(+)
    ORDER BY pro.TYPE_OF_WORK;
    /* Cursor for order by TYPE_OF_WORK descending */
    CURSOR c_pro_sum_work_dsc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
    cp_user_id USERS.ID%TYPE,
    cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
    cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
    cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
    SELECT pro.ID id,
    pro.NAME name,
    pro.TYPE_OF_WORK type_of_work,
    pro.STAGE stage,
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
    pro.Currency currency,
    pro.VALUE value,
    pro.DISPLAY_VALUE display_value,
    TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
    DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
    'true','false')
    ||'~'||DECODE(SIGN(cp_last_accessed_date -
    TRUNC(pro.LATEST_UPDATED_DATE)
    ),0,'true'
    ,-1,'true'
    ,1,'false')
    ||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
    ||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
    ||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
    FROM PROJECTS pro,
    TMP_PROJECTS tmp,
    (SELECT wrt.PRO_ID wrt_pro_id
    FROM WATCH_REQUESTS wrt,
    TMP_PROJECTS tmp_sub
    WHERE wrt.VIEWED_DATE IS NULL
    AND wrt.PSR_PSN_PSE_ID = cp_pse_id
    AND wrt.PSR_USR_ID = cp_user_id
    AND tmp_sub.PRO_ID = wrt.PRO_ID
    GROUP BY wrt.PRO_ID) wrt_rec,
    (SELECT pne.PRO_ID pne_pro_id
    FROM PROJECT_NOTES pne,
    TMP_PROJECTS tmp_pne
    WHERE pne.USR_ID = cp_user_id
    AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
    (SELECT ebr.STATUS ebr_status,
    ebp.PRO_ID ebp_pro_id
    FROM EXTRACT_BATCH_HEADERS ebr,
    EXTRACT_BATCH_PROJECTS ebp,
    TMP_PROJECTS tmp_ebr
    WHERE ebr.ID = ebp.EBR_ID
    AND ebp.PRO_ID = tmp_ebr.PRO_ID
    AND ebr.USR_ID = cp_user_id
    AND ebr.STATUS = cp_status) ebr_rec
    WHERE pro.ID = tmp.PRO_ID
    AND pro.ID = wrt_rec.wrt_pro_id(+)
    AND pro.ID = pne_rec.pne_pro_id(+)
    AND pro.ID = ebr_rec.ebp_pro_id(+)
    ORDER BY pro.TYPE_OF_WORK DESC;
    /* Cursor for order by STAGE asc*/
    CURSOR c_pro_sum_stage_asc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
    cp_user_id USERS.ID%TYPE,
    cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
    cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
    cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
    SELECT pro.ID id,
    pro.NAME name,
    pro.TYPE_OF_WORK type_of_work,
    pro.STAGE stage,
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
    pro.Currency currency,
    pro.VALUE value,
    pro.DISPLAY_VALUE display_value,
    TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
    DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
    'true','false')
    ||'~'||DECODE(SIGN(cp_last_accessed_date -
    TRUNC(pro.LATEST_UPDATED_DATE)
    ),0,'true'
    ,-1,'true'
    ,1,'false')
    ||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
    ||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
    ||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
    FROM PROJECTS pro,
    TMP_PROJECTS tmp,
    (SELECT wrt.PRO_ID wrt_pro_id
    FROM WATCH_REQUESTS wrt,
    TMP_PROJECTS tmp_sub
    WHERE wrt.VIEWED_DATE IS NULL
    AND wrt.PSR_PSN_PSE_ID = cp_pse_id
    AND wrt.PSR_USR_ID = cp_user_id
    AND tmp_sub.PRO_ID = wrt.PRO_ID
    GROUP BY wrt.PRO_ID) wrt_rec,
    (SELECT pne.PRO_ID pne_pro_id
    FROM PROJECT_NOTES pne,
    TMP_PROJECTS tmp_pne
    WHERE pne.USR_ID = cp_user_id
    AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
    (SELECT ebr.STATUS ebr_status,
    ebp.PRO_ID ebp_pro_id
    FROM EXTRACT_BATCH_HEADERS ebr,
    EXTRACT_BATCH_PROJECTS ebp,
    TMP_PROJECTS tmp_ebr
    WHERE ebr.ID = ebp.EBR_ID
    AND ebp.PRO_ID = tmp_ebr.PRO_ID
    AND ebr.USR_ID = cp_user_id
    AND ebr.STATUS = cp_status) ebr_rec
    WHERE pro.ID = tmp.PRO_ID
    AND pro.ID = wrt_rec.wrt_pro_id(+)
    AND pro.ID = pne_rec.pne_pro_id(+)
    AND pro.ID = ebr_rec.ebp_pro_id(+)
    ORDER BY pro.STAGE;
    /* Cursor for order by STAGE descending */
    CURSOR c_pro_sum_stage_dsc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
    cp_user_id USERS.ID%TYPE,
    cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
    cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
    cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
    SELECT pro.ID id,
    pro.NAME name,
    pro.TYPE_OF_WORK type_of_work,
    pro.STAGE stage,
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
    pro.Currency currency,
    pro.VALUE value,
    pro.DISPLAY_VALUE display_value,
    TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
    DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
    'true','false')
    ||'~'||DECODE(SIGN(cp_last_accessed_date -
    TRUNC(pro.LATEST_UPDATED_DATE)
    ),0,'true'
    ,-1,'true'
    ,1,'false')
    ||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
    ||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
    ||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
    FROM PROJECTS pro,
    TMP_PROJECTS tmp,
    (SELECT wrt.PRO_ID wrt_pro_id
    FROM WATCH_REQUESTS wrt,
    TMP_PROJECTS tmp_sub
    WHERE wrt.VIEWED_DATE IS NULL
    AND wrt.PSR_PSN_PSE_ID = cp_pse_id
    AND wrt.PSR_USR_ID = cp_user_id
    AND tmp_sub.PRO_ID = wrt.PRO_ID
    GROUP BY wrt.PRO_ID) wrt_rec,
    (SELECT pne.PRO_ID pne_pro_id
    FROM PROJECT_NOTES pne,
    TMP_PROJECTS tmp_pne
    WHERE pne.USR_ID = cp_user_id
    AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
    (SELECT ebr.STATUS ebr_status,
    ebp.PRO_ID ebp_pro_id
    FROM EXTRACT_BATCH_HEADERS ebr,
    EXTRACT_BATCH_PROJECTS ebp,
    TMP_PROJECTS tmp_ebr
    WHERE ebr.ID = ebp.EBR_ID
    AND ebp.PRO_ID = tmp_ebr.PRO_ID
    AND ebr.USR_ID = cp_user_id
    AND ebr.STATUS = cp_status) ebr_rec
    WHERE pro.ID = tmp.PRO_ID
    AND pro.ID = wrt_rec.wrt_pro_id(+)
    AND pro.ID = pne_rec.pne_pro_id(+)
    AND pro.ID = ebr_rec.ebp_pro_id(+)
    ORDER BY pro.STAGE DESC;
    /* Cursor for order by LOCATION asc*/
    CURSOR c_pro_sum_loc_asc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
    cp_user_id USERS.ID%TYPE,
    cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
    cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
    cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
    SELECT pro.ID id,
    pro.NAME name,
    pro.TYPE_OF_WORK type_of_work,
    pro.STAGE stage,
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
    pro.Currency currency,
    pro.VALUE value,
    pro.DISPLAY_VALUE display_value,
    TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
    DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
    'true','false')
    ||'~'||DECODE(SIGN(cp_last_accessed_date -
    TRUNC(pro.LATEST_UPDATED_DATE)
    ),0,'true'
    ,-1,'true'
    ,1,'false')
    ||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
    ||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
    ||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
    FROM PROJECTS pro,
    TMP_PROJECTS tmp,
    (SELECT wrt.PRO_ID wrt_pro_id
    FROM WATCH_REQUESTS wrt,
    TMP_PROJECTS tmp_sub
    WHERE wrt.VIEWED_DATE IS NULL
    AND wrt.PSR_PSN_PSE_ID = cp_pse_id
    AND wrt.PSR_USR_ID = cp_user_id
    AND tmp_sub.PRO_ID = wrt.PRO_ID
    GROUP BY wrt.PRO_ID) wrt_rec,
    (SELECT pne.PRO_ID pne_pro_id
    FROM PROJECT_NOTES pne,
    TMP_PROJECTS tmp_pne
    WHERE pne.USR_ID = cp_user_id
    AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
    (SELECT ebr.STATUS ebr_status,
    ebp.PRO_ID ebp_pro_id
    FROM EXTRACT_BATCH_HEADERS ebr,
    EXTRACT_BATCH_PROJECTS ebp,
    TMP_PROJECTS tmp_ebr
    WHERE ebr.ID = ebp.EBR_ID
    AND ebp.PRO_ID = tmp_ebr.PRO_ID
    AND ebr.USR_ID = cp_user_id
    AND ebr.STATUS = cp_status) ebr_rec
    WHERE pro.ID = tmp.PRO_ID
    AND pro.ID = wrt_rec.wrt_pro_id(+)
    AND pro.ID = pne_rec.pne_pro_id(+)
    AND pro.ID = ebr_rec.ebp_pro_id(+)
    -- ORDER BY DECODE(cp_loc_lvl
    -- ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    -- ,'C',pro.ADDRESS_LINE_4),
    ORDER BY DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
    TRUNC(pro.LATEST_UPDATED_DATE)DESC,
    pro.VALUE DESC,
    pro.ID DESC;
    /* Cursor for order by LOCATION descending */
    CURSOR c_pro_sum_loc_dsc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
    cp_user_id USERS.ID%TYPE,
    cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
    cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
    cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
    SELECT pro.ID id,
    pro.NAME name,
    pro.TYPE_OF_WORK type_of_work,
    pro.STAGE stage,
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
    pro.Currency currency,
    pro.VALUE value,
    pro.DISPLAY_VALUE display_value,
    TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
    DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
    'true','false')
    ||'~'||DECODE(SIGN(cp_last_accessed_date -
    TRUNC(pro.LATEST_UPDATED_DATE)
    ),0,'true'
    ,-1,'true'
    ,1,'false')
    ||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
    ||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
    ||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
    FROM PROJECTS pro,
    TMP_PROJECTS tmp,
    (SELECT wrt.PRO_ID wrt_pro_id
    FROM WATCH_REQUESTS wrt,
    TMP_PROJECTS tmp_sub
    WHERE wrt.VIEWED_DATE IS NULL
    AND wrt.PSR_PSN_PSE_ID = cp_pse_id
    AND wrt.PSR_USR_ID = cp_user_id
    AND tmp_sub.PRO_ID = wrt.PRO_ID
    GROUP BY wrt.PRO_ID) wrt_rec,
    (SELECT pne.PRO_ID pne_pro_id
    FROM PROJECT_NOTES pne,
    TMP_PROJECTS tmp_pne
    WHERE pne.USR_ID = cp_user_id
    AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
    (SELECT ebr.STATUS ebr_status,
    ebp.PRO_ID ebp_pro_id
    FROM EXTRACT_BATCH_HEADERS ebr,
    EXTRACT_BATCH_PROJECTS ebp,
    TMP_PROJECTS tmp_ebr
    WHERE ebr.ID = ebp.EBR_ID
    AND ebp.PRO_ID = tmp_ebr.PRO_ID
    AND ebr.USR_ID = cp_user_id
    AND ebr.STATUS = cp_status) ebr_rec
    WHERE pro.ID = tmp.PRO_ID
    AND pro.ID = wrt_rec.wrt_pro_id(+)
    AND pro.ID = pne_rec.pne_pro_id(+)
    AND pro.ID = ebr_rec.ebp_pro_id(+)
    -- ORDER BY DECODE(cp_loc_lvl
    -- ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    -- ,'C',pro.ADDRESS_LINE_4) DESC,
    ORDER BY DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) DESC,
    TRUNC(pro.LATEST_UPDATED_DATE) DESC,
    pro.VALUE DESC,
    pro.ID DESC;
    /* Cursor for order by VALUE asc*/
    CURSOR c_pro_sum_val_asc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
    cp_user_id USERS.ID%TYPE,
    cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
    cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
    cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
    SELECT pro.ID id,
    pro.NAME name,
    pro.TYPE_OF_WORK type_of_work,
    pro.STAGE stage,
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
    pro.Currency currency,
    pro.VALUE value,
    pro.DISPLAY_VALUE display_value,
    TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
    DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
    'true','false')
    ||'~'||DECODE(SIGN(cp_last_accessed_date -
    TRUNC(pro.LATEST_UPDATED_DATE)
    ),0,'true'
    ,-1,'true'
    ,1,'false')
    ||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
    ||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
    ||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
    FROM PROJECTS pro,
    TMP_PROJECTS tmp,
    (SELECT wrt.PRO_ID wrt_pro_id
    FROM WATCH_REQUESTS wrt,
    TMP_PROJECTS tmp_sub
    WHERE wrt.VIEWED_DATE IS NULL
    AND wrt.PSR_PSN_PSE_ID = cp_pse_id
    AND wrt.PSR_USR_ID = cp_user_id
    AND tmp_sub.PRO_ID = wrt.PRO_ID
    GROUP BY wrt.PRO_ID) wrt_rec,
    (SELECT pne.PRO_ID pne_pro_id
    FROM PROJECT_NOTES pne,
    TMP_PROJECTS tmp_pne
    WHERE pne.USR_ID = cp_user_id
    AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
    (SELECT ebr.STATUS ebr_status,
    ebp.PRO_ID ebp_pro_id
    FROM EXTRACT_BATCH_HEADERS ebr,
    EXTRACT_BATCH_PROJECTS ebp,
    TMP_PROJECTS tmp_ebr
    WHERE ebr.ID = ebp.EBR_ID
    AND ebp.PRO_ID = tmp_ebr.PRO_ID
    AND ebr.USR_ID = cp_user_id
    AND ebr.STATUS = cp_status) ebr_rec
    WHERE pro.ID = tmp.PRO_ID
    AND pro.ID = wrt_rec.wrt_pro_id(+)
    AND pro.ID = pne_rec.pne_pro_id(+)
    AND pro.ID = ebr_rec.ebp_pro_id(+)
    ORDER BY pro.VALUE,
    TRUNC(pro.LATEST_UPDATED_DATE),
    -- DECODE(cp_loc_lvl
    -- ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    -- ,'C',pro.ADDRESS_LINE_4),
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
    pro.ID DESC;
    /* Cursor for order by VALUE descending */
    CURSOR c_pro_sum_val_dsc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
    cp_user_id USERS.ID%TYPE,
    cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
    cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
    cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
    SELECT pro.ID id,
    pro.NAME name,
    pro.TYPE_OF_WORK type_of_work,
    pro.STAGE stage,
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
    pro.Currency currency,
    pro.VALUE value,
    pro.DISPLAY_VALUE display_value,
    TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
    DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
    'true','false')
    ||'~'||DECODE(SIGN(cp_last_accessed_date -
    TRUNC(pro.LATEST_UPDATED_DATE)
    ),0,'true'
    ,-1,'true'
    ,1,'false')
    ||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
    ||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
    ||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
    FROM PROJECTS pro,
    TMP_PROJECTS tmp,
    (SELECT wrt.PRO_ID wrt_pro_id
    FROM WATCH_REQUESTS wrt,
    TMP_PROJECTS tmp_sub
    WHERE wrt.VIEWED_DATE IS NULL
    AND wrt.PSR_PSN_PSE_ID = cp_pse_id
    AND wrt.PSR_USR_ID = cp_user_id
    AND tmp_sub.PRO_ID = wrt.PRO_ID
    GROUP BY wrt.PRO_ID) wrt_rec,
    (SELECT pne.PRO_ID pne_pro_id
    FROM PROJECT_NOTES pne,
    TMP_PROJECTS tmp_pne
    WHERE pne.USR_ID = cp_user_id
    AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
    (SELECT ebr.STATUS ebr_status,
    ebp.PRO_ID ebp_pro_id
    FROM EXTRACT_BATCH_HEADERS ebr,
    EXTRACT_BATCH_PROJECTS ebp,
    TMP_PROJECTS tmp_ebr
    WHERE ebr.ID = ebp.EBR_ID
    AND ebp.PRO_ID = tmp_ebr.PRO_ID
    AND ebr.USR_ID = cp_user_id
    AND ebr.STATUS = cp_status) ebr_rec
    WHERE pro.ID = tmp.PRO_ID
    AND pro.ID = wrt_rec.wrt_pro_id(+)
    AND pro.ID = pne_rec.pne_pro_id(+)
    AND pro.ID = ebr_rec.ebp_pro_id(+)
    ORDER BY pro.VALUE DESC,
    TRUNC(pro.LATEST_UPDATED_DATE) DESC,
    -- DECODE(cp_loc_lvl
    -- ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    -- ,'C',pro.ADDRESS_LINE_4),
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
    pro.ID DESC;
    /* Cursor for order by LATEST_UPDATED_DATE asc*/
    CURSOR c_pro_sum_lud_asc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
    cp_user_id USERS.ID%TYPE,
    cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
    cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
    cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
    SELECT pro.ID id,
    pro.NAME name,
    pro.TYPE_OF_WORK type_of_work,
    pro.STAGE stage,
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
    pro.Currency currency,
    pro.VALUE value,
    pro.DISPLAY_VALUE display_value,
    TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
    DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
    'true','false')
    ||'~'||DECODE(SIGN(cp_last_accessed_date -
    TRUNC(pro.LATEST_UPDATED_DATE)
    ),0,'true'
    ,-1,'true'
    ,1,'false')
    ||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
    ||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
    ||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
    FROM PROJECTS pro,
    TMP_PROJECTS tmp,
    (SELECT wrt.PRO_ID wrt_pro_id
    FROM WATCH_REQUESTS wrt,
    TMP_PROJECTS tmp_sub
    WHERE wrt.VIEWED_DATE IS NULL
    AND wrt.PSR_PSN_PSE_ID = cp_pse_id
    AND wrt.PSR_USR_ID = cp_user_id
    AND tmp_sub.PRO_ID = wrt.PRO_ID
    GROUP BY wrt.PRO_ID) wrt_rec,
    (SELECT pne.PRO_ID pne_pro_id
    FROM PROJECT_NOTES pne,
    TMP_PROJECTS tmp_pne
    WHERE pne.USR_ID = cp_user_id
    AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
    (SELECT ebr.STATUS ebr_status,
    ebp.PRO_ID ebp_pro_id
    FROM EXTRACT_BATCH_HEADERS ebr,
    EXTRACT_BATCH_PROJECTS ebp,
    TMP_PROJECTS tmp_ebr
    WHERE ebr.ID = ebp.EBR_ID
    AND ebp.PRO_ID = tmp_ebr.PRO_ID
    AND ebr.USR_ID = cp_user_id
    AND ebr.STATUS = cp_status) ebr_rec
    WHERE pro.ID = tmp.PRO_ID
    AND pro.ID = wrt_rec.wrt_pro_id(+)
    AND pro.ID = pne_rec.pne_pro_id(+)
    AND pro.ID = ebr_rec.ebp_pro_id(+)
    ORDER BY TRUNC(pro.LATEST_UPDATED_DATE),
    pro.VALUE DESC,
    -- DECODE(cp_loc_lvl
    -- ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    -- ,'C',pro.ADDRESS_LINE_4),
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
    pro.ID DESC;
    /* Cursor for order by LATEST_UPDATED_DATE descending*/
    CURSOR c_pro_sum_lud_dsc(cp_pse_id PORTAL_SERVICES.ID%TYPE,
    cp_user_id USERS.ID%TYPE,
    cp_status EXTRACT_BATCH_HEADERS.STATUS%TYPE,
    cp_loc_lvl PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE,
    cp_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE ) IS
    SELECT pro.ID id,
    pro.NAME name,
    pro.TYPE_OF_WORK type_of_work,
    pro.STAGE stage,
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))) location,
    pro.Currency currency,
    pro.VALUE value,
    pro.DISPLAY_VALUE display_value,
    TO_CHAR(pro.LATEST_UPDATED_DATE,'DD/MM/YYYY') latest_updated_date,
    DECODE(pro.LATEST_UPDATED_DATE, pro.CREATED_DATE,
    'true','false')
    ||'~'||DECODE(SIGN(cp_last_accessed_date -
    TRUNC(pro.LATEST_UPDATED_DATE)
    ),0,'true'
    ,-1,'true'
    ,1,'false')
    ||'~'||DECODE(wrt_rec.wrt_pro_id,NULL,'false','true')
    ||'~'||DECODE(pne_rec.pne_pro_id,NULL,'false','true')
    ||'~'||DECODE(ebr_rec.ebr_status,cp_status,'true','false') flags
    FROM PROJECTS pro,
    TMP_PROJECTS tmp,
    (SELECT wrt.PRO_ID wrt_pro_id
    FROM WATCH_REQUESTS wrt,
    TMP_PROJECTS tmp_sub
    WHERE wrt.VIEWED_DATE IS NULL
    AND wrt.PSR_PSN_PSE_ID = cp_pse_id
    AND wrt.PSR_USR_ID = cp_user_id
    AND tmp_sub.PRO_ID = wrt.PRO_ID
    GROUP BY wrt.PRO_ID) wrt_rec,
    (SELECT pne.PRO_ID pne_pro_id
    FROM PROJECT_NOTES pne,
    TMP_PROJECTS tmp_pne
    WHERE pne.USR_ID = cp_user_id
    AND tmp_pne.PRO_ID = pne.PRO_ID) pne_rec,
    (SELECT ebr.STATUS ebr_status,
    ebp.PRO_ID ebp_pro_id
    FROM EXTRACT_BATCH_HEADERS ebr,
    EXTRACT_BATCH_PROJECTS ebp,
    TMP_PROJECTS tmp_ebr
    WHERE ebr.ID = ebp.EBR_ID
    AND ebp.PRO_ID = tmp_ebr.PRO_ID
    AND ebr.USR_ID = cp_user_id
    AND ebr.STATUS = cp_status) ebr_rec
    WHERE pro.ID = tmp.PRO_ID
    AND pro.ID = wrt_rec.wrt_pro_id(+)
    AND pro.ID = pne_rec.pne_pro_id(+)
    AND pro.ID = ebr_rec.ebp_pro_id(+)
    ORDER BY TRUNC(pro.LATEST_UPDATED_DATE) DESC,
    pro.VALUE DESC,
    -- DECODE(cp_loc_lvl
    -- ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    -- ,'C',pro.ADDRESS_LINE_4),
    DECODE(cp_loc_lvl
    ,'T',NVL(pro.ADDRESS_LINE_3,pro.ADDRESS_LINE_4)
    ,'C',pro.ADDRESS_LINE_4)||', '||
    SUBSTR(POST_CODE,1,DECODE(LTRIM(INSTR(POST_CODE,' ')),0,
    LENGTH(POST_CODE),LTRIM(INSTR(POST_CODE,' ')))),
    pro.ID DESC;
    /* Local Variables */
    v_tt_pro_id DS$REF.TT_PRO_ID;
    v_first PROJECTS.ID%TYPE := p_project_id_arr.FIRST;
    v_last PROJECTS.ID%TYPE := 0;
    v_project_id_count PROJECTS.ID%TYPE := p_project_id_arr.COUNT;
    v_page_count PROJECTS.ID%TYPE := 0;
    v_delimter CONSTANT VARCHAR2(1) := '|';
    v_sort_no NUMBER;
    v_sort_order VARCHAR2(4);
    v_sort_by_column VARCHAR2(30);
    v_last_accessed_date USERS.LAST_ACCESSED_DATE%TYPE;
    v_loc_level PORTAL_SCS.LOCATION_REPORTING_LEVEL%TYPE;
    /* Variables for Error handling */
    v_location ERROR_LOGS.LOCATION%TYPE := ' :: 0';
    v_module CONSTANT VARCHAR2(25) := 'DS$234.DS$2342_PROC';
    e_user_defined_excep EXCEPTION;
    PRAGMA EXCEPTION_INIT (e_user_defined_excep, -20001);
    /* Variables for Timestamp logging */
    v_tpg_id NUMBER;
    v_start_time NUMBER;
    v_tt_location DS$REF.TT_VARCHAR2;
    BEGIN
    v_location := ' :: 1';
    /*Dynamically change the sort area size to 64 mb */
    EXECUTE IMMEDIATE 'ALTER SESSION SET SORT_AREA_SIZE = 67108864';
    v_location := ' :: 1a';
    -- Call to timestamp log procedure for logging start time.
    DS$226.DS$2261_PROC(p_usr_id => p_user_id,
    p_module_name => v_module,
    p_call_by_module => 'ds_projectlist_bl.jsp',
    p_caller_module => NULL,
    o_tpg_id => v_tpg_id,
    o_start_time => v_start_time);
    v_location := ' 1a';
    v_last_accessed_date :=TRUNC(TO_DATE(p_last_accessed_date,'DD MON YYYY HH24:MI:SS'));
    v_location := ' 2';
    v_sort_no := SUBSTR(p_sort_order,
    1,
    INSTR(p_sort_order, v_delimter,1) - 1
    v_sort_order := SUBSTR(p_sort_order,
    INSTR(p_sort_order,v_delimter,1)+ 1
    v_page_count := CEIL(((p_project_id_arr.COUNT)/p_records_per_page));
    v_location := ' 3';
    FOR j IN 1..v_page_count
    LOOP
    v_location := ' 4';
    v_first := v_first;
    v_last := v_first + (p_records_per_page - 1);
    IF (v_last >= v_project_id_count)
    THEN
    v_last := v_project_id_count;
    ELSE
    v_last := v_first + (p_records_per_page - 1);
    END IF;
    IF (j = p_page_no)
    THEN
    v_location := ' 5';
    EXIT;
    END IF;
    v_location := ' 6';
    v_first := v_last + 1;
    v_location := ' 7';
    END LOOP;
    v_location := ' 8';
    FORALL i IN v_first..v_last
    INSERT INTO TMP_PROJECTS VALUES(p_project_id_arr(i));
    FORALL i IN p_project_id_arr.FIRST..p_project_id_arr.LAST
    INSERT INTO TMP_PROJECTS VALUES(p_project_id_arr(i));
    v_location := ' 9';
    OPEN c_psc(p_pse_id);
    LOOP
    FETCH c_psc INTO v_loc_level;
    EXIT WHEN c_psc%NOTFOUND;
    IF c_psc%ROWCOUNT > 1
    THEN
    v_location := ' 10';
    CLOSE c_psc;
    RAISE_APPLICATION_ERROR(-20001,'PLS-00234201');
    END IF;
    END LOOP;
    CLOSE c_psc;
    v_location := ' 11';
    IF v_loc_level IS NULL
    THEN
    v_location := ' 12';
    RAISE_APPLICATION_ERROR(-20001,'PLS-00234202');
    END IF;
    IF (v_sort_no = 1)
    THEN
    v_location := ' 13';
    IF (v_sort_order ='ASC' )
    THEN
    v_location := ' 14';
    IF c_projects_name_order_asc%ISOPEN
    THEN
    CLOSE c_projects_name_order_asc;
    END IF;
    OPEN c_projects_name_order_asc;
    v_location := ' 15';
    FETCH c_projects_name_order_asc BULK COLLECT INTO v_tt_pro_id;
    v_location := ' 16';
    CLOSE c_projects_name_order_asc;
    /* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
    v_location := ' 17';
    o_pro_all_id_array := v_tt_pro_id;
    /* Delete records from temporary table TMP_PROJECTS */
    v_location := ' 18';
    DELETE FROM TMP_PROJECTS;
    /* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
    v_location := ' 19';
    FORALL i IN v_first..v_last
    INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
    v_location := ' 20';
    OPEN c_pro_sum_name_asc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
    v_location := ' 21';
    FETCH c_pro_sum_name_asc BULK COLLECT INTO o_pro_id_array,
    o_name_array,
    o_type_of_work_array,
    o_stage_array,
    o_loc_array,
    o_currency_array,
    o_value_array,
    o_display_value_array,
    o_latest_updated_date_array,
    o_flag_array;
    CLOSE c_pro_sum_name_asc;
    ELSE
    v_location := ' 22';
    IF c_projects_name_order_desc%ISOPEN
    THEN
    CLOSE c_projects_name_order_desc;
    END IF;
    OPEN c_projects_name_order_desc;
    v_location := ' 23';
    FETCH c_projects_name_order_desc BULK COLLECT INTO v_tt_pro_id;
    CLOSE c_projects_name_order_desc;
    /* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
    v_location := ' 24';
    o_pro_all_id_array := v_tt_pro_id;
              /*Delete records from temporary table TMP_PROJECTS */
    v_location := ' 25';
    DELETE FROM TMP_PROJECTS;
    /* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
    v_location := ' 26';
    FORALL i IN v_first..v_last
    INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
    v_location := ' 27';
    OPEN c_pro_sum_name_dsc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
    v_location := ' 28';
    FETCH c_pro_sum_name_dsc BULK COLLECT INTO o_pro_id_array,
    o_name_array,
    o_type_of_work_array,
    o_stage_array,
    o_loc_array,
    o_currency_array,
    o_value_array,
    o_display_value_array,
    o_latest_updated_date_array,
    o_flag_array;
    CLOSE c_pro_sum_name_dsc;
    END IF;
    ELSIF (v_sort_no = 2)
    THEN
    v_location := ' 29';
    IF (v_sort_order ='ASC' )
    THEN
    v_location := ' 30';
    IF c_projects_work_order_asc%ISOPEN
    THEN
    CLOSE c_projects_work_order_asc;
    END IF;
    OPEN c_projects_work_order_asc;
    v_location := ' 31';
    FETCH c_projects_work_order_asc BULK COLLECT INTO v_tt_pro_id;
    CLOSE c_projects_work_order_asc;
    /* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
    v_location := ' 32';
    o_pro_all_id_array := v_tt_pro_id;
    /* Delete records from temporary table TMP_PROJECTS */
    DELETE FROM TMP_PROJECTS;
    /* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
    v_location := ' 33';
    FORALL i IN v_first..v_last
    INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
    v_location := ' 34';
    OPEN c_pro_sum_work_asc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
    v_location := ' 35';
    FETCH c_pro_sum_work_asc BULK COLLECT INTO o_pro_id_array,
    o_name_array,
    o_type_of_work_array,
    o_stage_array,
    o_loc_array,
    o_currency_array,
    o_value_array,
    o_display_value_array,
    o_latest_updated_date_array,
    o_flag_array;
    CLOSE c_pro_sum_work_asc;
    ELSE
    v_location := ' 36';
    IF c_projects_work_order_desc%ISOPEN
    THEN
    CLOSE c_projects_work_order_desc;
    END IF;
    OPEN c_projects_work_order_desc;
    v_location := ' 37';
    FETCH c_projects_work_order_desc BULK COLLECT INTO v_tt_pro_id;
    CLOSE c_projects_work_order_desc;
    /* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
    v_location := ' 38';
    o_pro_all_id_array := v_tt_pro_id;
    /* Delete records from temporary table TMP_PROJECTS */
    v_location := ' 39';
    DELETE FROM TMP_PROJECTS;
    /* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
    v_location := ' 40';
    FORALL i IN v_first..v_last
    INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
    v_location := ' 41';
    OPEN c_pro_sum_work_dsc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
    v_location := ' 42';
    FETCH c_pro_sum_work_dsc BULK COLLECT INTO o_pro_id_array,
    o_name_array,
    o_type_of_work_array,
    o_stage_array,
    o_loc_array,
    o_currency_array,
    o_value_array,
    o_display_value_array,
    o_latest_updated_date_array,
    o_flag_array;
    CLOSE c_pro_sum_work_dsc;
    END IF;
    ELSIF (v_sort_no = 3)
    THEN
    v_location := ' 43';
    IF (v_sort_order ='ASC' )
    THEN
    v_location := ' 44';
    IF c_projects_stage_order_asc%ISOPEN
    THEN
    CLOSE c_projects_stage_order_asc;
    END IF;
    OPEN c_projects_stage_order_asc;
    v_location := ' 45';
    FETCH c_projects_stage_order_asc BULK COLLECT INTO v_tt_pro_id;
    CLOSE c_projects_stage_order_asc;
    /* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
    v_location := ' 46';
    o_pro_all_id_array := v_tt_pro_id;
    /* Delete records from temporary table TMP_PROJECTS */
    v_location := ' 47';
    DELETE FROM TMP_PROJECTS;
    /* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
    v_location := ' 48';
    FORALL i IN v_first..v_last
    INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
    v_location := ' 49';
    OPEN c_pro_sum_stage_asc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
    v_location := ' 50';
    FETCH c_pro_sum_stage_asc BULK COLLECT INTO o_pro_id_array,
    o_name_array,
    o_type_of_work_array,
    o_stage_array,
    o_loc_array,
    o_currency_array,
    o_value_array,
    o_display_value_array,
    o_latest_updated_date_array,
    o_flag_array;
    CLOSE c_pro_sum_stage_asc;
    ELSE
    v_location := ' 51';
    IF c_projects_stage_order_desc%ISOPEN
    THEN
    CLOSE c_projects_stage_order_desc;
    END IF;
    OPEN c_projects_stage_order_desc;
    v_location := ' 52';
    FETCH c_projects_stage_order_desc BULK COLLECT INTO v_tt_pro_id;
    CLOSE c_projects_stage_order_desc;
    /* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
    v_location := ' 53';
    o_pro_all_id_array := v_tt_pro_id;
         /* Delete records from temporary table TMP_PROJECTS */
    v_location := ' 54';
    DELETE FROM TMP_PROJECTS;
    /* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
    v_location := ' 55';
    FORALL i IN v_first..v_last
    INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
    v_location := ' 56';
    OPEN c_pro_sum_stage_dsc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
    v_location := ' 57';
    FETCH c_pro_sum_stage_dsc BULK COLLECT INTO o_pro_id_array,
    o_name_array,
    o_type_of_work_array,
    o_stage_array,
    o_loc_array,
    o_currency_array,
    o_value_array,
    o_display_value_array,
    o_latest_updated_date_array,
    o_flag_array;
    CLOSE c_pro_sum_stage_dsc;
    END IF;
    ELSIF (v_sort_no = 4)
    THEN
    v_location := ' 58';
    IF (v_sort_order ='ASC' )
    THEN
    IF c_projects_loc_order_asc%ISOPEN
    THEN
    CLOSE c_projects_loc_order_asc;
    END IF;
    OPEN c_projects_loc_order_asc(v_loc_level);
    v_location := ' 59';
    FETCH c_projects_loc_order_asc BULK COLLECT INTO v_tt_pro_id,v_tt_location;
    CLOSE c_projects_loc_order_asc;
    /* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY,O_LOCATION for fast scan */
    v_location := ' 60';
    o_pro_all_id_array := v_tt_pro_id;
    o_location := v_tt_location;
    /* Delete records from temporary table TMP_PROJECTS */
    v_location := ' 61';
    DELETE FROM TMP_PROJECTS;
    /* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
    v_location := ' 62';
    FORALL i IN v_first..v_last
    INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
    v_location := ' 63';
    OPEN c_pro_sum_loc_asc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
    v_location := ' 64';
    FETCH c_pro_sum_loc_asc BULK COLLECT INTO o_pro_id_array,
    o_name_array,
    o_type_of_work_array,
    o_stage_array,
    o_loc_array,
    o_currency_array,
    o_value_array,
    o_display_value_array,
    o_latest_updated_date_array,
    o_flag_array;
    CLOSE c_pro_sum_loc_asc;
    ELSE
    v_location := ' 65';
    IF c_projects_loc_order_desc%ISOPEN
    THEN
    CLOSE c_projects_loc_order_desc;
    END IF;
    OPEN c_projects_loc_order_desc (v_loc_level);
    v_location := ' 66';
    FETCH c_projects_loc_order_desc BULK COLLECT INTO v_tt_pro_id,v_tt_location;
    CLOSE c_projects_loc_order_desc;
    /* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY,O_LOCATION for fast scan */
    v_location := ' 67';
    o_pro_all_id_array := v_tt_pro_id;
    o_location := v_tt_location;
    /* Delete records from temporary table TMP_PROJECTS */
    DELETE FROM TMP_PROJECTS;
    /* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
    v_location := ' 68';
    FORALL i IN v_first..v_last
    INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
    v_location := ' 69';
    OPEN c_pro_sum_loc_dsc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
    v_location := ' 70';
    FETCH c_pro_sum_loc_dsc BULK COLLECT INTO o_pro_id_array,
    o_name_array,
    o_type_of_work_array,
    o_stage_array,
    o_loc_array,
    o_currency_array,
    o_value_array,
    o_display_value_array,
    o_latest_updated_date_array,
    o_flag_array;
    CLOSE c_pro_sum_loc_dsc;
    END IF;
    ELSIF (v_sort_no = 5)
    THEN
    v_location := ' 71';
    IF (v_sort_order ='ASC' )
    THEN
    v_location := ' 72';
    IF c_projects_value_order_asc%ISOPEN
    THEN
    CLOSE c_projects_value_order_asc;
    END IF;
    OPEN c_projects_value_order_asc(v_loc_level);
    v_location := ' 73';
    FETCH c_projects_value_order_asc BULK COLLECT INTO v_tt_pro_id,v_tt_location;
    CLOSE c_projects_value_order_asc;
    /* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
    v_location := ' 74';
    o_pro_all_id_array := v_tt_pro_id;
         o_location := v_tt_location;
    /* Delete records from temporary table TMP_PROJECTS */
    DELETE FROM TMP_PROJECTS;
    /* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
    v_location := ' 75';
    FORALL i IN v_first..v_last
    INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
    v_location := ' 76';
    OPEN c_pro_sum_val_asc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
    v_location := ' 77';
    FETCH c_pro_sum_val_asc BULK COLLECT INTO o_pro_id_array,
    o_name_array,
    o_type_of_work_array,
    o_stage_array,
    o_loc_array,
    o_currency_array,
    o_value_array,
    o_display_value_array,
    o_latest_updated_date_array,
    o_flag_array;
    CLOSE c_pro_sum_val_asc;
    ELSE
    v_location := ' 78';
    IF c_projects_value_order_desc%ISOPEN
    THEN
    CLOSE c_projects_value_order_desc;
    END IF;
    OPEN c_projects_value_order_desc(v_loc_level);
    v_location := ' 79';
    FETCH c_projects_value_order_desc BULK COLLECT INTO v_tt_pro_id,v_tt_location;
    CLOSE c_projects_value_order_desc;
    /* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
    v_location := ' 80';
    o_pro_all_id_array := v_tt_pro_id;
         o_location := v_tt_location;
    /* Delete records from temporary table TMP_PROJECTS */
    DELETE FROM TMP_PROJECTS;
    /* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
    v_location := ' 81';
    FORALL i IN v_first..v_last
    INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
    v_location := ' 82';
    OPEN c_pro_sum_val_dsc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
    FETCH c_pro_sum_val_dsc BULK COLLECT INTO o_pro_id_array,
    o_name_array,
    o_type_of_work_array,
    o_stage_array,
    o_loc_array,
    o_currency_array,
    o_value_array,
    o_display_value_array,
    o_latest_updated_date_array,
    o_flag_array;
    CLOSE c_pro_sum_val_dsc;
    END IF;
    ELSIF (v_sort_no = 6)
    THEN
    v_location := ' 83';
    IF (v_sort_order ='ASC' )
    THEN
    v_location := ' 84';
    IF c_projects_lud_order_asc%ISOPEN
    THEN
    CLOSE c_projects_lud_order_asc;
    END IF;
    OPEN c_projects_lud_order_asc(v_loc_level);
    v_location := ' 85';
    FETCH c_projects_lud_order_asc BULK COLLECT INTO v_tt_pro_id,v_tt_location;
    CLOSE c_projects_lud_order_asc;
    /* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
    v_location := ' 86';
    o_pro_all_id_array := v_tt_pro_id;
    o_location := v_tt_location;
    /* Delete records from temporary table TMP_PROJECTS */
    DELETE FROM TMP_PROJECTS;
    /* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
    v_location := ' 87';
    FORALL i IN v_first..v_last
    INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
    v_location := ' 88';
    OPEN c_pro_sum_lud_asc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
    FETCH c_pro_sum_lud_asc BULK COLLECT INTO o_pro_id_array,
    o_name_array,
    o_type_of_work_array,
    o_stage_array,
    o_loc_array,
    o_currency_array,
    o_value_array,
    o_display_value_array,
    o_latest_updated_date_array,
    o_flag_array;
    CLOSE c_pro_sum_lud_asc;
    ELSE
    v_location := ' 89';
    IF c_projects_lud_order_desc%ISOPEN
    THEN
    CLOSE c_projects_lud_order_desc;
    END IF;
    OPEN c_projects_lud_order_desc(v_loc_level);
    v_location := ' 90';
    FETCH c_projects_lud_order_desc BULK COLLECT INTO v_tt_pro_id,v_tt_location;
    CLOSE c_projects_lud_order_desc;
    /* Assign the Sorted project ids to O/P parameter O_PRO_ALL_ID_ARRAY for fast scan */
    v_location := ' 91';
    o_pro_all_id_array := v_tt_pro_id;
         o_location := v_tt_location;
    /* Delete records from temporary table TMP_PROJECTS */
    DELETE FROM TMP_PROJECTS;
    /* Insert records into TMP_PROJECTS as per the page number (p_page_no) */
    v_location := ' 92';
    -- FORALL i IN p_project_id_arr.FIRST..p_project_id_arr.LAST
    -- FORALL i IN v_first..v_last
    FORALL i IN v_first..v_last
    INSERT INTO TMP_PROJECTS VALUES(v_tt_pro_id(i));
    FORALL i IN p_project_id_arr.FIRST..p_project_id_arr.LAST
    INSERT INTO TUSH2 VALUES(v_tt_pro_id(i));
    v_location := ' 93';
    OPEN c_pro_sum_lud_dsc(p_pse_id,p_user_id,v_status,v_loc_level,v_last_accessed_date);
    FETCH c_pro_sum_lud_dsc BULK COLLECT INTO o_pro_id_array,
    o_name_array,
    o_type_of_work_array,
    o_stage_array,
    o_loc_array,
    o_currency_array,
    o_value_array,
    o_display_value_array,
    o_latest_updated_date_array,
    o_flag_array;
    CLOSE c_pro_sum_lud_dsc;
    END IF;
    END IF;
    v_location := ' 94';
    -- Call to Timestamp Logs for logging end_time.
    DS$226.DS$2262_PROC(p_usr_id => p_user_id,
    p_tpg_id => v_tpg_id,
    p_start_time => v_start_time);
    v_location := ' 95';
    EXCEPTION
    WHEN e_user_defined_excep
    THEN
    ds$221.ds$2211_proc(p_module_type => 'PLS',
    p_err_type => 'R',
    p_location => v_module ||'::'|| v_location,
    p_java_error_stack => NULL,
    p_user_id => p_user_id);
    RAISE;
    WHEN OTHERS
    THEN
    ds$221.ds$2211_proc(p_module_type => 'PLS',
    p_err_type => 'R',
    p_location => v_module || v_location,
    p_java_error_stack => NULL,
    p_user_id => p_user_id);
    RAISE;
    END;
    END;

  • ORA-06502: PL/SQL: numeric or value error: Bulk bind: Error in define (WWV-11230)

    Hello,
    I'm running into the above error when running a master/detail form. I can also run the form as a portlet and the form comes up but if I try to save, query or reset, I also get the error. I have portal 3.0.9.8.0 and I do have other master detail forms that work.
    Any thoughts?
    Thanks,
    Martin
    Table structure
    PCH
    PCH_ID NUMBER(9) NOT NULL PK,
    PCH_AGY NUMBER(9) NOT NULL
    PCD
    PCD_ID NUMBER(9) NOT NULL PK,
    PCD_CAN VARCHAR2(7) NOT NULL,
    PCD_PCH_ID NUMBER(9) NOT NULL FK to PCH.PCH_ID

    This usually happens when you upgrade/patch the db after you have upgraded portal/ias. The owa package required by portal are usually of a higher version than that supplied by the db, The db upgrade/patch will cause the owa packages to be overwritten. The solution as mentioned is to reload the latest owa packages supplied with portal/iAS.

  • ORA-6502:  PL/SQL: numeric or value error: Character string buffer too small

    I then ran the sql in APEX- SQL tool and got the following error
         URL Encoded SQL length exceeds 32k limit
    Is there a paramter that controls this value or is my only option to shrink the column data in the intractive report ?
    Note:  Toad renders data for the SQL - only an issue in APEX.
    Thanks

    Issue in APEX, sorry.. You will need to shrink the # of characters you are returning down in your select....
    Thank you,
    Tony Miller
    LuvMuffin Software

Maybe you are looking for

  • Open a file from a Projector?

    Hi folks, I'm probably just missing something, but here's my problem. I have a flash projector file for a client. Within the file are two buttons. One I want to point to a word document, and one I want to point to a pdf file. I don't want either of t

  • XL Reporter Peoblem

    Hi In XL Reporter we are not able to do  print the query in xl sheet. Problem is displaying ( Security Settings in Microsoft Excel Prohibit XL Reporter from Running .

  • Forms/Designer 10g - problem with attached libraries

    I've problem with forms with attached libraries. All of libraries have removed paths. I can run all forms without any problem on my local application server from Forms Builder 9i or Designer 9i. I added all paths in registry FORMS90_PATH. WORKINGDIRE

  • How to link to another project?

    Hello guys! I´ve got a little problem with captivate 4: I would like to put a button in my project that is linked to a specific slide in another project. Is this possible? I´m looking forward to hearing from you! Best regards Smoky Mc Pot 3555

  • Errors in transaction CRM_BUS2000115

    Hi, as I save a sales order from transaction CRM_BUS2000115 to transfer it to SAP R/3, I get the following errors even if the order is complete: The sales document is not yet complete Edit data ( Notification W V1 555) and Unknown object type 'BUS200