Pl/SQL procedure

The procedure appears to be failing when it hits a Wire transfer (Record #6800).   When it aborts the filename is not getting updated to “xloaded_”<filename> so it keeps attempting to reload the same file and is creating duplicate batches until the filenames are reloaded. 
LOAD_LOCKBOX_FILE procedure to find out why it’s failing when it hits a Wire Transfer Entry.
Wire Transfers should import into CODI exactly like a Standard Check imports with the exception of one field called Payment Type (ar_payment_header.payment_type).   It should have a value of ‘Check’ for standard checks and ‘Wire Transfer’ for wire transfers.    There are typically records created in three tables for this process (ar_batch, ar_payment_header, ar_payment_detail).   The Wire Transfer is creating the ar_batch entry (as seen above for batch ID “PYL09252013-1”), but there is no ar_payment_header or ar_payment_detail entry.
PLEASE HELP ME OUT TO FIGURE WHAT THE PROBLEM IS
Prodcedure
CREATE OR REPLACE PROCEDURE CO_DEVB.load_lockbox_file
IS
   tmpfile1 utl_file.file_type;
   inline           VARCHAR2 (32767);
   tmpname          VARCHAR2 (500);
   tmpname_no_txt   VARCHAR2 (500);
   xline_ctr        NUMBER;
   v_directory_name VARCHAR2 (100);
   v_directory_path VARCHAR2 (100); -- := '\\lighthouse-1\lockbox_files';
   tmpdir           VARCHAR2 (200);
   --CH3438 ---------------------------------------------------------------
   file_done        BOOLEAN  :=FALSE;
   unproc_files     NUMBER(2);  --number of unprocessed files in folder
   --CH3438 ---------------------------------------------------------------
   CURSOR cursor_filename
   IS
      SELECT filename
      FROM ar_dir_list
      WHERE (upper (filename) LIKE '%'
         ||'.TXT')
      AND upper (filename) NOT LIKE 'XLOADED%.TXT'
      ORDER BY filename;
   v_sales_year               NUMBER(4);
   v_prev_sales_year          NUMBER(4);
   v_batch_base               VARCHAR2(11);
   v_batch_description        VARCHAR2(50);
   v_created_by               VARCHAR2(30);
   v_batch_hdr_cnt            NUMBER(4)  :=0;
   v_batches_cnt              NUMBER(4)  :=0; 
   v_pymt_batch_exists        NUMBER(1);
   v_tot_payment_amount       NUMBER(12,2);
   v_num_remittances          NUMBER(4);
   v_batch_num_remittances    NUMBER(4);
   v_batch_tot_payment_amount NUMBER(12,2);
   v_billable_account_num     NUMBER(6);
   v_batch_id                 VARCHAR2(20);
   v_batch_type               VARCHAR2(20) :='Payment Batch';
   v_status                   VARCHAR2(2)  :='OP';
   v_hld_six_batch_num        VARCHAR2(3);
   v_hld_six_item_num         VARCHAR2(3);
   v_lkbx_hp_trip_ind         VARCHAR2(1);
   v_lkbx_except_reason       VARCHAR2(4);
   v_hld_four_batch_num       VARCHAR2(3);
   v_hld_four_item_num        VARCHAR2(3);
   v_hld_four_rec_type_9      VARCHAR2(1);
   v_discount_percent         NUMBER(5,2);
   v_discount_amount          NUMBER(14,2);
   v_lockbox_bank             VARCHAR2(2);
   v_bank_id                  VARCHAR2(2);
   v_payment_type_a           VARCHAR2(30) :='ACH';
   v_payment_type_c           VARCHAR2(30) :='Checks';
   v_payment_type_w           VARCHAR2(30) :='Wire';
   v_is_ach                   VARCHAR2(1)  :='N';
   v_payment_type             VARCHAR2(30);
   v_proc                     NUMBER(3);
   v_order_num                NUMBER(8);
   v_ar_payment_num           NUMBER(11);
   v_lkbx_dealer_num          NUMBER(6);
   v_payment_class            VARCHAR2(20) :='Customer Payment';
   v_acct_status              VARCHAR(1);
   v_is_harv_plan             VARCHAR(1);
   v_hp_balance               NUMBER(14,2);
   v_previous_yr_balance      VARCHAR(1);
   v_comment_ind              NUMBER(2);
   v_curr_yr_bal_amt          NUMBER(14,2);
   v_prev_yr_bal_amt          NUMBER(14,2);
   v_balance_ind              VARCHAR(1);
   v_check_for_op_payments    NUMBER(4);
   v_prev_yr_amt_apply        NUMBER(14,2);
   v_curr_yr_amt_apply        NUMBER(14,2);
   v_sequence_no              NUMBER(4);
   v_is_split_yrs             VARCHAR2(1);
   v_newfile_name             VARCHAR2(255);
   v_line1                    VARCHAR2(500);
   v_line2                    VARCHAR2(500);
   l_crlf                     VARCHAR2(2) := CHR (13) || CHR (10);
   l_cr                       VARCHAR2(1) := CHR (13);
   l_lf                       VARCHAR2(1) := CHR (10);
   v_msg_lines                VARCHAR2(5000);
   v_no_name                  VARCHAR2(25) :='No Name on detail in file';
   v_acct_msg                 VARCHAR2(25) :=' - VERIFY Acct#/Name.';
   v_name_use                 VARCHAR2(50);
   l_completed VARCHAR2(9)   :='COMPLETED';
   l_no_file   VARCHAR2(8)   :='NO FILES';
   l_sender    VARCHAR2(40)  :='CODI Administrator<[email protected]>';
   l_subject   VARCHAR2(100) :='Automated Lockbox Processing -- '||l_completed;
   l_email ctl_system_variables.value_str%TYPE;
   l_email_bcc ctl_system_variables.value_str%TYPE;
   l_email_cc ctl_system_variables.value_str%TYPE;
   l_message VARCHAR2(32000);
   l_attach  VARCHAR2(32000);
   l_email_batch_id   VARCHAR2(11); 
   l_rec_ind                VARCHAR2(1);
   l_record_type            VARCHAR2(1);
   l_rec_cnt                NUMBER(4);
   l_lockbox_name           VARCHAR2(10); -- from rec_type 1
   l_lockbox_date_alpha     VARCHAR2(6);
   l_lockbox_creation_date  DATE;
   l_lockbox_batch_num      VARCHAR2(3);
   l_lockbox_batch_item_num VARCHAR2(3);
   l_lkbx_dealer_num        NUMBER(6);
   l_lkbx_comments          VARCHAR2(250);
   l_lkbx_message           VARCHAR2(32000);
   l_lkbx_message2          VARCHAR2(32000);
   l_lkbx_issues            NUMBER(10);
   l_lkbx_header_acct_num   NUMBER(6);
   -- BAI Record Formats -- per document
   l_record_type VARCHAR2(1); -- record type indentifier (1 -- Transmission Header
   --                          5 -- Batch Header
   --                          6 -- Detail Record
   --                          4 -- Overflow record -- detail
   --                          7 -- Batch Total
   --                          8 -- Trailer
   --                          9 -- Trailer
   -- Transmission Header - record type 1
   l_trans_header_rec_type    VARCHAR2(1);
   l_trans_header_priority    VARCHAR2(2);  -- Priority
   l_trans_header_destination VARCHAR2(10); -- Company's account number at sending bank
   l_trans_header_origin      VARCHAR2(10); -- Sending bank's FR/ABA Number
   l_trans_header_date_alpha  VARCHAR2(6);  -- Transmission date (YYMMDD) -- alpha
   l_trans_header_date        DATE;         -- Transmission date (YYMMDD) -- Oracle date format
   l_trans_header_time        VARCHAR2(4);  -- Time -- NOT USED
   l_trans_header_filler      VARCHAR2(47); -- Filler - Blank
   -- Batch Header -- record type 5
   l_batch_header_rec_type    VARCHAR2(1);
   l_batch_header_batch_no    VARCHAR2(3);  -- Zero filled for Customer Payment, 900 for ACH, 800 for Wire
   l_batch_header_item_no     VARCHAR2(3);  -- Zero filled, NOT USED
   l_batch_header_lockbox_no  VARCHAR2(7);  -- Lockbox Number
   l_batch_header_date_alpha  VARCHAR2(6);  -- Deposit date at sending bank (YYMMDD) -- alpha
   l_batch_header_date        DATE;         -- Deposit date at sending bank (YYMMDD) -- Oracle date format
   l_batch_header_destination VARCHAR2(10); -- Company's account number at sending bank
   l_batch_header_origin      VARCHAR2(10); -- The sending bank's FR/ABA number (0TTTTAAAAC)
   l_batch_header_filler      VARCHAR2(40); -- Filler - Blank
   -- Detail Record -- record type 6
   l_batch_detail_rec_type       VARCHAR2(1);
   l_batch_detail_batch_no       VARCHAR2(3);  -- Sequentially assigned number for each batch of items deposited
   l_batch_detail_item_no        VARCHAR2(3);  -- Sequentially assigned number indicating the position of an item within a batch
   l_batch_detail_amount_alpha   VARCHAR2(10); -- Dollar amount of each check deposited -- alpha
   l_batch_detail_amount         NUMBER(10,2); -- Dollar amount of each check deposited -- converted to numeric
   l_batch_detail_route_no_lkbx  VARCHAR2(9);  -- Transit routing number for Lockbox
   l_batch_detail_account_number VARCHAR2(10); -- Remitter's account number parsed from l_batch_detailremitter_id
   l_batch_detail_check_no       VARCHAR2(9);  -- Check number of each check deposited
   l_batch_detail_trp_ind        VARCHAR2(1);  -- Trip or Harvest Plan indicator
   l_batch_detail_chk_date_a     VARCHAR2(6);  -- Check date alpha
   l_batch_detail_chk_date       DATE;         -- Check date Oracle format
   l_batch_detail_name           VARCHAR2(36); -- Name on check
   -- Overflow record -- record type 4
   l_batch_detail_ovfl_rec_type   VARCHAR2(1);
   l_batch_detail_ovfl_batch_no   VARCHAR2(3); -- Overflow batch no -- same as Detail Batch No in record 6
   l_batch_detail_ovfl_item_no    VARCHAR2(3); -- Overflow item no -- same as Detail Item No in record 6
   l_batch_detail_ovfl_rec_type_6 VARCHAR2(1); -- Constant 6 -- indicates that record is associated with previous 6 record
   l_batch_detail_ovfl_seq_no     VARCHAR2(2); -- Sequentially assigned number -- for overflow record
   l_batch_detail_ovfl_rec_type_9 VARCHAR2(1); -- This field is '9' if the record is the last of a series of overflows for a given
                                               -- check record (detail record 6, otherwise field is '0'
   l_batch_detail_ovfl_cust_no  VARCHAR2(6);   -- Customer Number
   l_batch_detail_ovfl_order_no VARCHAR2(8);   -- Order Number
   l_batch_detail_ovfl_name     VARCHAR2(50);  -- Customer Name
   l_type4_rec_no                NUMBER;       -- counter of type 4 records in type 6 batch
BEGIN
   xline_ctr := 0;
   tmpname   := ' ';
   SELECT VALUE_STR
   INTO v_directory_name
   FROM ctl_system_variables
   WHERE variable_name ='DIR_LOCKBOX';
   dbms_output.put_line('v_directory_name is '||v_directory_name);
   SELECT DIRECTORY_PATH
   INTO v_directory_path
   FROM dba_directories
   WHERE directory_name = v_directory_name;
   dbms_output.put_line('v_directory_path is '||v_directory_path);
   ar_get_dir_list (v_directory_path);
   BEGIN
   -- Check to see how many unprcoessed file exist in the folder
   --CH3438 ---------------------------------------------------------------
     begin
       select count(*)
         into unproc_files
         from ar_dir_list
        where (upper(filename) like '%'
             ||'.TXT')
          and upper (filename) not like 'XLOADED%.TXT';
     end;    
   --CH3438 ---------------------------------------------------------------
     if unproc_files = 0 then
       --dbms_output.put_line('NO FILES FOUND TO PROCESS');
       BEGIN
         l_sender       := pkg_ctl.get_value_str('Standard Email from');
         l_email        := pkg_ctl.get_value_str('Auto Lkbx Notify');
         l_email_cc     := pkg_ctl.get_value_str('Auto Lkbx Notify cc');
         l_email        := l_email ||';'||l_email_cc;
         l_email_bcc    := pkg_ctl.get_value_str('Auto Lkbx Notify bcc');
         l_subject      :='Automated Lockbox Processing -- '||l_no_file;
         l_lkbx_message :='NO Current Lockbox files were found or the files were previously loaded.'|| chr(13) || chr(10);
         l_message      :=l_lkbx_message;
         pkg_mail.send_email_no_attach(l_sender,l_email,l_email_bcc,l_subject,l_message,' ');
       END;
     else
       BEGIN
         OPEN cursor_filename;
           LOOP
             FETCH cursor_filename INTO tmpname;
             EXIT WHEN cursor_filename%NOTFOUND;
             l_rec_cnt                  :=0;
             v_batch_hdr_cnt            :=0;
             v_pymt_batch_exists        :=0;
             v_tot_payment_amount       :=0;
             v_num_remittances          :=0;
             v_batch_num_remittances    :=0;
             v_batch_tot_payment_amount :=0;
             v_billable_account_num     :=NULL;
             l_lkbx_issues              :=0;
             l_lkbx_header_acct_num     :=0;
             dbms_output.put_line('Filename === '||tmpname);
             ----- OPEN FILE TO PROCESS ----
             tmpfile1 := utl_file.fopen (v_directory_name,tmpname,'r');
             inline   := NULL;
             IF utl_file.is_open(tmpfile1) THEN
               dbms_output.put_line('Processing '||tmpname);
               v_batch_description :=NULL;
               v_created_by        :=NULL;
             END IF;
             LOOP
               utl_file.get_line (tmpfile1,inline);
               --dbms_output.put_line(inline);
               l_rec_ind := SUBSTR(inline,1,1);
               ----- Record Type 1 -----
               IF l_rec_ind = '1' THEN
                 v_sales_year               :=pkg_ctl.get_financial_year;
                 v_prev_sales_year          := v_sales_year -1;
                 v_batch_base               := 'PYL'||TO_CHAR(SYSDATE,'MMDDRRRR');
                 l_lockbox_name             :=SUBSTR(inline,4,10);
                 l_lockbox_date_alpha       :=SUBSTR(inline,24,6);
                 l_lockbox_creation_date    :=to_date(l_lockbox_date_alpha,'YYMMDD');
                 l_rec_cnt                  := l_rec_cnt + 1;
                 l_trans_header_rec_type    :=SUBSTR(inline,1,1);
                 l_trans_header_priority    :=SUBSTR(inline,2,2);
                 l_trans_header_destination :=SUBSTR(inline,4,10);
                 l_trans_header_origin      :=SUBSTR(inline,14,10);
                 l_trans_header_date_alpha  :=SUBSTR(inline,24,6);
                 l_trans_header_date        :=to_date(l_trans_header_date_alpha,'YYMMDD');
                 l_trans_header_time        :=SUBSTR(inline,30,4);
                 --CH3438 ----------------------------------------------------------
                 -- Identify the bank for Batch Header
                 v_lockbox_bank   :=pkg_lockbox.get_lockbox_bank_id(l_lockbox_name);
               ---- Record Type 5 -----
               ELSIF l_rec_ind = '5' THEN
                 --dbms_output.put_line(inline);
                 l_rec_cnt                := l_rec_cnt + 1;
                 l_lockbox_batch_num      :=SUBSTR(inline,2,3); -- batch number -- hold this to compare rec_ind 6s to
                 l_lockbox_batch_item_num :=SUBSTR(inline,5,3); -- batch item number
                 v_batch_id               :=NULL;
                 pkg_lockbox.assign_lkbx_batch(v_sales_year,v_batch_base,v_batch_id,v_batch_description,v_created_by);
                 --CH3438 ----------------------------------------------------------
                 -- This is to be added for change of Banks. Identify Banks as Wells Fargo or Northern Trust,
                 -- might also be sending files for awhile.
                 v_batch_description := v_lockbox_bank||'-'||v_batch_description||' '||l_lockbox_batch_num||l_lockbox_batch_item_num;
                 if l_lockbox_batch_num = '900' then
                    v_is_ach := 'Y';
                 else
                    v_is_ach := 'N';
                 end if;
                 if l_lockbox_batch_num = '800' then
                   l_batch_header_date_alpha  :=SUBSTR(inline,15,6);
                   l_batch_header_date        :=to_date(l_batch_header_date_alpha,'YYMMDD');
                   v_payment_type :='Wire Transfer';
                   v_batch_description := v_batch_description||'-'||v_payment_type_w;
                 else
                   v_payment_type :='Check';
                   l_batch_header_date_alpha  :=l_trans_header_date_alpha;
                   l_batch_header_date        :=l_trans_header_date;
                   v_batch_description := v_batch_description||'-'||v_payment_type_c; 
                 end if;
                 if v_is_ach ='N' then
                   pkg_lockbox.insert_lkbx_ar_batch(v_sales_year, v_batch_id, v_batch_type, v_batch_description,
                                                    l_batch_header_date,   --l_lockbox_creation_date,
                                                    v_created_by, v_status);
                   v_batch_hdr_cnt            :=v_batch_hdr_cnt + 1;
                   l_email_batch_id           :=substr(v_batch_ID,1,11);
                   l_batch_header_rec_type    :=SUBSTR(inline,1,1);
                   l_batch_header_batch_no    :=SUBSTR(inline,2,3);
                   l_batch_header_item_no     :=SUBSTR(inline,5,3);
                   l_batch_header_lockbox_no  :=SUBSTR(inline,8,7);
                   l_batch_header_date_alpha  :=SUBSTR(inline,15,6);
                   l_batch_header_date        :=to_date(l_batch_header_date_alpha,'YYMMDD');
                   l_batch_header_destination :=SUBSTR(inline,21,10);
                   l_batch_header_origin      :=SUBSTR(inline,31,10);
                 end if;
               ----- Record Type 6 -----
               ELSIF l_rec_ind = '6' THEN
                 if v_is_ach ='N' then
                   v_sequence_no := 0;
                   l_type4_rec_no := 0;
                   l_batch_detail_rec_type       :=SUBSTR(inline,1,1);
                   l_batch_detail_batch_no       :=SUBSTR(inline,2,3);
                   l_batch_detail_item_no        :=SUBSTR(inline,5,3);
                   l_batch_detail_amount_alpha   :=SUBSTR(inline,8,10);
                   l_batch_detail_amount         :=to_number(l_batch_detail_amount_alpha)*.01;
                   l_batch_detail_route_no_lkbx  :=SUBSTR(inline,18,9);
                   l_batch_detail_account_number :=SUBSTR(inline,27,10);
                   l_batch_detail_check_no       :=rtrim(SUBSTR(inline,37,9));
                   l_batch_detail_trp_ind        :=SUBSTR(inline,46,1);
                   l_batch_detail_chk_date_a     :=SUBSTR(inline,47,6);
                   IF l_batch_detail_chk_date_a = '      ' THEN
                     l_batch_detail_chk_date_a :=l_batch_header_date_alpha;
                   END IF;
                   l_batch_detail_chk_date :=to_date(l_batch_detail_chk_date_a,'YYMMDD');
                   l_batch_detail_name     :=SUBSTR(inline,53);
                   v_hld_six_batch_num     :=l_batch_detail_batch_no;
                   v_hld_six_item_num      :=l_batch_detail_item_no;
                   l_lockbox_creation_date :=to_date(l_batch_header_date_alpha,'YYMMDD');
                   --- check trip/harvest plan indicator ----
                   v_lkbx_hp_trip_ind   :=NULL;
                   v_lkbx_except_reason :=NULL;
                   pkg_lockbox.check_trip_hp_ind(l_batch_detail_trp_ind,v_lkbx_hp_trip_ind,v_lkbx_except_reason);
                 end if;
               ----- Record Type 4 -----
               ELSIF l_rec_ind = '4' THEN
                 if v_is_ach ='N' then
                   l_type4_rec_no := l_type4_rec_no + 1;
                   v_prev_yr_amt_apply        := 0;
                   v_curr_yr_amt_apply        := 0;
                   l_batch_detail_ovfl_rec_type   :=SUBSTR(inline,1,1);
                   l_batch_detail_ovfl_batch_no   :=SUBSTR(inline,2,3);
                   l_batch_detail_ovfl_item_no    :=SUBSTR(inline,5,3);
                   l_batch_detail_ovfl_rec_type_6 :=SUBSTR(inline,8,1);
                   l_batch_detail_ovfl_seq_no     :=SUBSTR(inline,9,2);
                   l_batch_detail_ovfl_rec_type_9 :=SUBSTR(inline,11,1);
                   l_batch_detail_ovfl_cust_no    :=NVL(rtrim(SUBSTR(inline,12,6),' '),NULL);
                   l_batch_detail_ovfl_order_no   :=rtrim(SUBSTR(inline,18,8),' ');
                   l_batch_detail_ovfl_name       :=nvl(rtrim(SUBSTR(inline,26),' '),v_no_name);
                   IF l_batch_detail_ovfl_cust_no IS NULL THEN
                     l_batch_detail_ovfl_cust_no := NULL;
                     v_billable_account_num      :=NULL;
                     l_lkbx_dealer_num           :=NULL;
                     v_comment_ind               := 1;
                     l_lkbx_comments             :='No Customer Account# for '||l_batch_detail_ovfl_name||' in LockBox file.';
                     l_lkbx_header_acct_num      :=v_billable_account_num;
                     l_lkbx_issues               :=l_lkbx_issues + 1;                    
                   ELSIF IS_NUMERIC(l_batch_detail_ovfl_cust_no) = 'FALSE' OR pkg_account.get_billable_account(l_batch_detail_ovfl_cust_no) IS NULL
                     THEN
                       l_batch_detail_ovfl_cust_no := NULL;
                       v_billable_account_num      :=NULL;
                       l_lkbx_dealer_num           :=NULL;
                       v_comment_ind               := 1;
                       l_lkbx_comments             :='Customer Account# for '||l_batch_detail_ovfl_name||' not found.';
                       l_lkbx_header_acct_num      :=v_billable_account_num;
                       l_lkbx_issues               :=l_lkbx_issues + 1;
                   ELSE
                     v_billable_account_num := pkg_account.get_billable_account(v_sales_year,l_batch_detail_ovfl_cust_no,v_lkbx_hp_trip_ind);
                     l_lkbx_dealer_num      :=pkg_lockbox.get_lkbx_dealer_num(l_batch_detail_ovfl_cust_no);
                     v_acct_status          :=pkg_lockbox.get_account_status(l_batch_detail_ovfl_cust_no);
                     IF v_acct_status       IS NULL THEN
                       l_lkbx_comments     :=NULL;
                     ELSE
                       l_lkbx_comments :=(l_lkbx_comments||''||'Customer Account# '||l_batch_detail_ovfl_cust_no||' NOT ACTIVE.');
                       l_lkbx_issues   :=l_lkbx_issues + 1;
                     END IF;
                     l_lkbx_header_acct_num :=v_billable_account_num;
                   END IF;
                   v_is_harv_plan                := 'N';
                   IF v_lkbx_hp_trip_ind          = 'Y' THEN
                     v_is_harv_plan             :=pkg_lockbox.get_harvest_plan_status(v_sales_year,v_billable_account_num);
                     IF NVL(v_is_harv_plan,'N') <> 'Y' THEN
                       v_is_harv_plan          :=pkg_lockbox.get_harvest_plan_status(v_prev_sales_year,v_billable_account_num);
                     END IF;
                     IF NVL(v_is_harv_plan,'N') <> 'Y' THEN
                       l_lkbx_comments    :=('Customer Account# '||v_billable_account_num||' not a Harvest Plan account');
                       l_lkbx_issues      :=l_lkbx_issues + 1;
                       v_lkbx_hp_trip_ind := 'N';
                     END IF;
                   END IF;
                   v_previous_yr_balance :=pkg_lockbox.does_previous_bal_exists(v_sales_year,v_billable_account_num,v_is_harv_plan);
                   v_prev_yr_bal_amt     :=pkg_lockbox.get_prev_yr_bal_amt(v_prev_sales_year,v_billable_account_num,v_is_harv_plan);
                   v_curr_yr_bal_amt     :=pkg_lockbox.get_curr_yr_bal_amt(v_sales_year,l_batch_detail_ovfl_cust_no);
                   v_prev_yr_amt_apply   :=0;
                   v_curr_yr_amt_apply   :=0;
                   v_is_split_yrs        :='N';
                   pkg_lockbox.yr_amt_to_apply(v_sales_year, v_billable_account_num, v_is_harv_plan, l_batch_detail_amount,
                                               v_prev_yr_bal_amt, v_curr_yr_bal_amt, v_prev_sales_year, v_sales_year,
                                               v_prev_yr_amt_apply, v_curr_yr_amt_apply, v_is_split_yrs);
                   IF v_prev_yr_amt_apply > 0 THEN
                     l_lkbx_comments    :=('Customer Account# '||l_batch_detail_ovfl_cust_no||' has a Previous Yr Balance.');
                   ELSE
                     If l_lkbx_comments IS NULL Then
                       l_lkbx_comments :=NULL;
                     End If;  
                   END IF;
                   IF l_batch_detail_trp_ind = 'T' THEN
                     v_discount_percent   :=0;
                     v_discount_amount    :=0;
                   ELSE
                     v_discount_percent   :=0;
                     v_discount_percent    :=pkg_pricing.get_discount_percent(v_sales_year,v_billable_account_num,v_payment_type ,trunc(sysdate));
                     v_discount_amount    :=0;
                     v_discount_amount    :=pkg_lockbox.calc_discount(l_batch_detail_amount,v_discount_percent);
                     v_lkbx_except_reason :=NULL;
                   END IF;
                   IF l_batch_detail_ovfl_order_no IS NULL THEN
                     v_order_num                  :=NULL;
                   ELSE
                     v_order_num :=to_number(l_batch_detail_ovfl_order_no);
                   END IF;
                   v_lkbx_dealer_num :=l_lkbx_dealer_num;
                   if l_batch_detail_trp_ind = 'H' THEN
                     v_lkbx_hp_trip_ind := 'Y';
                   else
                     v_lkbx_hp_trip_ind := v_lkbx_hp_trip_ind;  
                   end if;
                   ----- write header and detail -----
                   ----- insert row into AR_PAYMENT_HEADER -----
                   IF v_sequence_no     = 0 THEN
                     v_ar_payment_num :=get_next.ar_payment_num(v_sales_year);
                     IF l_batch_detail_ovfl_name = v_no_name
                       and l_batch_detail_ovfl_cust_no is not null THEN
                         l_lkbx_comments := v_no_name||v_acct_msg;
                     ELSIF l_batch_detail_ovfl_name = v_no_name
                       and l_batch_detail_ovfl_cust_no is null THEN 
                         l_lkbx_comments := 'No Account # or Name on detail record for '||l_batch_detail_name;
                         --l_lkbx_comments := v_no_name;
                     END IF; 
                     pkg_lockbox.insert_ar_payment_header(v_sales_year, v_ar_payment_num, v_batch_id, v_payment_class, l_batch_detail_ovfl_cust_no,
                                                          v_payment_type, l_batch_detail_check_no, l_batch_detail_amount, TRUNC(sysdate),
                                                          v_created_by, v_status, l_batch_detail_chk_date, l_lkbx_comments);
                   END IF;
                   IF v_curr_yr_amt_apply <> 0 OR (v_curr_yr_amt_apply = 0 AND v_prev_yr_amt_apply = 0) THEN
                     v_sequence_no       := v_sequence_no + 1;
                     v_name_use          :=null;
                     if l_type4_rec_no > 1 then
                       v_curr_yr_amt_apply := 0;
                       v_discount_amount := null;
                     end if;
                     if l_batch_detail_ovfl_name = v_no_name
                       and l_batch_detail_ovfl_cust_no is not null then
                         begin
                           v_name_use := null;
                           select contact_name_lf
                             into v_name_use
                             from v_per_contact_info
                            where contact_num = l_batch_detail_ovfl_cust_no
                              and contact_type = 'Primary';
                         end;    
                     else
                       v_name_use :=l_batch_detail_ovfl_name;
                     end if;
                     pkg_lockbox.insert_ar_payment_detail(v_sales_year, v_ar_payment_num, v_sequence_no, v_sales_year,
                                                          l_batch_detail_ovfl_cust_no, v_curr_yr_amt_apply, v_name_use,
                                                          v_lkbx_hp_trip_ind, v_lkbx_except_reason, v_billable_account_num,
                                                          v_discount_percent, v_discount_amount, v_order_num);
                   END IF;
                   IF v_prev_yr_amt_apply <> 0 THEN
                     v_sequence_no       := v_sequence_no + 1;
                     v_name_use          :=null;
                     if l_type4_rec_no > 1 then
                       v_prev_yr_amt_apply := 0;
                       v_discount_amount := null;
                     end if;  
                     if l_batch_detail_ovfl_name = v_no_name
                       and l_batch_detail_ovfl_cust_no is not null then
                         begin
                           v_name_use := null;
                           select contact_name_lf
                             into v_name_use
                             from v_per_contact_info
                            where contact_num = l_batch_detail_ovfl_cust_no
                              and contact_type = 'Primary';
                         end;
                     else
                       v_name_use :=l_batch_detail_ovfl_name;
                     end if;
                     pkg_lockbox.insert_ar_payment_detail(v_sales_year, v_ar_payment_num, v_sequence_no, v_prev_sales_year,
                                                          l_batch_detail_ovfl_cust_no, v_prev_yr_amt_apply, v_name_use,
                                                          v_lkbx_hp_trip_ind, NULL, v_billable_account_num,0, 0, v_order_num);
                   END IF;
                 end if;
               ----- Record Type 7 -----
               ELSIF l_rec_ind = '7' THEN
                 NULL;
               ----- Record Type 8 -----
               ELSIF l_rec_ind = '8' THEN
                 NULL;
               ----- Record Type 9 -----
               ELSIF l_rec_ind = '9' THEN
                 v_proc := v_proc + 1;
                 --dbms_output.put_line('Last Record in File '||tmpname);
                 utl_file.fclose(tmpfile1);
                 v_newfile_name :='xloaded_'||tmpname;
                 --dbms_output.put_line('New File Name is '||v_newfile_name);   
                 utl_file.frename (v_directory_name,tmpname,v_directory_name,v_newfile_name,FALSE);
                 if v_proc < unproc_files then
                   goto next_file;
                 else
                   --dbms_output.put_line('HERE'); 
                   exit;
                 end if;
               END IF;
               <<next_file>>
               null;
             END LOOP;
             BEGIN
               l_sender       := pkg_ctl.get_value_str('Standard Email from');
               l_email        := pkg_ctl.get_value_str('Auto Lkbx Notify');
               l_email_cc     := pkg_ctl.get_value_str('Auto Lkbx Notify cc');
               l_email        := l_email ||';'||l_email_cc;
               l_email_bcc    := pkg_ctl.get_value_str('Auto Lkbx Notify bcc');
               if v_lockbox_bank = 'NT' then
                 v_line1        :=NULL;
                 v_line2        :=NULL;
                 v_line1        :='Lockbox file '||tmpname||' for Northern Trust was loaded into '||TO_CHAR(v_batch_hdr_cnt)||' batches,';
                 v_line2        :='There are '||l_lkbx_issues||' issues in this file.';
                 l_subject      :='Automated Lockbox Import -- Northern Trust ';
                 --v_msg_lines    :=v_line1||chr(13)||chr(10)||v_line2||chr(13)||chr(10);
                 v_msg_lines    :=v_line1||l_crlf||v_line2||l_crlf;
                 --l_lkbx_message :=l_lkbx_message|| chr(13) || chr(10)||v_msg_lines|| chr(13) || chr(10);
                 l_lkbx_message :=l_lkbx_message||l_crlf||v_msg_lines||l_crlf;
                 --l_message      :=l_lkbx_message|| chr(13) || chr(10);
                 l_message      :=l_lkbx_message||l_crlf;
                 --l_lkbx_message2:=l_message|| chr(13) || chr(10);
                 l_lkbx_message2:=l_crlf||l_message;
                 --pkg_mail.send_email_no_attach(l_sender,l_email,l_email_bcc,l_subject,l_message,' ');
               elsif v_lockbox_bank = 'WF' then
                 v_line1        :=NULL;
                 v_line2        :=NULL;
                 v_line1        :=chr(10)||'Lockbox file '||tmpname||' for Wells Fargo was loaded into '||TO_CHAR(v_batch_hdr_cnt)||' batches,';
                 v_line2        :='There are '||l_lkbx_issues||' issues in this file.';
                 l_subject      :='Automated Lockbox Import -- Wells Fargo ';
                 --v_msg_lines    :=v_line1||chr(13)||chr(10)||v_line2||chr(13)||chr(10);
                 v_msg_lines    :=v_line1||l_crlf||v_line2||l_crlf;
                 --l_lkbx_message :=l_lkbx_message|| chr(13) || chr(10)||v_msg_lines|| chr(13) || chr(10);
                 l_lkbx_message :=l_lkbx_message||l_crlf||v_msg_lines||l_crlf;
                 --l_message      :=l_lkbx_message|| chr(13) || chr(10);
                 l_message      :=l_lkbx_message||l_crlf;
                 --l_lkbx_message2:=l_message|| chr(13) || chr(10);
                 l_lkbx_message2:=l_crlf||l_message;
                 --pkg_mail.send_email_no_attach(l_sender,l_email,l_email_bcc,l_subject,l_message,' ');
               elsif v_lockbox_bank = 'XX' then 
                 v_line1        :=NULL;
                 v_line2        :=NULL;
                 v_line1        :=chr(10)||'Lockbox file '||tmpname||' for an Unidentified Bank was loaded into '||TO_CHAR(v_batch_hdr_cnt)||' batches,';
                 v_line2        :='There are '||l_lkbx_issues||' issues in this file.';
                 l_subject      :='Automated Lockbox Import -- Unidentified Bank ';
                 --v_msg_lines    :=v_line1||chr(13)||chr(10)||v_line2||chr(13)||chr(10);
                 v_msg_lines    :=v_line1||l_crlf||v_line2||l_crlf;
                 --l_lkbx_message :=l_lkbx_message|| chr(13) || chr(10)||v_msg_lines|| chr(13) || chr(10);
                 l_lkbx_message :=l_lkbx_message||l_crlf||v_msg_lines||l_crlf;
                 --l_message      :=l_lkbx_message|| chr(13) || chr(10);
                 l_message      :=l_lkbx_message||l_crlf;
                 --l_lkbx_message2:=l_message|| chr(13) || chr(10);
                 l_lkbx_message2:=l_crlf||l_message;
                 --pkg_mail.send_email_no_attach(l_sender,l_email,l_email_bcc,l_subject,l_message,' ');
               end if;
               v_batches_cnt := v_batches_cnt + v_batch_hdr_cnt;
               v_batch_hdr_cnt:=0;
               l_lkbx_issues :=0;
               v_msg_lines    :=null;
           END;
           END LOOP;
           BEGIN
             l_sender       := pkg_ctl.get_value_str('Standard Email from');
             l_email        := pkg_ctl.get_value_str('Auto Lkbx Notify');
             l_email_cc     := pkg_ctl.get_value_str('Auto Lkbx Notify cc');
             l_email        := l_email ||';'||l_email_cc;
             l_email_bcc    := pkg_ctl.get_value_str('Auto Lkbx Notify bcc');
             l_subject      :='Automated Lockbox Processing -- '||l_completed;
             l_message      :=l_lkbx_message2||'Batch_IDs start with ' ||l_email_batch_id;
             pkg_mail.send_email_no_attach(l_sender,l_email,l_email_bcc,l_subject,l_message,' ');
           END;
       EXCEPTION
         WHEN NO_DATA_FOUND THEN
           dbms_output.put_line('No more files');       
       END;
     end if;
   END;
END load_lockbox_file;

You are right its an old code
Huh? How could I be right about something that I never even said?
, but I wish I could rewrite the whole logic.
I was asked to fix the issue.
Yes - and to fix the issue you are going to have to REWRITE THE WHOLE LOGIC.
That logic being used has some serious flaws and it makes NO SENSE to try to fix them piecemeal.
The file name is getting renamed in this part of the code
               ELSIF l_rec_ind = '9' THEN
                 utl_file.fclose(tmpfile1);
                 utl_file.frename (v_directory_name,tmpname,v_directory_name,v_newfile_name,FALSE);
EXACTLY! And that is the reason for your problem.
The file is ONLY being closed and renamed in the section for record type '9'. So if the code blows up and never gets to that section the file will NEVER be renamed.
That is just ONE indication that the code needs to be refactored to be more modular. Other indications are code like this:
ELSIF l_rec_ind = '4' THEN
                 if v_is_ach ='N' then
There are numerous places in the code where you have IF clauses but no ELSE clause to show what, if anything should be done when the IF condition is not met.
In that example above what is supposed to happen if 'v_is_ach' is NOT an uppercase 'N'? How would any developer even know what is supposed to happen? That code says it is OK to have a record type 4 that is a 'Y' for ACH. But then you just ignore that record and don't do anything with it.
I've done ACH processing before for a major bank (likely the same one you are dealing with) and that type of record processing doesn't make any sense to me. For the work I did have a type 4 record and no code to process it or report it as an error/exception would be a SERIOUS audit (and potential LIABILITY) issue.
At a minimum you should create an object type that wraps the record-related data together so it is easier to identify and manage. The code already identifies the main candidates:
   -- Transmission Header - record type 1
   l_trans_header_rec_type    VARCHAR2(1);
   -- Batch Header -- record type 5
   l_batch_header_rec_type    VARCHAR2(1);
   -- Detail Record -- record type 6
   l_batch_detail_rec_type       VARCHAR2(1);
   -- Overflow record -- record type 4
   l_batch_detail_ovfl_rec_type   VARCHAR2(1);
Each of those should be converted to a user-defined type with the required structure. Then the other code should create and populate instances of those types.
That could be EASILY done. It took me less than two minutes to create an example type from your code:
create or replace type lockbox_trans_header as object (
-- Transmission Header - record type 1
   l_trans_header_rec_type    VARCHAR2(1),
   l_trans_header_priority    VARCHAR2(2),  -- Priority
   l_trans_header_destination VARCHAR2(10), -- Company's account number at sending bank
   l_trans_header_origin      VARCHAR2(10), -- Sending bank's FR/ABA Number
   l_trans_header_date_alpha  VARCHAR2(6),  -- Transmission date (YYMMDD) -- alpha
   l_trans_header_date        DATE,         -- Transmission date (YYMMDD) -- Oracle date format
   l_trans_header_time        VARCHAR2(4),  -- Time -- NOT USED
   l_trans_header_filler      VARCHAR2(47) -- Filler - Blank
The types can be created as SQL types or put into a package spec. That would remove a LOT of the clutter in the current code.
Your code also makes reference to other record types that are not handled by the code:
   l_record_type VARCHAR2(1); -- record type indentifier (1 -- Transmission Header
   --                          5 -- Batch Header
   --                          6 -- Detail Record
   --                          4 -- Overflow record -- detail
   --                          7 -- Batch Total
   --                          8 -- Trailer
   --                          9 -- Trailer
Either ALL of those types need to be handled in the code or you need to add comments saying WHY some of them are NOT handled.
The code DOES include junk like this:
              ----- Record Type 7 -----
               ELSIF l_rec_ind = '7' THEN
                 NULL;
               ----- Record Type 8 -----
               ELSIF l_rec_ind = '8' THEN
                 NULL;
I consider that JUNK because there is no EXPLICIT mention as to why you are NOT doing anything if there is actually data for those record types. And there is nothing said about whether those record types are REQUIRED to be in the file (but then ignored) or whether they are optional.
The BEST thing you could do for this code is:
1. add comments that explicitly identify the business rules that the code implements
2. refactor the code to be more modular - use custom types that correspond to the record types expected in the files that are processed
3. ensure that ALL conditional statements either DO SOMETHING or SAY SOMETHING - that is, that there is an ELSE for every IF, etc.
4. add appropriate EXCEPTION handlers that either LOG or actually handle exceptions.
The missing item #4 above is your current problem. There is no exception handler that ensures that a file gets closed and/or renamed if there is a problem. And you never answered my question about why you would want to PRETEND that a file had been processed by renaming it when it actually blew up in the middle of being processed.
The WORST thing you could do with this code is make a cosmetic change to simply fix the one thing you are currently experiencing.
A good code reviewer and tester could break that code you posted in several ways very easily. It is poorly written and incomplete. It needs to be rewritten.

Similar Messages

  • Unable to capture the parameter values from a PL/SQL procedure

    hi.
    i'm trying to capture the parameter values of a PL/SQL procedure by calling inside a anonymous block but i'm getting a "reference to uninitialized collection error" ORA-06531.
    Please help me regarding.
    i'm using following block for calling the procedure.
    declare
    err_cd varchar2(1000);
    err_txt VARCHAR2(5000);
    no_of_recs number;
    out_sign_tab search_sign_tab_type:=search_sign_tab_type(search_sign_type(NULL,NULL,NULL,NULL,NULL));
    cntr_var number:=0;
    begin
         rt843pq('DWS','3000552485',out_sign_tab,no_of_recs,err_cd,err_txt);
         dbms_output.put_line('The error is ' ||err_cd);
         dbms_output.put_line('The error is ' ||err_txt);
         dbms_output.put_line('The cntr is ' ||cntr_var);
         for incr in 1 .. OUT_SIGN_TAB.count
         loop
         cntr_var := cntr_var + 1 ;
    Dbms_output.put_line(OUT_SIGN_TAB(incr).ref_no||','||OUT_SIGN_TAB(incr).ciref_no||','||OUT_SIGN_TAB(incr).ac_no||','||OUT_SIGN_TAB(incr).txn_type||','||OUT_SIGN_TAB(incr).objid);
    end loop;
    end;
    Error is thrown on "for incr in 1 .. OUT_SIGN_TAB.count" this line
    Following is some related information.
    the 3rd parameter of the procedure is a out parameter. it is a type of a PL/SQL table (SEARCH_SIGN_TAB_TYPE) which is available in database as follows.
    TYPE "SEARCH_SIGN_TAB_TYPE" IS TABLE OF SEARCH_SIGN_TYPE
    TYPE "SEARCH_SIGN_TYPE" AS OBJECT
    (ref_no VARCHAR2(22),
    ciref_no VARCHAR2(352),
    ac_no VARCHAR2(22),
    txn_type VARCHAR2(301),
    objid VARCHAR2(1024))............

    We don't have your rt843pq procedure, but when commenting that line out, everything works:
    SQL> create TYPE "SEARCH_SIGN_TYPE" AS OBJECT
      2  (ref_no VARCHAR2(22),
      3  ciref_no VARCHAR2(352),
      4  ac_no VARCHAR2(22),
      5  txn_type VARCHAR2(301),
      6  objid VARCHAR2(1024))
      7  /
    Type is aangemaakt.
    SQL> create type "SEARCH_SIGN_TAB_TYPE" IS TABLE OF SEARCH_SIGN_TYPE
      2  /
    Type is aangemaakt.
    SQL> declare
      2    err_cd varchar2(1000);
      3    err_txt VARCHAR2(5000);
      4    no_of_recs number;
      5    out_sign_tab search_sign_tab_type:=search_sign_tab_type(search_sign_type(NULL,NULL,NULL,NULL,NULL));
      6    cntr_var number:=0;
      7  begin
      8    -- rt843pq('DWS','3000552485',out_sign_tab,no_of_recs,err_cd,err_txt);
      9    dbms_output.put_line('The error is ' ||err_cd);
    10    dbms_output.put_line('The error is ' ||err_txt);
    11    dbms_output.put_line('The cntr is ' ||cntr_var);
    12    for incr in 1 .. OUT_SIGN_TAB.count
    13    loop
    14      cntr_var := cntr_var + 1 ;
    15      Dbms_output.put_line(OUT_SIGN_TAB(incr).ref_no||','||OUT_SIGN_TAB(incr).ciref_no||','||OUT_SIGN_TAB(incr).ac_no||','||OUT_SIGN
    TAB(incr).txntype||','||OUT_SIGN_TAB(incr).objid);
    16    end loop;
    17  end;
    18  /
    The error is
    The error is
    The cntr is 0
    PL/SQL-procedure is geslaagd.Regards,
    Rob.

  • How to call a PL/SQL procedure from a Java class?

    Hi,
    I am new to the E-BusinessSuite and I want to develop a Portal with Java Portlets which display and write data from some E-Business databases (e.g. Customer Relationship Management or Human Resource). These data have been defined in the TCA (Trading Community Architecture) data model. I can access this data with PL/SQL API's. The next problem is how to get the data in the Java class. So, how do you call a PL/SQL procedure from a Java program?
    Can anyone let me know how to solve that problem?
    Thanks in advance,
    Chang Si Chou

    Have a look at this example:
    final ApplicationModule am = panelBinding.getApplicationModule();
    try
         final CallableStatement stmt = ((DBTransaction)am.getTransaction()).
                                                                                         createCallableStatement("{? = call some_pck.some_function(?, ?)}", 10);
         stmt.registerOutParameter(1, OracleTypes.VARCHAR);
         stmt.setInt(2, ((oracle.jbo.domain.Number)key.getAttribute(0)).intValue());
         stmt.setString(3, "Test");
         stmt.execute();
         stmt.close();
         return stmt.getString(1);
    catch (Exception ex)
         panelBinding.reportException(ex);
         return null;
    }Hope This Helps

  • How to call a PL/SQL procedure from a xml Data Template

    We have a requirement in which we need to call a pl/sql package.(dot)procedure from a Data Template of XML Publisher.
    we have registered a Data Template & a RTF Template in the XML Publisher Responsibility in the Oracle 11.5.10 instance(Front End).
    In the Data Query part of the Data Template , we have to get the data from a Custom View.
    This view needs to be populated by a PL/SQL procedure.And this procedure needs to be called from this Data Template only.
    Can anybody suggest the solution.
    Thanks,
    Sachin

    Call the procecure in the After Parameter Form trigger, which can be scripted in the Data Template.
    BTW, there is a specialized XML Publisher forum:
    BI Publisher

  • How to call a PL/SQL procedure from Portal

    Env.Info: Windows NT Server 4 (Service Pack 3) / Oracle 8i R3 EE / Oracle Portal 3.0 Production.
    I created a new schema "BISAPPS" and created a user with the same name. Ran provsyns.sql script to grant Portal API access. Created a new package under this new schema and compiled it against the database. After that I registered the schema as a portal provider. There were no errors.
    Now I logged into Portal using the account PORTAL30. Refreshed the portlet repository and the new portlets appeared. I added the new portlet to the page. It is displayed successfully.
    New portlet allows the user to enter a bug-number and lets the user to either view or edit. If the user clicks on the button "Edit", it opens a new window and displays the contents from BugDB application. But if the user clicks on "Show", it should display the output generated by a PL/SQL procedure (Owned by the above New Schema - BISAPPS) in a separate window. But instead it is displaying the following error in the separate window:
    bisapps_pkg.buginfo: PROCEDURE DOESN'T EXIST.
    DAD name: PORTAL30
    PROCEDURE : bisapps_pkg.buginfo
    URL : http://host_name:80/pls/portal30/bisapps_pkg.buginfo
    And list of environment variables ....
    Can anyone help me? How can I call a PL/SQL procedure when the button is clicked? Thanks in advance.

    You must grant EXECUTE privilege on your procedure to the PORTAL30_PUBLIC user. If the error still persists, create a PUBLIC synonym for your procedure.

  • How to send a java array to a pl/sql procedure

    Hi,
    This is similar to a post about 6 months ago on retrieving pl/sql tables from a java application but I can't seem to figure out how to use what I learned there to solve this.
    In a java application I have a Long[] array, and in the database I have a pl/sql procedure which takes a numeric in parameter. I currently loop through the array in my java application and call the procedure multiple times. What I'd prefer to do is to be able to pass the entire array to a new procedure which performs the looping internally.
    John
    null

    Kathy,
    Search the archives of this forum and the JDBC forum for the terms STRUCT and ARRAY and you can find some sample code on the JDBC How-To Documents page and the JDBC Samples which can both be accessed from this page:
    http://www.oracle.com/technology/tech/java/sqlj_jdbc/index.html
    Good Luck,
    Avi.

  • How to get data from URL in a PL/SQL procedure

    Hi!<br>
    <br>
    I want to pass values in APEX from a report with a link to a PL/SQL procedure through URL.
    How can I make this?<br>
    <br>
    For example:<br>
    <br>
    I have a report:<br>
    <br>
    select<br>
       id,<br>
       name,<br>
       akt,<br>
       case<br>
          when akt is NULL then '< a href="f?p=&APP_ID.:27:&SESSION.:START_PROCESS" name="test_link" >set< /a >'<br>
       end choice<br>
    from<br>
       USERS;<br>
    <br>
    I want to pass the value "id" in the link ( named "test_link" ) . And want to use this value in a process like this:<br>
    <br>
    DECLARE<br>
       v_user_id NUMBER(10);<br>
    BEGIN<br>
       --I want to read this value from the url<br>
       if :REQUEST='START_PROCESS' then<br>
          v_user_id := ????;<br>
          <br>
          ...<br>
       end if;<br>
    END;<br>
    <br>
    <br>
    Thanks!<br>
    Marton

    Hi,
    1- Create a hidden item P27_USER_ID on page 27
    2- Change your code :
    SELECT ID, NAME, akt,
           CASE
              WHEN akt IS NULL
                 THEN    '< a href="f?p=&APP_ID.:27:&SESSION.:START_PROCESS:NO::P27_USER_ID:'
                      || ID
                      || '" name="test_link" >set< /a >'
           -- refer to f?p=App:Page:Session:Request:Debug:ClearCache:itemNames:itemValues:PrinterFriendly
           END choice
      FROM users;
       And then
    DECLARE
       v_user_id   NUMBER (10);
    BEGIN
       --I want to read this value from the url
       IF :request = 'START_PROCESS'
       THEN
          v_user_id := :p27_user_id;
           --your code
       END IF;
    END;Hope this helps,
    Grégory

  • How to secure a PL/SQL procedure that is called from the web browser

    If you have ever seen the sample document management application, and tried to download a file that was stored in the system, you are probably familiar with the apex_util.count_click URL that is used to download the file. If you copy that URL and paste it into a new browser, you will not be prompted to login to download the requested file. I'm using SSO with Apex as a partner application. How can I secure a pl/sql procedure like this to redirect to the login page before beginning the download?
    Thanks,
    Kris

    You can use the second method described here:
    http://apex.oracle.com/pls/otn/f?p=31517:15
    You would use an application process instead of pasting the procedure call in the browser. In the case I describe, you don't need to grant execute to public on the download procedure.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Error when try to call a pl/sql procedure from the .xsql file

    I tried to call a pl/sql procedure like this:
    <?xml version="1.0"?>
    <page connection="omtest5" xmlns:xsql="urn:oracle-xsql">
    <xsql:include-owa>
    sampleowaxml.testone
    </xsql:include-owa>
    </page>
    but I got the following error message:
    <?xml version="1.0" ?>
    - <page>
    - <xsql-error action="xsql:include-owa">
    <statement>declare buf htp.htbuf_arr; param_names owa.vc_arr; param_values owa.vc_arr; rows integer := 32767; outclob CLOB;begin param_names(1) := 'HTTP_COOKIE'; param_values(1) := ''; param_names(2) := 'SERVER_NAME'; param_values(2) := 'mxfang-nt.us.oracle.com'; param_names(3) := 'SERVER_PORT'; param_values(3) := '80'; param_names(4) := 'SCRIPT_NAME'; param_values(4) := '/servlets/oracle.xml.xsql.XSQLServlet'; param_names(5) := 'PATH_INFO'; param_values(5) := '/xsql/test/myproject.xsql'; param_names(6) := 'HTTP_USER_AGENT'; param_values(6) := 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)'; owa.init_cgi_env(6,param_names,param_values); sampleowaxml.testone owa.get_page(buf,rows); dbms_lob.createtemporary(outclob,true,dbms_lob.session); for i in 1..rows loop dbms_lob.writeappend(outclob,length(buf(i)),buf(i)); end loop; ? := outclob; ? := DBMS_LOB.INSTR(outclob,CHR(10)&#0124; &#0124;CHR(10));end;</statement>
    <message>ORA-06550: line 3, column 3: PLS-00103: Encountered the symbol "OWA" when expecting one of the following: := . ( @ % ; The symbol ":=" was substituted for "OWA" to continue.</message>
    </xsql-error>
    - <xsql-error action="xsql:include-owa">
    <message />
    </xsql-error>
    </page>
    This error message is very similiar to the message that Shanthir posted on Jan, 21. I did run the dbmslob.sql, but it doesn't help. Anybody has ideas how to solve it?
    I used the PL/SQL web toolkit provided by OAS4.0.8.1. I believe oracle web agent is replaced by this toolkit.
    Thanks,
    Min
    null

    Hi,
    Glad that somebody else too got this problem. Well, as I had mentioned in my previous posting too, I think there are some procedures in the package, dbms_lob, like the writeappend, createtemporary etc.. which is not found in my dbms_lob.sql file, I am using 8.0.5, but I found these procedures in the 8i, I think it is becos of that.
    By the way if anybody got this solution and got any workaround, please help me too.
    I am still waiting for the solution to that.
    Shanthi

  • How to pass multiple parameters while calling a pl/sql procedure based serv

    Hi,
    I have a pl/sql procedure based service that needs to be invoked from the bpel console for testing purpose. This procedure accepts multiple input values which are of varchar2,boolean and datetime data types. How can I get the bpel console to throw a UI where I can enter these values --in other words where(which file and where) can I specify that these are the input parameters that need to be entered along with their types.
    Thanks for yr help!

    Change the payload of the request 'Process WSDL' message type. Change the element of the payload for the RequestMessage to be 'InputParameters' from the XSD generated by the DB Adapter wizard.
    Edit the payload (Element) - Choose 'Project Schema Files'. Select 'InputParameters' from the XSD.
    You can also change the ResponseMessage by doing the same thing, except that you select 'OutputParameters' from the XSD.

  • Obtaining HTML page by issuing a call from a PL/SQL procedure

    Is there any possibility to obtain HTMLDB -> HTML page from a user defined PL/SQL procedure ?
    For example I build an procedure which calls directly
    flows_010500.wwv_flow.show(null,p_flow_step_id=>'2',p_flow_id=>'104')
    and i try to read the result from htp.showpage, but I get a html response page with a security error.
    Maybe is necessary to initialize other parameters?
    Any help?

    Scott, I have got two pages in an application one is login page the other is welcome page. my login page will be process by store proceduer to validate the user based on users table that I have created on my schema. If the user login with username and password, if they exist on this table I will like to send them to welcome page. but I get http://htmldb.oracle.com/pls/otn/wwv_flow.accept.
    The page cannot be found
    The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
    Please try the following:
    If you typed the page address in the Address bar, make sure that it is spelled correctly.
    Open the htmldb.oracle.com home page, and then look for links to the information you want.
    Click the Back button to try another link.
    Click Search to look for information on the Internet.
    HTTP 404 - File not found
    Internet Explorer
    the procedure is below:
    CREATE OR REPLACE PROCEDURE obj_pls_login_chk(p_UserName IN varchar2
    ,p_Password IN varchar2
    ,Login IN varchar2 ) IS
    l_usr_id number;
    l_url varchar2(2000);
    BEGIN
    l_url := 'http://htmldb.oracle.com/pls/otn/f?';
    select user_id into l_usr_id
    from s_cdm_users
    where upper(username) = upper(p_UserName)
    and upper(Password) = upper(p_Password);
    if l_usr_id is not null then
    l_url := l_url||'p=29921:2:4413779570974471450';
    --wwv_flow.show(null,p_flow_step_id=>'29921',p_flow_id=>'29921:2');
    --htp.print(p_UserName);
    end if;
    EXCEPTION
    when others then
    return;
    END

  • Call an applications 'user exit' from a PL/SQL procedure

    My question is a technical PL/SQL question related to Oracle Applications. I need to call a standard applications 'user exit' from a stored PL/SQL procedure. Can anyone tell me if this is possible and how to do it?
    (i.e. I am attempting to call the AR user exit SALESTAX)
    Thanks,
    Michelle Dodge

    Hi,
    Read this thread, perhaps is there your response :
    Host...
    Nicolas.

  • Creating a CSV file from a pl/sql procedure

    Hi Everyone,
    I would like to know how to write a procedure in pl/sql where i need to check if they are any records in a table say "Table A".
    If they are any records in the "Table A" then we need to write those records in the "Table A" to the CSV file.
    If they are no records then we need to insert a record into the CSV file that "No records are found in "Table A".
    Could anybody please help ?
    Thanks in advance

    see this
    ops$tkyte@8i> create or replace procedure dump_table_to_csv( p_tname in varchar2,
    2 p_dir in varchar2,
    3 p_filename in varchar2 )
    4 is
    5 l_output utl_file.file_type;
    6 l_theCursor integer default dbms_sql.open_cursor;
    7 l_columnValue varchar2(4000);
    8 l_status integer;
    9 l_query varchar2(1000)
    10 default 'select * from ' || p_tname;
    11 l_colCnt number := 0;
    12 l_separator varchar2(1);
    13 l_descTbl dbms_sql.desc_tab;
    14 begin
    15 l_output := utl_file.fopen( p_dir, p_filename, 'w' );
    16 execute immediate 'alter session set nls_date_format=''dd-mon-yyyy hh24:mi:ss''
    17
    18 dbms_sql.parse( l_theCursor, l_query, dbms_sql.native );
    19 dbms_sql.describe_columns( l_theCursor, l_colCnt, l_descTbl );
    20
    21 for i in 1 .. l_colCnt loop
    22 utl_file.put( l_output, l_separator || '"' || l_descTbl(i).col_name || '"'
    23 dbms_sql.define_column( l_theCursor, i, l_columnValue, 4000 );
    24 l_separator := ',';
    25 end loop;
    26 utl_file.new_line( l_output );
    27
    28 l_status := dbms_sql.execute(l_theCursor);
    29
    30 while ( dbms_sql.fetch_rows(l_theCursor) > 0 ) loop
    31 l_separator := '';
    32 for i in 1 .. l_colCnt loop
    33 dbms_sql.column_value( l_theCursor, i, l_columnValue );
    34 utl_file.put( l_output, l_separator || l_columnValue );
    35 l_separator := ',';
    36 end loop;
    37 utl_file.new_line( l_output );
    38 end loop;
    39 dbms_sql.close_cursor(l_theCursor);
    40 utl_file.fclose( l_output );
    41
    42 execute immediate 'alter session set nls_date_format=''dd-MON-yy'' ';
    43 exception
    44 when others then
    45 execute immediate 'alter session set nls_date_format=''dd-MON-yy'' ';
    46 raise;
    47 end;
    48 /
    Procedure created.
    ops$tkyte@8i> exec dump_table_to_csv( 'emp', '/tmp', 'tkyte.emp' );
    PL/SQL procedure successfully completed.

  • Execute CDC mappings from a PL/SQL procedure

    Hi,
    I´m using OWB 11.2.0.2 for Linux. I´ve created some CDC mappings to update cubes with changes coming from other tables and cubes (from the tables that implement those cubes with the relational option). The issues are:
    - The CDC mappings run successfully from the OWB (Project Navigator - Start), but I cannot execute them from a procedure in PL/SQL with the following code:
    PROCEDURE "PROC_RUNCDCMAPPINGS" IS
    --inicializar variables aquí
    RetVal NUMBER;
    P_ENV WB_RT_MAPAUDIT.WB_RT_NAME_VALUES;
    -- ventana principal
    BEGIN
    RetVal:= BARIK.CDC_LOAD_CUBO_RECARGA.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_TOR.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_TOAE.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_VIAJES.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_TICKETINCIDENCIA.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_LIQMONEDERO.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBOS_LIQTEMPORALES.MAIN(P_ENV);
    COMMIT;
    END;
    It doesn´t report any error (the value for RetVal after execution is 0), but the cubes are not loaded with changes, and the changes stored in the J$_%tables are not consumed.
    Some of the options that may impact in the mappings are:
    - All the CDC are of Simple type
    - There are more than one subscriber to consume the changes, as for some tables, its changes must feed more than one CDC.
    - All the mappings include only one execution unit per mapping.
    - The integration/load template is the default: DEFAULT_ORACLE_TARGET_CT
    Other question is: As I explained, I need more than one subscriber because same updates must be consumed by different CDC mappings, to load different cubes, but I´ve not been able to assign the subscribers to only the tables associated with them, so all the subscribers are subscribed to all the changes in all the CDC tables, but as many of those subscribers never consume the changes of same tables, in the J$_% tables remains the not consumed records, and I haven´t found the way to purge those tables (other than the delete from J$_), nor to assign the tables with the subscribers (so the subscribers are only subscribed to their interested changes, that will be consumed, so the tables will be emptied after the consumption).
    Any help with these problems will be greatly appreciated.
    Tell me if more info is needed to clarify the situation.
    Best regards,
    Ana

    Hi David,
    Thank you for your reply.
    These mappings are the mappings needed to update the cubes with the changes detected by the CDC system, they are located under the Mapping Templates folder and I´m using code templates for the control of the loading and the integration (the DEFAULT_ORACLE_TARGET_CT) mapping.
    What I need is to execute these mappings within a PL/SQL procedure that will be invoked from different tools.
    I´ve done it for regular mappings (not CDC mappings), and it works. The code is the same as for the CDC ones:
    PROCEDURE "PROC_RUNLOADMAPPINGS" IS
    --inicializar variables aquí
    RetVal NUMBER;
    P_ENV WB_RT_MAPAUDIT.WB_RT_NAME_VALUES;
    -- ventana principal
    BEGIN
    RetVal:= BARIK.LOAD_CUBO_RECARGA.MAIN(P_ENV);
    RetVal:= BARIK.LOAD_CUBO_TOR.MAIN(P_ENV);
    RetVal:= BARIK.LOAD_CUBO_TOAE.MAIN(P_ENV);
    RetVal:= BARIK.LOAD_CUBO_VIAJES.MAIN(P_ENV);
    RetVal:= BARIK.LOAD_CUBO_TICKETINCIDENCIA.MAIN(P_ENV);
    COMMIT;
    END;
    -- End of PROC_RUNLOADMAPPINGS;
    ,and when I run it, the mappings are executed, but with the CDC ones it doesn´t (even when no error is reported).
    I know that they are deployed in the selected agent (in my case the Default_Agent), but when I start them from the OWB, the mapping packages are created in the DB schema, so, I thought that maybe I could invoke them....so what you tell me is that the only way to invoke them is from SQL*Plus? not from a regular PL/SQL procedure?
    Thank you very much,
    Ana

  • Basic Report Run from a PL/SQL Procedure

    I am hosed trying to start a BI Publisher report from a PL/SQL procedure. Basically, I have a procedure with a local variable defined as an XMLType. I need to call an RTF source, pass the xmlfile in and tell the RTF Engine where to send the output.
    The users guide implies that it involves calls to a Java program and I am totally ignorant of Java.
    I have successfully linked the RTF source into the XML_Publisher application and previewed it against a known data set. hat works.
    So, if I have a PL/SQL package with the local variable L_XML defined as XMLTYPE
    and an output file L_OUTBUT defined as VARCHAR2(100), what do I use to call the RTF Processor and generate the report to the output file?
    That is
    declare
    l_xml xmltype;
    l_output varchar2(100);
    begin
    -- stuff to build the xml variable
    -- insert the call to FTP Processor here Apparently, it should be
    -- something like
    package.procedure('linked_rtf file name', l_xml, l_output);
    end;
    If this calls a Java script, would also appreciate a sample copy of the script.
    My need is desperate so any assistance will be greatly appreciated.
    Many thanks
    Frank

    I don't think you can. The parameters passed to a VB dll are formatted differently than a C dll, especially strings. I know a C program has to use special data structures when working with a VB dll, and this is basically what Oracle is doing.
    It should be possible, however, to create a C dll that acts as a wrapper for the VB dll. I'm not sure this would save you anything, though. If you have to do that you may as well write the function in C.

  • Generating an xml from a pl/sql procedure

    Hi Friends,
    I have come up with a requirement to generate an xml from a pl/sql procedure.
    I did some R & D and also got some sample procedures but could not understand the datatypes being used.
    The procedure declares variables like this:
    doc                  xmldom.DOMDocument;
    mainNode         xmldom.DOMNode;
    headerElem      xmldom.DOMElement; Pls could anyone tell what do these xmldom.DOMDocument, xmldom.DOMNode and xmldom.DOMElement mean?
    Later in the procedure, these variables are assigned values like
    doc      := xmldom.newDOMDocument;
    mainNode := xmldom.makenode(doc); This went a bouncer on me.
    Pls help.
    Thanks in advance ...!

    You can check this one -- Learned this from michael.
    satyaki>
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    satyaki>
    satyaki>
    satyaki>with person_h
      2  as
      3    (
      4      select 1 id, 'M' gender, 'W' race, '170' weight from dual union all
      5      select 1, 'M', 'W', '170' from dual union all
      6      select 1, 'M', 'W', '180' from dual union all
      7      select 1, 'M', NULL, '175' from dual union all
      8      select 1, NULL, 'W', NULL from dual
      9    )
    10    select xmlelement("Person",(
    11                                 select xmlagg(xmlelement("Sex", gender))
    12                                 from (
    13                                        select distinct gender
    14                                        from person_h
    15                                        where id = 1
    16                                        and gender is not null
    17                                      ) pg
    18                                ),
    19                                (
    20                                  select xmlagg(xmlforest(race as "Race"))
    21                                  from (
    22                                         select distinct race
    23                                         from person_h
    24                                         where id = 1
    25                                       ) pg
    26                                ),
    27                                (
    28                                  select xmlagg(xmlforest(weight as "Weight"))
    29                                  from (
    30                                         select distinct weight
    31                                         from person_h
    32                                         where id = 1
    33                                       ) pg
    34                                 )
    35                     ).getstringval() Res
    36    from dual;
    RES
    <Person><Sex>M</Sex><Race>W</Race><Weight>170</Weight><Weight>175</Weight><Weight>180</Weight></Person>
    satyaki>Regards.
    Satyaki De.

Maybe you are looking for

  • Dual Language in Form Printing

    Hi Friends, I have to maintain two languages for sales order printing i.e. EN and FR. I have copied the standard print program into a Zprogram as I have to add some more functionality  also the script is a Custom Script. How would I maintain two lang

  • SAP reporting layout sharing

    Looking for a way to share reporting layouts between users without giving all the users access to modify the layout.  I thought this was standard SAP however my IT department is indicating it can't be done.

  • Cannot connect to WIFI with WPA2 enterprise security

    I'm currently trying to switch my Wifi from WPA2 Personal to WPA2 Enterprise using a dd-wrt flashed TP-Link router and a Synology Diskstation as the RADIUS server. The diskstation also creates the CA certificate which I can download from there for al

  • Black & White Printing

    How can I print in B&W from MacOS Preview.app (it's a .pdf file) and my color cartridges are empty. Thanks

  • Floating point problem in method

    When I got a method, like moveTo(float,float), originally, it should be, for example moveTo(30.45f,100.894f). But if I passed an array which id of type float but don't have the 'f' at the back. Does this matter? An Example: float x1Points[]=new float