Pular para o conteúdo
Visualizando 7 posts - 1 até 7 (de 7 do total)
  • Autor
    Posts
  • #97416
    Avatar de hcamposcruhcamposcru
    Participante

      Pessoal,

      Alguém sabe me falar se é possível eu listar através de uma consulta o nome dos arquivos existentes em uma pasta local da máquina?

      Abraço

      #97417
      Avatar de leandrolbsleandrolbs
      Participante

        Olá, de uma pesquisada nesta função, não tenho muito conheço melhor pesquisar….

        UTL_FILE.FGETATTR

        #97422
        Avatar de hudsonahudsona
        Participante

          Chara,

          Não sei qual o teu problema, mas acho que listar os arquivos de um diretorio pelo banco, nao é uma solução muito bacana ….

          Enfim a package que o amigo postou acima, é legal porém, só diz se um arquivo existe em um diretorio, retorna um boolean …

          agora o mestre tom, deu uma solução bacana, da uma olhada :

          http://asktom.oracle.com/pls/asktom/f?p … 9619916584

          #97443
          Avatar de burgaburga
          Participante

            Só lembrando que se você estiver brincando com o XE não terá suporte ao Java… Segue ainda uma outra opção interessante que eu encontrei por aí:

            http://www.chrispoole.co.uk/tips/plsqltip2.htm

            Não tive tempo de testar ainda, mas é bem curiosa esta opção… Se você tiver algum sucesso poste aqui o resultado!!!
            Abraços,

            #97445
            Avatar de hudsonahudsona
            Participante

              Mandou muito bem burga …

              Só que o rapaz quando for rodar, vai ter que ter privilegios de sys …rs

              mas interessante …

              #97446
              Avatar de IshiiIshii
              Participante

                Olá,

                Testei a opção do Tom Kyte e funciona mas para os arquivos onde está o BD, se tiver o privilégio de leitura, qualquer diretório do Servidor pode ser listado. No segundo caso, não tive sucesso ainda…

                Se o colega quiser listar os arquivos da máquina cliente, a opção do Tom Kyte não funciona… e ainda não achei nada que funcionasse…

                []s Ishii

                #97449
                Avatar de fsitjafsitja
                Participante

                  Tem uma outra ideia do Tom Kyte que ele exibiu durante o GUOB Tech Day que serve esse propósito também, mas é recurso do 11g Release 2. Segue abaixo o exemplo exibido pelo Tom, extraído do material dele:

                  [quote=”Tom Kyte”:witlemyw]

                  External Tables can run code now

                  • External tables allow for a preprocessor
                    =>Program is run when you SELECT from external table
                    => The ‘location’ is passed to the script/executable
                    =>The executable does whatever it wants and writes to stdout
                    =>Stdout is treated as the input file
                  • We need a way to control who can do what
                    GRANT EXECUTE ON DIRECTORY handles that
                    [/quote]


                  ops$tkyte%ORA11GR2> CREATE or replace DIRECTORY load_dir
                  2 AS '/mnt/hgfs/docs/Presentations/Seminar/11gr2'
                  3 /

                  Directory created.

                  ops$tkyte%ORA11GR2> CREATE or replace DIRECTORY exec_dir
                  2 AS '/mnt/hgfs/docs/Presentations/Seminar/11gr2'
                  3 /

                  Directory created.

                  ops$tkyte%ORA11GR2> CREATE TABLE EMP_ET
                  2 (
                  3 "EMPNO" NUMBER(4),
                  4 "ENAME" VARCHAR2(10),
                  5 "JOB" VARCHAR2(9),
                  6 "MGR" NUMBER(4),
                  7 "HIREDATE" DATE,
                  8 "SAL" NUMBER(7,2),
                  9 "COMM" NUMBER(7,2),
                  10 "DEPTNO" NUMBER(2)
                  11 )
                  12 ORGANIZATION external
                  13 ( TYPE oracle_loader
                  14 DEFAULT DIRECTORY load_dir
                  15 ACCESS PARAMETERS
                  16 ( RECORDS DELIMITED BY NEWLINE
                  17 preprocessor exec_dir:'run_gunzip.sh'
                  18 FIELDS TERMINATED BY "|" LDRTRIM
                  19 )
                  20 location ( 'emp.dat.gz')
                  21 )
                  22 /
                  Table created.

                  ops$tkyte%ORA11GR2> !file emp.dat.gz
                  emp.dat.gz: gzip compressed data, was "emp.dat", from Unix, last modified: Wed Oct 7 12:48:53 2009

                  ops$tkyte%ORA11GR2> !cat run_gunzip.sh
                  #!/bin/bash

                  /usr/bin/gunzip -c $*

                  ops$tkyte%ORA11GR2> select empno, ename from emp_et where rownum <= 5;

                   EMPNO ENAME
                  

                    7369 SMITH
                    7499 ALLEN
                    7521 WARD
                    7566 JONES
                    7654 MARTIN
                  

                  E o pulo do gato:

                  ops$tkyte%ORA11GR2> CREATE TABLE ls
                  2 (
                  3 line varchar2(255)
                  4 )
                  5 ORGANIZATION external
                  6 ( TYPE oracle_loader
                  7 DEFAULT DIRECTORY load_dir
                  8 ACCESS PARAMETERS
                  9 ( RECORDS DELIMITED BY NEWLINE
                  10 preprocessor exec_dir:'run_ls.sh'
                  11 FIELDS TERMINATED BY "|" LDRTRIM
                  12 )
                  13 location ( 'run_ls.sh')
                  14 )
                  15 /

                  Table created.

                  ops$tkyte%ORA11GR2> select * from ls;

                  LINE

                  11 things about 11gr2.ppt
                  diyp.sql
                  ebr.old.sql
                  ebr.sql
                  emp.ctl
                  emp.dat.gz
                  EMP_ET_26122.log
                  emp_et.sql
                  LS_26122.log
                  run_gunzip.sh
                  run_ls.sh

                  11 rows selected.

                Visualizando 7 posts - 1 até 7 (de 7 do total)
                • Você deve fazer login para responder a este tópico.
                plugins premium WordPress