Home » Developer & Programmer » Forms » What this code do step by step?
What this code do step by step? [message #181698] Tue, 11 July 2006 03:29 Go to next message
khusraqazi
Messages: 3
Registered: July 2006
Location: INDIA
Junior Member
Hi,

Could someone please let me know step by step what does this code do in this procedure?
I will appreciate this very much.

KhusraQazi


Below this is a procedure :

PROCEDURE get_file (p_type in VARCHAR2) IS
  fp            UTL_FILE.FILE_TYPE; 
  p_loc    VARCHAR2(100) := :Loc.file_loc;
  p_file_start  VARCHAR2(20)  := :Loc.file_start;
  p_file_end    VARCHAR2(20)  := :loc.file_end;
  p_start_plsql VARCHAR2(5000);
  p_mid_plsql   VARCHAR2(2000);
  p_end_plsql   VARCHAR2(5000);
  p_out_status  NUMBER(4) := 0;
  v_line        VARCHAR2(1000);
  v_l_start     NUMBER(10);
  v_l_end       NUMBER(10);
  v_ol_start    NUMBER(10);
  v_ol_end      NUMBER(10);
  v_temp        NUMBER;
  v_temp_line   VARCHAR2(300);
  v_temp_date   DATE;
  v_quick_list  VARCHAR2(1000);



BEGIN

  p_start_plsql :=                'DECLARE fp UTL_FILE.FILE_TYPE; ';
  p_start_plsql := p_start_plsql||'  i number; ';
  p_start_plsql := p_start_plsql||'BEGIN ';

  p_end_plsql :=              '  BEGIN ';
  p_end_plsql := p_end_plsql||'    fp := UTL_FILE.FOPEN('''||p_loc||''','''||
                 p_file_start||'''||to_char(i)||'''||p_file_end||''',''r''); ';
  p_end_plsql := p_end_plsql||'    UTL_FILE.FCLOSE (fp); ';
  p_end_plsql := p_end_plsql||'    DBMS_OUTPUT.PUT_LINE(i); ';
  p_end_plsql := p_end_plsql||'  EXCEPTION WHEN OTHERS THEN NULL; ';
  p_end_plsql := p_end_plsql||'  END; ';
  p_end_plsql := p_end_plsql||' END LOOP; ';
  p_end_plsql := p_end_plsql||'END; ';

  DBMS_OUTPUT.ENABLE(100000);
  GO_BLOCK('child');
  CLEAR_BLOCK;

  v_ol_start := LEAST(NVL(:loc.minimum,1),NVL(:loc.maximum,99999));
  v_ol_end   := GREATEST(NVL(:loc.minimum,1),NVL(:loc.maximum,99999));
  v_ol_start := trunc(v_ol_start/5000);
  v_ol_end   := trunc((v_ol_end-1)/5000);

  SET_APPLICATION_PROPERTY(CURSOR_STYLE,'BUSY');
  message('0 %',NO_ACKNOWLEDGE);
  synchronize;

  FOR a in v_ol_start..v_ol_end LOOP
    v_l_start := (a*5000)+1;
    v_l_end   := (a+1)*5000;
    IF p_type = 'NORMAL' then
       p_mid_plsql := 'FOR i in '||v_l_start||'..'||v_l_end||' LOOP ';
    ELSE
       p_mid_plsql := 'FOR j in (SELECT DISTINCT to_number(p.spid) j '||
                      ' FROM v$session s, v$process p '||
                      ' WHERE s.paddr=p.addr) loop i := j.j; ';
    END IF;
    v_temp := v_ol_end - v_ol_start;
    IF v_temp != 0 THEN
       v_temp := trunc((a - v_ol_start)/v_temp,2);
    ELSE
       v_temp := 0;
    END IF;

    FORMS_DDL(p_start_plsql||p_mid_plsql||p_end_plsql);
    message(to_char(v_temp*100)||' %',NO_ACKNOWLEDGE);
    synchronize;
    IF NOT FORM_SUCCESS THEN
       message('bugger');pause;
    END IF;

    WHILE p_out_status = 0 LOOP
      dbms_output.get_line(v_line, p_out_status);
      IF p_out_status = 0 THEN
        :child.FILE_NAME := p_file_start||v_line||p_file_end;
        NEXT_RECORD;
      END IF;
    END LOOP;
    p_out_status := 0;
    IF p_type = 'QUICK' then
       EXIT;
    END IF;
  END LOOP;
END;

[Updated on: Tue, 11 July 2006 03:35] by Moderator

Report message to a moderator

Re: What this code do step by step? [message #181922 is a reply to message #181698] Wed, 12 July 2006 04:11 Go to previous messageGo to next message
khusraqazi
Messages: 3
Registered: July 2006
Location: INDIA
Junior Member

Hi,

Please have a reply.

Thanks

KQ
Re: What this code do step by step? [message #182102 is a reply to message #181922] Thu, 13 July 2006 01:21 Go to previous messageGo to next message
khusraqazi
Messages: 3
Registered: July 2006
Location: INDIA
Junior Member
Why this message ('bugger') pause used in forms 6i?
Could someone plz explain what I posted ?

Thanks
KQ
Re: What this code do step by step? [message #182212 is a reply to message #182102] Thu, 13 July 2006 15:04 Go to previous messageGo to next message
jowahl
Messages: 82
Registered: May 2006
Member
"PAUSE;" is used to force forms to display the MESSAGE('...') in an alert window where the user has to accept it.

then the trigger code goes on ...

Re: What this code do step by step? [message #182515 is a reply to message #181922] Sun, 16 July 2006 01:16 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
It looks as though the dynamic SQL is used to open and close a list of files. Th e'bugger' message comes if the file can not be opened.

David
Previous Topic: About Help in Forms
Next Topic: Combo Box Problem
Goto Forum:
  


Current Time: Fri Sep 20 10:45:16 CDT 2024