Help Procedure

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Fri, 02 May 2008 4:01 pm

Guys, where must be passed the name of the arquivvo as a parameter?

: Script
Code: Select all
create or replace PROCEDURE             "SP_INSERE_ARQ_TARIFADOR" (p_nome_arquivo in varchar2) as
  v_linha                     varchar2(200);
  f_arquivo                   utl_file.file_type;
  v_arquivo                      varchar2(50);
begin
  delete dados_linha;
  f_arquivo    := utl_file.fopen('/tmp',p_nome_arquivo,'R');
  loop
    begin
      utl_file.get_line(f_arquivo,v_linha);
      --
      insert into dados_linha
        ( linha )
      values
        (substr(p_nome_arquivo,1,3)||substr(v_linha,4,110) );
      --
    Exception
        When No_Data_Found      Then
          Exit;
        When Others Then
          raise_application_error(20001,'Erro v_linha-> '|| v_linha||' -> '||sqlerrm);
    end;
  end loop;
  UTL_FILE.FCLOSE(F_ARQUIVO);
  commit;
end;
mariogus
Location: Porto Alegre - RS

Poston Mon, 05 May 2008 10:50 am

Don't quite understand your question, but the use of the parameter would be done as follows:
Code: Select all
SP_INSERE_ARQ_TARIFADOR("Nome_do_arquivo.ext");
Ah ... where necessary through some sample code, use the tag [code] what specifically you want to know?
Toad
Location: Seattle, WA

Matheus H. Gonçalves
www.toad.com.br
www.twitter.com/toadgeek



Return to SQL

Who is online

Users browsing this forum: No registered users and 4 guests