In PL-SQL archive data from a table to a file

I am currently developing a vb app where I need to archive data from a table to a file. I was hoping to do this with a stored procedure. I will also need to be able to retrieve the data from the file for future use if necessary. What file types are available? Thanks in advance for any suggestions.

What about exporting in an oracle binary format? The export files cannot be modifiable. Is there a way to use the export and import utility in PL/SQL?
null

Similar Messages

  • Ho to archive data from COPA tables in ECC 6.0

    HI Experts,
    We are using ECC 6.0 and our client wants to archive data from COPA table's CE1XXXX,CE3XXXX and CE4XXXX. We are not using COPA planning.
    Need your suggestions and step by step process  to follow to archive the data from the above mentioned COPA tables. Also suggest is there any SAP note is required to apply for this activity.
    Regards,
    Chandra

    Hi Vijay Chandra
    please check below links , this shows a detail explaination.
    http://help.sap.com/saphelp_afs64/helpdata/en/8d/3e58e2462a11d189000000e8323d3a/content.htm
    How to Use SARA Tcode
    Also would suggest that Archiving thru batch job is suitable. If archving is to be done on regular basis (say monthly or quarterly)
    Regards
    Minesh
    Edited by: mineshshah on Nov 4, 2011 9:02 AM

  • How can i extract data from oracle table  to flat file or excel spread shee

    Hello,
    DB Version is 10.1.0.3.0
    How can i extract data from oracle table to flat file or excel spread sheet by using sub programs?
    Regards,
    D

    Here what I did
    SET NEWPAGE 0
    SET SPACE 0
    SET LINESIZE 80
    SET PAGESIZE 0
    SET ECHO OFF
    SET FEEDBACK OFF
    SET VERIFY OFF
    SET HEADING OFF
    SET MARKUP HTML OFF SPOOL OFF
    Sql> SPOOL bing
    select * from -------;
    SPOOL OFF;
    I do not see file.
    I also tried
    Sql> SPOOL /tmp/bing
    select * from -------;
    SPOOL OFF;
    But still not seeing the fie,

  • Downloading data from internal table to xls file leading zeros are not disp

    Hai abap gurus,
    when i am downloading data from internal table to excle file. some field values in a column are with leading zeros and some others dont have leading zeros.but in the output it is showing without leading zeros. then how to get with exact values.
    Ex:
    <b>ECC Code.</b>
    045234
      88567
    098456 
    but output is giving like this:
    45234
    88567
    98456
    how to get the actual values.....
    plz help me in this matter.

    Dear Kiran,
    Those field in the internal table having Leading Zeroes, make those fields' datatype as character.
    Then use the function module to download the content of the internal table to the excel file.
    Regards,
    Abir
    Don't forget to Reward Points  *

  • Download data from internal table to flat file.

    I need to download the data from Internal table to Flat file. can any one suggest how to do it? i suppose WS_Download OR GUI_DOWNLOAD.
    but if it is please guide me how to use this.
    is thre any other F.M. please provide the information.
    Thanks in advance

    Hi,
    Try this,
    * File download, uses older techniques but achieves a perfectly
    * acceptable solution which also allows the user to append data to
    * an existing file.
      PARAMETERS: p_file like rlgrap-filename.
    * Internal table to store export data  
      DATA: begin of it_excelfile occurs 0,
       row(500) type c,
       end of it_excelfile.
      DATA: rc TYPE sy-ucomm,
            ld_answer TYPE c.
      CALL FUNCTION 'WS_QUERY'
           EXPORTING
                query    = 'FE'  "File Exist?
                filename = p_file
           IMPORTING
                return   = rc.
      IF rc NE 0.                       "If File alread exists
        CALL FUNCTION 'POPUP_TO_CONFIRM'
          EXPORTING
    *          TITLEBAR              = ' '
    *          DIAGNOSE_OBJECT       = ' '
               text_question         = 'File Already exists!!'
               text_button_1         = 'Replace'
    *          ICON_BUTTON_1         = ' '
               text_button_2         = 'New name'
    *          ICON_BUTTON_2         = ' '
    *          DEFAULT_BUTTON        = '1'
    *          DISPLAY_CANCEL_BUTTON = 'X'
    *          USERDEFINED_F1_HELP   = ' '
    *          START_COLUMN          = 25
    *          START_ROW             = 6
    *          POPUP_TYPE            =
          IMPORTING
               answer                = ld_answer
    *     TABLES
    *         PARAMETER              =
          EXCEPTIONS
              text_not_found         = 1
              OTHERS                 = 2.
    * Option 1: Overwrite
        IF ld_answer EQ '1'.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
    *            BIN_FILESIZE            =
                 filename                = p_file        "File Name
                 filetype                = 'ASC'
    *       IMPORTING
    *            FILELENGTH              =
            TABLES
                data_tab                = it_excelfile   "Data table
            EXCEPTIONS
                file_write_error        = 1
                no_batch                = 2
                gui_refuse_filetransfer = 3
                invalid_type            = 4
                OTHERS                  = 5.
          IF sy-subrc <> 0.
            MESSAGE i003(zp) WITH
                     'There was an error during Excel file creation'(200).
            exit. "Causes short dump if removed and excel document was open 
          ENDIF.
    * Option 2: New name.
        ELSEIF ld_answer EQ '2'.
          CALL FUNCTION 'DOWNLOAD'
            EXPORTING
                 filename            = p_file          "File name
                 filetype            = 'ASC'           "File type
    *             col_select          = 'X'            "COL_SELECT
    *             col_selectmask      = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
    *                                                   "COL_SELECTMASK
                 filetype_no_show    = 'X'     "Show file type selection?
    *       IMPORTING
    *             act_filename        = filename_dat
            TABLES
                 data_tab            = it_excelfile    "Data table
    *            fieldnames          =
            EXCEPTIONS
                 file_open_error     = 01
                 file_write_error    = 02
                 invalid_filesize    = 03
                 invalid_table_width = 04
                 invalid_type        = 05
                 no_batch            = 06
                 unknown_error       = 07.
        ENDIF.
      ELSE.                               "File does not alread exist.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
    *          BIN_FILESIZE            =
               filename                = p_file         "File name
               filetype                = 'ASC'          "File type
    *     IMPORTING
    *          FILELENGTH              =
          TABLES
               data_tab                = it_excelfile   "Data table
          EXCEPTIONS
               file_write_error        = 1
               no_batch                = 2
               gui_refuse_filetransfer = 3
               invalid_type            = 4
               OTHERS                  = 5.
        IF sy-subrc <> 0.
          MESSAGE i003(zp) WITH
                   'There was an error during Excel file creation'(200).
          exit. "Causes short dump if removed and excel document was open 
        ENDIF.
      ENDIF.
    Regards,
    Raghav

  • Convert data from internal table to XML file.

    Hi All,
    I am selecting data from database into one internal table.
    Now I want to convert data from internal table to xml file format and save in to my desktop. Please suggest me how I can achieve my requirement.
    Kindly reply me ASAP.

    Use this FM. SAP_CONVERT_TO_XML_FORMAT
    Check this link too -
    Re: Data Export in XML format
    XML files from ABAP programs

  • Upload data from Internal table to text file with  '~' separator

    can anyone help me to download data from internal table to flat file with  ''  separator. GUI_DOWNLOAD is not working in my case ....like for ''  separator

    Here it is
    REPORT  zkb_test1.
    TYPE-POOLS: truxs.
    DATA: i_scarr TYPE TABLE OF scarr,
    i_conv_data TYPE truxs_t_text_data.
    SELECT * FROM scarr INTO TABLE i_scarr.
    CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
      EXPORTING
        i_field_seperator    = '~'
      TABLES
        i_tab_sap_data       = i_scarr
      CHANGING
        i_tab_converted_data = i_conv_data
      EXCEPTIONS
        conversion_failed    = 1
        OTHERS               = 2.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
        filename                = 'C:\Test1.txt'
        filetype                = 'ASC'
      CHANGING
        data_tab                = i_conv_data
      EXCEPTIONS
        file_write_error        = 1
        no_batch                = 2
        gui_refuse_filetransfer = 3
        invalid_type            = 4
        no_authority            = 5
        unknown_error           = 6
        header_not_allowed      = 7
        separator_not_allowed   = 8
        filesize_not_allowed    = 9
        header_too_long         = 10
        dp_error_create         = 11
        dp_error_send           = 12
        dp_error_write          = 13
        unknown_dp_error        = 14
        access_denied           = 15
        dp_out_of_memory        = 16
        disk_full               = 17
        dp_timeout              = 18
        file_not_found          = 19
        dataprovider_exception  = 20
        control_flush_error     = 21
        not_supported_by_gui    = 22
        error_no_gui            = 23
        OTHERS                  = 24.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Regards
    Kathirvel

  • How to copy datas from a table to a file.

    Hi,
    Can Someone help me how to do this using queries or procedures.
    I want to copy the datas from the table to a flat file (eg. text or excel).
    example:
    CREATE TABLE emp
    (FCST_DATE DATE,
    LEVEL1 VARCHAR2(2000) ,
    Sal NUMBER,
    Insert into emp (FCST_DATE,LEVEL1,Sal) values ('01-MAR-11','175-12','1');
    Insert into emp (FCST_DATE,LEVEL1,Sal) values ('01-JAN-11','319-10','100');
    Insert into emp (FCST_DATE,LEVEL1,Sal) values ('01-AUG-11','175-1L','10');
    select * from emp;
    fcst_date Level1 Sal
    01-JAN-11 319-10 100
    01-AUG-11 175-1L 12
    01-MAR-11 175-12 1
    I want this table information in a file.
    Can someone help!
    Padma

    Hi Padu,
    Use SQLPLUS commad SPOOL for exporting sql query result.
    and see : Sqlplus – spool data to a flat file

  • Export data from a table to text file using srcipt task

    Hi
    i am new to SSIS
    i have to export data from a table and append it into a existing file through SSIS script task
    please help
    Thanks
    Umesh

    Hi Umesh,
    The data structure of the source table and the structure of the destination file are the same, right? Is the destination file a flat file? Do you have to do it through Script Task? If the destination file is a flat file, this can be done easily by using
    the stock tasks/components other than .NET code. In the Data Flow Task, we choose the appropriate source adapter (such as OLE DB Source or ADO.NET Source) to extract data from the source table, perform transformation if necessary, and then load to the destination
    file via a Flat File Destination. When setting up the Flat File Destination, uncheck the “Overwrite data in the file” option so that the extracted data will be appended to the existing file.
    If you need to implement it through Script Task/Component indeed, you may benefit from the following code examples:
    http://stackoverflow.com/questions/8070163/how-to-add-custom-footer-to-an-ssis-flat-file-seperate-component-or-script-tas 
    http://stackoverflow.com/questions/8467326/add-header-and-footer-row-flat-file-ssis 
    If you need further help about the script, I suggest that you ask a new question in .NET forums where you can get more dedicated support:
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=netdevelopment 
    Regards,
    Mike Yin
    TechNet Community Support

  • How to retrive archived data from ECC table

    Hi,
    I need extract the data from archived ECC tables to BW.
    How can I know that which tables the archived data has been stored in ECC ?
    Thanks for your help in advance.
    Raj.

    Hi Sreenivas,
    I know the t-code SARA using we can pull the data. Please let me know by the steps how to pull the archived data in to the data source.
    Do I need to create any generic data source or we can pull the data into existing data source.
    Please let me know by steps or if you have any document link?
    Thanks,
    Raj.

  • Import data from Oracle table into flat file

    How to import the data in the oracle table into flat file using UTL File of PL/SQL....
    I am new in PL/SQL..
    can someone help me in writing query?

    Note : Not Tested.
    DECLARE
    V1 VARCHAR2(32767);
    F1 UTL_FILE.FILE_TYPE;
    cursor c1 is select ename,empno from emp;
    r_c1 c1%rowtype;
    BEGIN
    -- In this example MAX_LINESIZE is less than GET_LINE's length request
    -- so the number of bytes returned will be 256 or less if a line terminator is seen.
    open c1;
    F1 := UTL_FILE.FOPEN('MYDIR','MYFILE','W',256);
    loop
    fetch c1 into r_c1;
    v1:= r_c1.ename||''||To_char(r_c1.empno);
    UTL_FILE.PUT_LINE (F1, v1,TRUE);
    v1:= null;
    Exit when c1%not found;
    end loop;
    UTL_FILE.FCLOSE(F1);
    END;
    http://download.oracle.com/docs/cd/B19306_01/appdev.102
    ------------------------------------------------------------------

  • Loading data from oracle table to text file........

    how can i load data from a oracle table to a text file or CSV file using PL/SQL procedures where the pls/sql code will take the table name dynamically.........
    soumen

    Try this thread..
    Is it possible to export a pl/sql region as a csv file?

  • Writing data from a table to Excel file

    Hello friends,
    I am using Forms 5.0 on Windows NT. I need to write data from table A to Excel sheet from trigger 'when-botton-pressed'. Could you help me Any help will be appriciated.
    Thanks
    Charg
    null

    HERE IS THE CODE.
    YOU CAN RUN IT USING THE DEPT TABLE.
    PROCEDURE export_transaction_to_excel IS
    application ole2.obj_type;
    workbooks ole2.obj_type;
    workbook ole2.obj_type;
    worksheets ole2.obj_type;
    worksheet ole2.obj_type;
    cell ole2.obj_type;
    fdes varchar2(250);
    rowcounter number:=1;
    local_cursor_record number:=:system.cursor_record;
    old_cursor_style varchar2(100);
    errors_occured boolean:=false;
    ole_error exception;
    pragma exception_init(ole_error, -305500);
    my_alert_id alert;
    alert_respnse number;
    procedure place_value_in_cell(rownum_in in number,colnum_in in number,value_in in varchar2) is
    args ole2.list_type;
    begin
    args:=ole2.create_arglist;
    ole2.add_arg(args,rownum_in);
    ole2.add_arg(args,colnum_in);
    --cell:=ole2.invoke_obj(worksheet,'Cells',args);
    cell:=ole2.get_obj_property(worksheet,'Cells',args);
    ole2.destroy_arglist(args);
    ole2.set_property(cell,'Value',value_in);
    ole2.release_obj(cell);
    end place_value_in_cell;
    procedure savespreadsheet is
    args ole2.list_type;
    vDatestamp varchar2(20);
    begin
    fdes:='C:\TESTFORM.XLS';
    vDatestamp:=to_char(sysdate,'mmddyyyyy')&#0124; &#0124;'-'&#0124; &#0124;to_char(sysdate,'hh24miss');
    args:=ole2.create_arglist;
    ole2.add_arg(args,fdes);
    ole2.invoke(worksheet,'SaveAs',args);
    ole2.destroy_arglist(args);
    ole2.invoke(application,'Quit');
    end savespreadsheet;
    procedure open_excel_workbook is
    begin
    application:=ole2.create_obj('Excel.Application');
    workbooks:=ole2.get_obj_property(application,'Workbooks');
    workbook:=ole2.invoke_obj(workbooks,'Add');
    worksheets:=ole2.get_obj_property(application,'Worksheets');
    worksheet:=ole2.invoke_obj(worksheets,'Add');
    end open_excel_workbook;
    procedure write_column_header is
    begin
    place_value_in_cell(rowcounter,1,'Depart No');
    place_value_in_cell(rowcounter,2,'Depart Name');
    place_value_in_cell(rowcounter,3,'Loc');
    rowcounter:=rowcounter+1;
    end write_column_header;
    procedure export_the_data is
    original_receipt number;
    original_date date;
    original_transmital_number number;
    begin
    go_block('dept');
    first_record;
    loop
    place_value_in_cell(rowcounter,1,to_char(:deptno));
    place_value_in_cell(rowcounter,2,:dname);
    place_value_in_cell(rowcounter,3,:loc);
    exit when :system.last_record='TRUE';
    next_record;
    rowcounter:=rowcounter+1;
    end loop;
    end export_the_data;
    BEGIN
    begin
    old_cursor_style:=get_application_property(cursor_style);
    set_application_property(cursor_style,'BUSY');
    open_excel_workbook;
    write_column_header;
    export_the_data;
    exception
    when form_trigger_failure then
    raise;
    when ole_error then
    message('error sending data to excel');
    message(' ');
    errors_occured:=true;
    end;
    savespreadsheet;
    ole2.release_obj(worksheet);
    ole2.release_obj(worksheets);
    ole2.release_obj(workbook);
    ole2.release_obj(workbooks);
    ole2.release_obj(application);
    if not errors_occured then
    go_record(local_cursor_record);
    end if;
    set_application_property(cursor_style,old_cursor_style);
    END export_transaction_to_excel;

  • Error while downloading data from internal table into XML file

    hi all,
    i developed a program to download data from into internal table to xml file like this.
    tables: mara.
    parameters: p_matnr like mara-matnr.
    data: begin of itab_mara occurs 0,
                matnr like mara-matnr,
                ernam like mara-ernam,
                aenam like mara-aenam,
                vpsta like mara-vpsta,
          end of itab_mara.
    data: lv_field_seperator type c,     " value 'X',
          lv_xml_doc_name(30) type c,    " string value ‘my xml file’,
          lv_result type i.
          lv_field_seperator = 'x'.
          lv_xml_doc_name = 'my xml file'.
    types: begin of truxs_xml_line,
              data(256) type x,
          end of truxs_xml_line.
    types:truxs_xml_table type table of truxs_xml_line.
    data:lv_tab_converted_data type truxs_xml_line,
         lt_tab_converted_data type truxs_xml_table.
    data: lv_xml_file type rlgrap-filename value 'c:\simp.xml'.
    select matnr ernam aenam vpsta from mara into table itab_mara up to 5
           rows where matnr = p_matnr.
    CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
    EXPORTING
       I_FIELD_SEPERATOR          = lv_field_seperator
      I_LINE_HEADER              =
      I_FILENAME                 =
      I_APPL_KEEP                = ' '
       I_XML_DOC_NAME             = lv_xml_doc_name
    IMPORTING
       PE_BIN_FILESIZE            = lv_result
      TABLES
        I_TAB_SAP_DATA             = itab_mara
    CHANGING
       I_TAB_CONVERTED_DATA       = lt_tab_converted_data
    EXCEPTIONS
      CONVERSION_FAILED          = 1
      OTHERS                     = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    open dataset lv_xml_file for output in binary mode.
    loop at lt_tab_converted_data into lv_tab_converted_data.
    transfer lv_tab_converted_data to lv_xml_file.
    endloop.
    close dataset lv_xml_file.
    this program is syntactically correct and getting executed, but when i open the target xml file it is showing the following error.
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    XML document must have a top level element. Error processing resource 'file:///C:/simp.xml'.
    will anyone show me the possible solution to rectify this error
    thanks and regards,
    anil.

    Hi,
    Here is a small sample program to convert data in an internal table into XML format and display it.
    DATA: itab  TYPE TABLE OF spfli,
          l_xml TYPE REF TO cl_xml_document.
    * Read data into a ITAB
    SELECT * FROM spfli INTO TABLE itab.
    * Create the XML Object
    CREATE OBJECT l_xml.
    * Convert data in ITAB to XML
    CALL METHOD l_xml->create_with_data( name = 'Test1'
                                         dataobject = t_goal[] ).
    * Display XML Document
    CALL METHOD l_xml->display.
    Here are some other sample SAP programs to handle XML in ABAP:
    BCCIIXMLT1, BCCIIXMLT2, and BCCIIXMLT3.
    Hope this helps,
    Sumant.

  • Transfering data from oracle table to a file on a windows server

    Hi
    I have an oracle DB version 11.2 running on oracle enterprize linux 5.9. I would much appreciate an suggestions on how to transfer data from the oracle DB to a flat file on a windows server.
    What i have done so far is to use utl_file to create a csv file on the oracle server and am now attempting to transfer this file. I was going to use scp or rcp but am unable to get this to work(was looking at filezilla). Another option i can use is ftp as i have a unix script which i can run to do this. All this is done through an oracle package which is run hourly through dbms_scheduler. I have been using sp_host_command to run unix commands directly from pl/sql so can use this to run a unix script for last resort if i cant find an easier way to automate this.
    Any suggestions or options would be much appreciated.
    Cheers
    Gary

    Well, using DBMS_SCHEDULER you can run o/s commands so you could use that to do your FTP or whatever to move the file.
    Alternatively, you could write your own FTP package using the built in UTL_TCP package, or you can get hold of one of the freebie packages people have made available to do the same e.g.
    ORACLE-BASE - FTP From PL/SQL in Oracle in Oracle

Maybe you are looking for

  • OracleAS 10g Installation Problem on Windows2000

    I install OracleAS 10g for “Business Intelligence et Forms” While demanding to register for Oracle Internet Directory, I seize: host: liu-gwej0o37upx (it’s my machine’s name in that I install Oracle9i Server) port : 389 then this is a message of erro

  • TOC in PDF does not include Link OBJR tags when exported from InDesign

    I'm using InDesign CS6 to export a book file to a tagged PDF. When I run the accessibility checker in Acrobat 9, I get errors about items not being contained in the Structure tree. These missing items are links for the TOC and the Index page numbers.

  • Payment terms - net due date same as credit days?

    Dear all, I need to set up a payment term with 20 credit days, 2%. Invoices should be due also after 20 days. I would like the payment term to be set up as follow: Term           Percentage           No of days 1.                2                    

  • Uploading photos from pc to iphone

    I have photos & videos transfered from motorolla to my pc, how i tranfer them to my iphone.

  • HANA SQL for BPC cubes

    I have been looking for getting start help/ideas on how to push BPC BADI logic down to HANA SQL. Not really sure where is the right place my question. Which forum should I focus on?  Not much help in BPC forum on this subject. ~Dilkins