How to *. ZIP has *. CSV file in the Oracle Directory?

Hello! How are you doing guys?

I have a question;

How to Zip, a CSV file in the oracle directory?

I use this method, but a mistake;

Error; Invalid file operation, this line: utl_file.get_raw (v_arquivo_out, strbufferdd);

___The Script___

v_arquivo_out: = utl_file.fopen ('ORA_DIR',-/ oracle/files/ORA/ORADIR /)

"DOC. CSV', - file name

"WORLD BANK");

UTL_FILE.get_raw (v_arquivo_out, strbufferdd);  <-this line a mistake.

strbufferdd: = UTL_COMPRESS.lz_compress (strbufferdd, 6);

V_SDIRECTORY: = TO_CHAR (SYSDATE, ' DD_MM_YYYY_HH24.MI.) SS') | "_RETORNA. ZIP';

psDsc_File: = v_sDirectory;

v_arquivo_out2: = utl_file.fopen ('ORA_DIR',-/ oracle/files/ORA/ORADIR /)

psDsc_File,

'W');

-as_zip.

Utl_File.Put_Raw (v_arquivo_out2, strbufferdd);

UTL_FILE.fclose (v_arquivo_out);

UTL_FILE.fclose (v_arquivo_out2);

___End SCRIPT___

Help me?

Thank you to all the world, I have the solution;

Please see the procedure;

CREATE OR REPLACE PROCEDURE 'PR_RELAT_CSV '.

(

peCod_Prog in DOCUMENT. Type of Cod_Prog %,

psDsc_File out varchar2

)

IS

-variaveis para land

v_arquivo_out utl_file.file_type;

v_separator varchar2 (1): = "";

v_sDirectory varchar2 (200);

src_file BFILE.

v_content BLOB;

v_blob_len INTEGER.

v_file UTL_FILE.file_type;

v_buffer RAW (32767).

v_amount directory: = 32767;

v_pos INTEGER: = 1;

BEGIN

-DADOS PREENCHIDOS. ABAIXO, CRIAR PREENCHER E O LAND CSV

V_SDIRECTORY: = TO_CHAR (SYSDATE, ' DD_MM_YYYY_HH24.MI.) SS') |

' _RETORNA. CSV';

psDsc_File: = v_sDirectory;

v_arquivo_out: = utl_file.fopen ('ORA_DIR',-/ oracle/files/oradir/ora /)

psDsc_File,

'W');

cabecalho - write

