Re: PL/SQL Loop and Spool Question

From: Dagoberto Navea Alfaro <dago_at_cec.unap.cl>
Date: Fri, 15 Oct 1999 11:33:08 -0300
Message-ID: <7u7gsd$aas$1_at_manutara.inf.utfsm.cl>


In sql/plus i can call one program pl/sql (start progpl.sql or _at_progpl.sql), also existing pakages in pl/sql that you can create text file usin TEXT_IO.

for example

CargaAsignacion(lp_archivoin in varchar2, lp_archivoout in varchar2,lp_ano in number,lp_sem in number, lp_utm in number) is
BEGIN
/*
Description : read register from text file lp_archivoin

              y create register to text file lp_archivoout. */
declare

   ld_reg VARCHAR2(150);
   in_file Text_IO.File_Type;
   out_file Text_IO.File_Type;
begin

      in_file := Text_IO.Fopen(lp_archivoin,'r');
      out_file := Text_IO.Fopen(lp_archivoout,'w');
      ld_nroreg := 0;
      loop
          if ld_nroreg <= 10 then
              exit;
          end if;
          text_IO.get_line(in_file,ld_reg);   // Read from file in_file
          Text_IO.PUT_Line(out_file,ld_reg);  // Write to file out_file
          ld_nroreg:=ld_nroreg+1

      end loop;
exception
     when no_data_found then
           Text_IO.Fclose (out_file);
           Text_IO.Fclose (in_file);
           message('Termine.....');
           null;

end;
end;

Hi hope this help you

Note: Sorry my English i am Chileam

Rob Vicker escribió en mensaje <7t37g3$bp3_at_ng1.icn.state.ia.us>...
>I know that technically SQL*Plus doesn't support loops but, PL/SQL does. I
>am trying to read in customer values from the customer table and execute a
>SQL statement for each customer with using the customer name as a parameter
>to the query. This all seems to work fine but, I am also spooling this
data
>to a file and I want to use the customer name as the name of the file (it
is
>there billing detail). Does anyone know how to use a loop and set a new
>filename on the spool function each time you go through the loop?
>
>Thanks in advance.
>
>-Rob
>
>
Received on Fri Oct 15 1999 - 16:33:08 CEST

Original text of this message