UTL_FILE.put_line (v_arquivo_out,

"Organize" | v_separator | ' OPTIONS / Options'.

v_separator | "AP" | v_separator | "CODE" |

v_separator | 'Description of the PN | v_separator |

"Station". v_separator | "Initial SN | v_separator |

"Final SN | v_separator | 'Note ' | v_separator |

'Pos ' | v_separator,

(FALSE);

-write linhas

/ * n : = 0 ; Contador * /.

for rec_ (SELECT DISTINCT a.*, d.DSC_ITEM, e.COD_PN_MAT

OF pcm_subestacao one

LEFT JOIN (select b.cod_prog,

c.num_arj,

c.cod_itens,

c.DSC_ITEM,

c.COD_SEST_CONJ

of pcm_desenho b

INNER JOIN TABLE (fu_pcm_Combinar_Subestacao ('SYSTEM', b.cod_prog, b.num_arj, 0, null, null, null,)) c

ON b.num_arj = c.num_arj

and b.cod_prog = peCod_Prog) d

ON a.cod_sest_conj = d.cod_sest_conj

INNER JOIN pcm_mat_geral e

ON e.cod_cemb_mat = a.cod_cemb_estc

WHERE a.cod_prog = peCod_Prog

loop of the order of a.num_arj, num_ns_i, num_ns_fn)

/ * n : = n + 1 ; Contador linhas * /.

UTL_FILE.put_line (v_arquivo_out,

Chr (34) | Chr (32) | rec_. NUM_ARJ | Chr (32) |

Chr (34) | v_separator | Chr (34) | Chr (32) |

rec_. DSC_ITEM | Chr (32) | Chr (34) | v_separator |

Chr (34) | Chr (32) | rec_. COD_PN_SEST | Chr (32) |

Chr (34) | v_separator | Chr (34) | Chr (32) |

rec_. COD_CEMB_SEST | Chr (32) | Chr (34) |

v_separator | Chr (34) | Chr (32) | rec_. DSC_PN_SEST |

Chr (32) | Chr (34) | v_separator | Chr (34) |

Chr (32) | rec_. COD_PN_MAT | Chr (32) | Chr (34) |

v_separator | Chr (34) | Chr (32) | rec_. NUM_NS_I |

Chr (32) | Chr (34) | v_separator | Chr (34) |

Chr (32) | rec_. NUM_NS_FN | Chr (32) | Chr (34) |

v_separator | Chr (34) | Chr (32) | rec_. DSC_OBS |

Chr (32) | Chr (34) | v_separator | Chr (34) |

Chr (32) | rec_. IND_POS | Chr (32) | Chr (34) |

v_separator,

(FALSE);

end loop;

UTL_FILE.fclose (v_arquivo_out);

src_file: = BFILENAME ('ORA_DIR', psDsc_File);

DBMS_LOB. FileOpen (src_file, dbms_lob.file_readonly);

v_content: = utl_compress.lz_compress (src_file);

v_blob_len: = DBMS_LOB.getlength (v_content);

V_SDIRECTORY: = TO_CHAR (SYSDATE, ' DD_MM_YYYY_HH24.MI.) SS') |

' _RETORNA. CSV. ZIP';

psDsc_File: = v_sDirectory;

v_file: = utl_file.fopen ('ORA_DIR',-/ oracle/files/ORADIR/ORA /)

psDsc_File,

"WORLD BANK");

Everything v_pos< v_blob_len="">

DBMS_LOB. READ (v_content, v_amount, v_pos, v_buffer);

UTL_FILE.put_raw (v_file, v_buffer, TRUE);

v_pos: = v_pos + v_amount;

END LOOP;

UTL_FILE.fclose (v_file);

EXCEPTION

WHILE OTHERS THEN

IF UTL_FILE.is_open (v_file) THEN

UTL_FILE.fclose (v_file);

END IF;

LIFT;

END PR_RELAT_CSV;

Tags: Database

Similar Questions

  • Read the csv file in the Windows directory

    Hi all

    I have a requirement to fill an Oracle table with the CSV file in the Windows directory.
    Please help me to achieve this goal.

    Thank you.

    Published by: Amit1cs on June 4, 2013 08:46

    Then I suggest you mark this thread as answered and repost on the SQL/PLSQL forum. This forum is for Developer SQL related questions.

    Good luck in your task!

  • Copy a file in the oracle directory

    I create a directory in statement create or replace directory john_test_dir as 'e:\jp_test\image_dir';

    now, I need to copy an image in e:\jp_test\image_dir how can we do this?

    by,.
    jp_valapad

    compile code below and post the error message

    create or replace procedure proc_blob_inser is
    l_blob blob.
    l_bfile bfile.

    Start
    insert into tbl_blob_demo values (1, empty_blob ()) return DATA_BLOB in l_blob;
    l_bfile: = BFILENAME ('JOHN_TEST_DIR', 'a.gif');
    DBMS_LOB. FileOpen (l_bfile);
    DBMS_LOB. LoadFromFile (l_blob, l_bfile, DBMS_LOB. GetLength (l_bfile));
    DBMS_LOB. FileClose (l_bfile);
    end;

    The directory name must be in the capital

    Published by: rajneesh kumar on November 24, 2008 16:19

  • How can I retrieve my files from the clouds after my hard drive has crashed - files were not deleted.

    How can I retrieve my files from the clouds after my hard drive has crashed - files were not deleted.

    Don't know what your problem is - log on to Skydrive and recover the files that you need them, or download the app to Skydrive and they will all be uploaded at the same time.

  • How can I transfer a file from the operating system to a backup of the production running VM virtual machine?

    Problem:  After I do a backup one using ghettoVCB on a local VMFS volume, I have a virtual machine that I can start something happened to that running.  However, sometimes I just need a file from the OS level, which means that I would need to start to get them, but then I have an IP address conflict.  I can't imagine a way to have the NICs turned off and still be able to move the file.  If I change the IP addresses, the software that I need to create the file that I need to transfer no longer works because, although there no need of constant connectivity to the seller, it is locked to the public IP address.http://communities.vmware.com/images/emoticons/sad.gif

    Material:  I have two 4 ESXi hosts to work, each with local VMFS volumes.  They share a private vlan common and a vlan common public.  They each ssh, ftp, wput, wget, and rsync available.  I have a Windows 2003 Server VM which also hosts a NFS and the VI client and other VMWare tools.  It also has private and public interfaces as do virtual machines that would be to make and receive the OS files.

    Question:  How can I transfer a file from the operating system to a backup of the production running VM virtual machine?

    Thank you!

    Yes Mr President, make sure you set the network on this virtual machine to be connected to the 'Internal' vswitch, you set up before turning the power on to the virtual machine.

    -

  • Download csv file into the database using apex

    Hi all

    I use apex 4 and express oracle 10g, I need to upload the .csv file in the database for one of my queries, I just discussion forum for solutions, I found too, but some how its does not work for me.

    below mentioned is error and the code


    ERROR:

    ORA-06550: line 38, column 8: PLS-00221: 'V_DATA_ARRAY' is not a procedure or is undefined ORA-06550: line 38, column 8: PL/SQL: statement ignored ORA-06550: line 39, column 8: PLS-00221: 'V_DATA_ARRAY' is not a procedure or is undefined ORA-06550: line 39, column 8: PL/SQL: statement ignored ORA-06550: line 40, column 8: PLS-00221: 'V_DATA_ARRAY' is not a procedure or is undefined ORA-06550 : line 40, column 8: PL/SQL: statement ignored ORA-06550: line 41, column 8: PLS-00221: 'V_DATA_ARRAY' is not a proc
    Error
    Ok


    CODE:
    DECLARE
    v_blob_data BLOB;
    v_blob_len NUMBER;
    V_POSITION NUMBER;
    v_raw_chunk RAW (10000);
    v_char char (1);
    number of c_chunk_len: = 1;
    v_line VARCHAR2 (32767): = NULL;
    v_data_array wwv_flow_global.vc_arr2;
    BEGIN
    -Read data from wwv_flow_files
    Select blob_content from v_blob_data
    of wwv_flow_files where filename = "DDNEW.csv";

    v_blob_len: = dbms_lob.getlength (v_blob_data);
    V_POSITION: = 1;

    -Read and convert binary to a char
    WHILE (v_position < = v_blob_len) LOOP
    v_raw_chunk: = dbms_lob.substr(v_blob_data,c_chunk_len,v_position);
    v_char: = chr (hex_to_decimal (rawtohex (v_raw_chunk)));
    v_line: = v_line | v_char;
    V_POSITION: = v_position + c_chunk_len;
    -When a whole line is retrieved
    IF v_char = Chr (10) THEN
    -Convert comma to: use of wwv_flow_utilities
    v_line: = REPLACE (v_line, ', ' :'); ")
    -Converting each column separated by: in the data table
    v_data_array: = wwv_flow_utilities.string_to_table (v_line);
    -Insert data into the target table
    EXECUTE IMMEDIATE ' insert into TABLE_X (v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
    "values (: 1,: 2,: 3: 4:5:6,: 7,: 8,: 9,: 10:11).
    USING
    v_data_array (1),
    v_data_array (2),
    v_data_array (3),
    v_data_array (4);
    v_data_array (5);
    v_data_array (6).
    v_data_array (7);
    v_data_array (8);
    v_data_array (9);
    v_data_array (10);
    v_data_array (11);

    -Remove
    v_line: = NULL;
    END IF;
    END LOOP;
    END;



    what I understand of it's system does not identify v_data_array as table for some reasons, please help me.



    initially the system was in error for hex_to_decimal, but I managed to get this feature on the discussion forum, and now it seems to be ok. but v_data_array problem is still there.



    Thanks in advance

    concerning

    Uday

    Hello

    Correct errors in your sample, I have

    Problem 1

    select blob_content into v_blob_data
    from wwv_flow_files where filename = 'DDNEW.csv'; 
    

    TO

    select blob_content into v_blob_data
    from wwv_flow_files where name = :P1_FILE;
    

    Problem 2

    EXECUTE IMMEDIATE 'insert into TABLE_X (v1, v2, v3, v4 ,v5, v6, v7,v8 ,v9, v10, v11)
    values (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11)'
    USING
    v_data_array(1),
    v_data_array(2),
    v_data_array(3),
    v_data_array(4);
    v_data_array(5);
    v_data_array(6);
    v_data_array(7);
    v_data_array(8);
    v_data_array(9);
    v_data_array(10);
    v_data_array(11);  
    

    TO

    EXECUTE IMMEDIATE 'insert into TABLE_X (v1, v2, v3, v4 ,v5, v6, v7,v8 ,v9, v10, v11)
    values (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11)'
    USING
    v_data_array(1),
    v_data_array(2),
    v_data_array(3),
    v_data_array(4),
    v_data_array(5),
    v_data_array(6),
    v_data_array(7),
    v_data_array(8),
    v_data_array(9),
    v_data_array(10),
    v_data_array(11);  
    

    And I have created table missing

    CREATE TABLE TABLE_X
      (
        v1  VARCHAR2(255),
        v2  VARCHAR2(255),
        v3  VARCHAR2(255),
        v4  VARCHAR2(255),
        v5  VARCHAR2(255),
        v6  VARCHAR2(255),
        v7  VARCHAR2(255),
        v8  VARCHAR2(255),
        v9  VARCHAR2(255),
        v10 VARCHAR2(255),
        v11 VARCHAR2(255)
      );
    

    Kind regards
    Jari

    Published by: jarola November 19, 2010 15:03

  • How can I protect some files of the icloud sharing in the sierra?

    How can I protect certain files from the desktop to icloud and sharing documents in the sierra?  Some of my data is private and I don't want it in the cloud.

    Do not put them in the Documents folder or on the desktop.

  • Is it possible to plug a USB to my new iPad Pro, to transfer PDF files and some Jpeg files from the USB key with an adapter of lightning? If there is NO adapter, how can I get these files on the USB key and my iPad pro?

    Is it possible to plug a USB to my new iPad Pro, to transfer PDF files and some Jpeg files from the USB key with an adapter of lightning? If there is NO adapter, how can I get these files on the USB key and my iPad pro? I need these PDF files transferred my I touch pro. Any suggestions?  Please

    Thank you

    Mike Tingey

    The iPad does not support USB keys. There are some wireless flash drives that can be used, but not the classical records. I suggest you transfer files to a computer and their synchronization then back to the iPad via iTunes.

  • How can I transfer video files to the library in windows media player for an external hard drive

    How can I transfer video files to the library in windows media player for an external hard drive. My os is Windows XP Home Edition and I use wmp 11.

    You have to locate the files on your internal hard drive, using the Explorer, then drag and drop them on the hard drive.  If you don't know where they are on your hard drive, right click on the video file in the library and choose the location of the opened file.

  • reproductive Extender invalid files in the installation directory - how to correct?

    My computer Guard stops. When it restarts, it displays a message 'invalid or missing files in the installation directory. Please reinstall Extender Player". How can I fix it?

    Hello

    1. have you done any change in software on the computer lately?
    2. are you able to boot in safe mode?
    3. do you have the Extender player installed on your computer?
    If so have you tried to re - install?
     

    Method 1.
    If you are able to boot to the desktop then disable automatic reboot.

    My computer properties > Advanced tab > startup and recovery settings > uncheck automatically restart.
     

    Method 2.
    Check to see if the problem exists in Safe Mode, if the computer works as expected in mode without failure, then we can solve the problem in the clean boot state.

    Note: Configure the computer to start in the State of clean boot to Safe Mode and check.
    a. refer to the article below for the procedure safe mode in Windows XP
    A description of the options to start in Windows XP Mode
    http://support.Microsoft.com/kb/315222
     
    b. you need to perform a clean boot to find the program that is causing and then disable or remove.
    How to configure Windows XP to start in a "clean boot" State
    http://support.Microsoft.com/kb/310353/en-us
    Note: When you are finished troubleshooting, follow the steps as explained in the article to reset the computer to start as usual.

    I hope this helps.
  • Windows Live Mail - How can I move old files to the newly created folders mail?

    How can I move old files to the newly created folders mail?

    original title: windows live mail/vista/records
    1. Simple click on the header of a message to select it.
    2. CTRL + F3 will highlight all.
    3. Right-click on highlighted messages and drag them to the new folder.
    4. Release the mouse button and select copy here.
    5. If the move is successful, delete the original folder if you wish.
  • How to pin folders and files to the taskbar?

    I have a few updates from XP to Windows 7.  How to pin folders and files to the taskbar?  I got a lot of these in my XP Quick Launch bar.

    Mike

    PIN Windows Explorer in the taskbar and you can right click to get your recently viewed files.

    You can also add toolbars to the taskbar.
    http://Windows.Microsoft.com/en-GB/Windows7/add-a-toolbar-to-the-taskbar

    A toolbar can be any folder in Windows Explorer. So you can put any selection of files to a user created folder and access these files quickly thanks to a simple icon in your taskbar.

    However, don't go overboard you can quickly run out of space on the taskbar. My toolbars are interspersed between the program pinned to the taskbar, tasks and links with the Noification area to the right. The section of the program will go to a second line below according to the needs and so you can limit the space allocated to programs if you wish.

  • How do you rename a file on the cloud?

    How do you rename a file on the cloud?

    There are two ways to rename the file. If you use file synchronization, then you can rename it after finding in the creative Cloud Files folder. Or you can rename it using the active site CC to https://assets.adobe.com and on the Actions menu, choose Rename.

  • How to download a PDF file from the clouds on iPad?

    I do not see a PDF file without an Internet connection, how can I permanently download a PDF from the PDF clouds?

    Hi Russell,

    You may want to take a look at the options that I have provided here: How can I copy a file in the cloud to document local Adobe on my iOS device?

    Thank you

    Abhishek

  • Not possible to export a list of virtual machines that are created in the past 7, 30, 120 and 180 days since an imported csv file containing the date of creation of virtual machine

    Not possible to export a list of virtual machines that are created in the past 7, 30, 120 and 180 days since an imported csv file containing the date of creation of virtual machine. My questions is the correct statement to the variable: $VmCreated7DaysAgo: $_CreatedOn "-lt" $CDate7.

    # #SCRIPT_START

    $file = "C:\Users\Admin\Documents\WindowsPowerShell\08-18-2014\VM-Repo.csv".

    $Import = import-csv $file

    $VMCreatedLast7RDayRepoFile = "C:\Users\Admin\Documents\WindowsPowerShell\08-18-2014\Last7Days.csv".

    $start7 = (get-Date). AddMonths(-1)

    $CDate7 = $start7. ToString('MM/dd/yyyy')

    $VmCreated7DaysAgo = $Import | Select-object - property name, Powerstate, vCenter, VMHost, Cluster, file, Application, CreatedBy, CreatedOn, NumCpu, MemoryGB | Where-Object {$_.} CreatedOn - lt $CDate7} | Sort-Object CreatedOn

    $TotalVmCreated7DaysAgo = $VmCreated7DaysAgo.count

    $VmCreated7DaysAgo | Export-Csv-path $VMCreatedLast7RDayRepoFile - NoTypeInformation - UseCulture

    Write-Host "$TotalVmCreated7DaysAgo VMs created in 7 days" - BackgroundColor Magenta

    Invoke-Item $VMCreatedLast7RDayRepoFile

    # #SCRIPT_END

    You can use the New-Timespan cmdlet in the Where clause, it returns the time difference between 2 DateTime objects.

    An example of this cmdley

    New-TimeSpan-start (Get-Date). AddDays(-7)-end (Get-Date). Select days - ExpandProperty

    In your case, you could do

    Where {(New Timespan-démarrer ([DateTime] $_.))} CreatedOn) - end $start7). {7 days - gt}

    But beware of negative numbers.

Maybe you are looking for