Export table data in a flat file without using FL

Hi,
I am looking for options where I can export table data into a flat file without using FL(File Layout) i.e., by using App Engine only.
Please share your experience if you did anything as this
Thanks

A simple way to export any record (table/view) to an csv fiel, is to create a rowset and loop through all record fields, like below example code
Local Rowset &RS;
Local Record &Rec;
Local File &MYFILE;
Local string &FileName, &strRecName, &Line, &Seperator, &Value;
Local number &numRow, &numField;
&FileName = "c:\temp\test.csv";
&strRecName = "PSOPRDEFN";
&Seperator = ";";
&RS = CreateRowset(@("Record." | &strRecName));
&RS.Fill();
&MYFILE = GetFile(&FileName, "W", %FilePath_Absolute);
If &MYFILE.IsOpen Then
   For &numRow = 1 To &RS.ActiveRowCount
      &Rec = &RS(&numRow).GetRecord(@("RECORD." | &strRecName));
      For &numField = 1 To &Rec.FieldCount
         &Value = String(&Rec.GetField(&numField).Value);
         If &numField = 1 Then
            &Line = &Value;
         Else
            &Line = &Line | &Seperator | &Value;
         End-If;
      End-For;
      &MYFILE.WriteLine(&Line);
   End-For;
End-If;
&MYFILE.Close(); You can of course create an application class for generic calling this piece of code.
Hope it helps.
Note:
Do not come complaining to me on performance issues ;)

Similar Messages

  • Exporting table data to a flat file

    Hi, I am trying to export data from a table to a text file using this:
    CREATE TABLE bufurl
    url, sno
    ORGANIZATION EXTERNAL
    TYPE oracle_datadump
    DEFAULT DIRECTORY dataload
    LOCATION ('external.txt')
    AS
    SELECT url, sno from table1 where sno > 10
    but i get this error:
    ERROR at line 1:
    ORA-29829: implementation type does not exist
    any clues what might be going on here?

    user652125 wrote:
    Hi, I am trying to export data from a table to a text file using this:
    CREATE TABLE bufurl
    url, sno
    ORGANIZATION EXTERNAL
    TYPE oracle_datadump
    DEFAULT DIRECTORY dataload
    LOCATION ('external.txt')
    AS
    SELECT url, sno from table1 where sno > 10
    but i get this error:
    ERROR at line 1:
    ORA-29829: implementation type does not exist
    any clues what might be going on here?Well it should work if you are using 10g or above...
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE TABLE ext_emps
      2  ORGANIZATION EXTERNAL
      3  (TYPE oracle_datapump
      4   DEFAULT DIRECTORY TEST_DIR
      5   LOCATION ('emps.txt'))
      6  AS
      7  SELECT empno, ename
      8* from emp
    SQL> /
    Table created.
    SQL>What version of SQL*Plus are you running?

  • Export HRMS data to a flat file

    Hi All!
    Are there any ways of exporting employee related data to a flat file without using a client app (PeopleCode or Integration Broker), that is simply generate a CSV feed from UI?

    You can Schedule a query and specify the output format as text. Note that when you select View Log/Trace in process monitor, you will see a file with a .csv extension. However, it will open by default in Excel, and even if you select Save instead of Open it will try to change the extension to .xls. You will have to change it back to .csv.

  • Exporting table data to a CSV file

    hello everyone,
    i need help on exporting table data to a CSV file.
    I have a div element containing the table which displays some data.
    there is a "Export" button just above the table, which if clicked, will export the current data in the table to a .csv file.
    can this be done in jsp? or i need to use servlet?
    also how can i submit the table data only? (as my webpage contiain other data also)
    can anyone provide with some sort of sample code?
    thanks in advance!!

    oops!!
    i just forgot..
    when the user will click on the export button, i want to greet him with a "Save As"
    popup, so that he can specify the filename and location to save the file.
    thanks!!

  • How can we export table data to a CSV file??

    Hi,
    I have the following requirement. Initially business agreed upon, exporting the table data to Excel file. But now, they would like to export the table data to a CSV file, which is not being supported by af:exportCollectionActionListener component.
    Because, when i opened the exported CSV file, i can see the exported data sorrounded with HTML tags. Hence the issue.
    Does someone has any solution for this ... Like, how can we export the table data to csv format. And it should work similar to exporting the data to excel sheet.
    For youre reference here is the code which i have used to export the table data..
    ><f:facet name="menus">
    ><af:menu text="Menu" id="m1">
    ><af:commandMenuItem text="Print" id="cmi1">
    ><af:exportCollectionActionListener exportedId="t1"
    >title="CommunicationDistributionList"
    >filename="CommunicationDistributionList"
    >type="excelHTML"/> ---- I tried with removing value for this attribute. With no value, it did not worked at all.
    ></af:commandMenuItem>
    ></af:menu>
    ></f:facet>
    Thanks & Regards,
    Kiran Konjeti

    Hi Alex,
    I have already visited that POST and it works only in 10g. Not in 11g.
    I got the solution for this. The solution is :
    Use the following code in jsff
    ==================
    <af:commandButton text="Export Data" id="ctb1">><af:fileDownloadActionListener contentType="text/csv; charset=utf-8"
    >filename="test.csv"
    >method="#{pageFlowScope.pageFlowScopeDemoAppMB.test}"/>
    ></af:commandButton>
    OR
    <af:commandButton text="Export Data" id="ctb1">><af:fileDownloadActionListener contentType="application/vnd.ms-excel; charset=utf-8"
    >filename="test.csv"
    >method="#{pageFlowScope.pageFlowScopeDemoAppMB.test}"/>
    ></af:commandButton>
    And place this code in ManagedBean
    ======================
    > public void test(FacesContext facesContext, OutputStream outputStream) throws IOException {
    > DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    >DCIteratorBinding itrBinding = (DCIteratorBinding)dcBindings.get("fetchDataIterator");
    >tableRows = itrBinding.getAllRowsInRange();
    preparaing column headers
    >PrintWriter out = new PrintWriter(outputStream);
    >out.print(" ID");
    >out.print(",");
    >out.print("Name");
    >out.print(",");
    >out.print("Designation");
    >out.print(",");
    >out.print("Salary");
    >out.println();
    preparing column data
    > for(Row row : tableRows){
    >DCDataRow dataRow = (DCDataRow)row;
    > DataLoaderDTO dto = (DataLoaderDTO)dataRow.getDataProvider();
    >out.print(dto.getId());
    >out.print(",");
    >out.print(dto.getName());
    >out.print(",");
    >out.print(dto.getDesgntn());
    >out.print(",");
    >out.print(dto.getSalary());
    >out.println();
    >}
    >out.flush();
    >out.close();
    > }
    And do the following settings(*OPTIONAL*) for your browser - Only in case, if the file is being blocked by IE
    ==================================================================
    http://ais-ss.usc.edu/helpdoc/main/browser/bris004b.html
    This resolves implementation of exporting table data to CSV file in 11g.
    Thanks & Regards,
    Kiran Konjeti

  • Exporting Table data to delimited txt file

    I am trying to import the table data into delimited text file, I am running the following code from Tom Kyte's website on the server. When I run the procedure after I run the function it is not creating any .dat file for me.
    I have also checked for the parameter 'utl_file_dir' in the database and it is set to the correct path. Is there anything that I am missing??
    any suggestions/inputs would help.
    create or replace function dump_csv( p_query in varchar2,
    p_separator in varchar2
    default ',',
    p_dir in varchar2 ,
    p_filename in varchar2 )
    return number
    AUTHID CURRENT_USER
    is
    l_output utl_file.file_type;
    l_theCursor integer default dbms_sql.open_cursor;
    l_columnValue varchar2(2000);
    l_status integer;
    l_colCnt number default 0;
    l_separator varchar2(10) default '';
    l_cnt number default 0;
    begin
    l_output := utl_file.fopen( p_dir, p_filename, 'w' );
    dbms_sql.parse( l_theCursor, p_query, dbms_sql.native );
    for i in 1 .. 255 loop
    begin
    dbms_sql.define_column( l_theCursor, i,
    l_columnValue, 2000 );
    l_colCnt := i;
    exception
    when others then
    if ( sqlcode = -1007 ) then exit;
    else
    raise;
    end if;
    end;
    end loop;
    dbms_sql.define_column( l_theCursor, 1, l_columnValue,
    2000 );
    l_status := dbms_sql.execute(l_theCursor);
    loop
    exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
    l_separator := '';
    for i in 1 .. l_colCnt loop
    dbms_sql.column_value( l_theCursor, i,
    l_columnValue );
    utl_file.put( l_output, l_separator ||
    l_columnValue );
    l_separator := p_separator;
    end loop;
    utl_file.new_line( l_output );
    l_cnt := l_cnt+1;
    end loop;
    dbms_sql.close_cursor(l_theCursor);
    utl_file.fclose( l_output );
    return l_cnt;
    end dump_csv;
    create or replace procedure test_dump_csv
    as
    l_rows number;
    begin
    l_rows := dump_csv( 'select *
    from doctype
    where rownum < 25',
    ',', '/tmp', 'test.dat' );
    end;
    /

    Hi,
    It works for me...
    SQL> select dump_csv('select * from dba_users',',','/tmp','teste.txt') from dual;
    DUMP_CSV('SELECT*FROMDBA_USERS',',','/TMP','TESTE.TXT')
                                                       149
    SQL> show parameter utl_file_dir
    NAME                                 TYPE        VALUE
    utl_file_dir                         string      /tmp
    oracle@icaro:/tmp> ls -l teste.txt
    -rw-r--r--  1 rps users 394353 2006-07-31 17:40 teste.txtJust for information:
    I'm using SUSE LINUX 10 and Oracle 10g 10.1.0.2
    Cheers
    Message was edited by:
    Legatti

  • Saving a Text data to a PDF file without using print option

    Hi,
    I want to save a Text to a PDF file. I want to assign the path of the PDF file as a default one.
    If I use Print options, then it ask for the file path at the run time.
    Is there any method to save to a PDF file without using print option in Labview 8.2.
    Regards,
    Raja

    This question comes up a lot. Did you try searching? It depends on the PDF printer driver that you're using. See here, here, here, ...

  • Export data to a flat file

    Hi all,
    I need to export a table data to a flat file.
    But the problem is that the data is huge about 200million rows occupying around 60GB of space
    If I use SQL*Loader in Toad, it is taking huge time to export
    After few months, I need to import the same data again into the table
    So please help me which is the efficient and less time taking method to do this
    I am very new to this field.
    Can some one help me with this?
    My oracle database version is 10.2
    Thanks in advance

    OK so first of all I would ask the following questions:
    1. Why must you export the data and then re-import it a few months later?
    2. Have you read through the documentation for SQLLDR thoroughly ? I know it is like stereo instructions but it has valuable information that will help you.
    3. Does the table the data is being re-imported into have anything attached to it eg: triggers, indices or anything that the DB must do on each record? If so then re-read the the sqlldr documentation as you can turn all of that off during the import and re-index, etc. at your leisure.
    I ask these questions because:
    1. I would find a way for whatever happens to this data to be accomplished while it was in the DB.
    2. Pumping data over the wire is going to be slow when you are talking about that kind of volume.
    3. If you insist that the data must be dumped, massaged, and re-imported do it on the DB server. Disk IO is an order of magnitude faster then over the wire transfer.

  • How to Export Table Data to a excel sheet using OPENROWSET

    Hi Team,
    I would like to Export table data to a excel sheet by using "OPENROWSET" command in SQL Server but I am getting the
    below error message
    Column name or number of supplied values does not match table definition.
    Please help me on how to export the table data to an excel sheet by using "OPENROWSET" in SQL Server

    I know this is old so I assume you've fixed this. However, for anyone else looking at this forum, I'd recommend using a union or a table join.
    Select a.1, a.2, a.3 from a <where clause>
    union
    Select b.1, b.2, b.3 from b <where clause>
    or
    use a type of join.
    If both table selects return the same number of columns but different data just reference them as a variable like fred, and Ted
    Select fred.1, fred.2, fred.3 from (Select a.1, a.2, a.3 from a) fred
    union
    Select Ted.1, Ted.2, Ted.3 from (Select b.1, b.2, b.3 from b) Ted
    or again some type of join of these two sets
    Select * from
    (Select a.1, a.2, a.3 from a) a
    INNER JOIN (Select b.1, b.2, b.3 from b) b ON b.1 = a.1
    This would give you 6 columns of data a1-3, and b1-3
    We don't know from your description what format your spreadsheet is in. These just give you the idea. Think of the sub-selects as a Table. It's just named "fred". Once your select holds all the data you need, then export the data to the spreadsheet. Use
    the horsepower of the database before trying to do a multple update of the same spreadsheet.
    Does this give you enough to fix what you were trying to do?   

  • Export table data to Pdf file

    Hi all,
    I have a .jspx page wich contains a table and a button with an exportCollectionActionListener to export the table data to an excell file.
    Now i want to do the same but to a pdf file.
    Is that posible, and if so how can I do that?
    If it isn't posible is there any way to do that.
    Thanks all,
    Rowan

    Hi!
    Yes, the first step is to learn iReport. Then, investigate Jasper Forums where you will find lot of code and hints.
    To produce a report you have to:
    1. Create report definition and compile it in report files used by Jasper API later on (this you learn on Jasper forums)
    2. Create java code in your project to generate report (based on datasource in your app) - this is just java code which doesnt have anything special to ADF/JDev - learn this also on Jasper forums
    3. Decide which mechanism you will use to downstream report output (whichever render you select when generate report - PDF, HTML, Excle, RTF...) - there are two options:
    a. Use standard JSP Servlet, where you just have to generate report and downstream it into servlet's output stream
    b. more ADF 11g way - using af:fileDownloadActionListener with backingbean to downstream a generated report content
    That's it. You have to design your own strategy for supplying report query parameters (through Http Request params or any other way dependent on mechanism you decide to use).
    Try Googling for Jdeveloper Jasper and you will find several blogs/forums on this topic (try JDeveloper and Jasper.. HTML Report without information The servlet technique is same as in 10g and for ADF 11g way you have to manage yourself.
    Regards,
    PaKo

  • Export table data in text file

    hi,
    i am using oracle 8.0.7 , i want to export a table data in to text file, thanks in advance
    Noman ul haq

    2 options:
    1) Spool the query results into a file using SQL*PLUS
    2) If you can use the Oracle Server, look at the UTL_FILE package. This writes files, but ONLY to the Oracle server. It will NOT write out to your client machine. Your DBA will need to add an entry to allow for the UTL_FILE package to write out to the directory you choose.
    Hope that helps - the documentation should have detailed usage of UTL_FILE package. Or search on this site b/c this is a common question - see it at least 3 times a week.

  • What is the best way to load and convert data from a flat file?

    Hi,
    I want to load data from a flat file, convert dates, numbers and some fields with custom logic (e.g. 0,1 into N,Y) to the correct format.
    The rows where all to_number, to_date and custom conversions succeed should go into table STG_OK. If some conversion fails (due to an illegal format in the flat file), those rows (where the conversion raises some exception) should go into table STG_ERR.
    What is the best and easiest way to archive this?
    Thanks,
    Carsten.

    Hi,
    thanks for your answers so far!
    I gave them a thought and came up with two different alternatives:
    Alternative 1
    I load the data from the flat file into a staging table using sqlldr. I convert the data to the target format using sqlldr expressions.
    The columns of the staging table have the target format (date, number).
    The rows that cannot be loaded go into a bad file. I manually load the data from the bad file (without any conversion) into the error table.
    Alternative 2
    The columns of the staging table are all of type varchar2 regardless of the target format.
    I define data rules for all columns that require a later conversion.
    I load the data from the flat file into the staging table using external table or sqlldr without any data conversion.
    The rows that cannot be loaded go automatically into the error table.
    When I read the data from the staging table, I can safely convert it since it is already checked by the rules.
    What I dislike in alternative 1 is that I manually have to create a second file and a second mapping (ok, I can automate this using OMB*Plus).
    Further, I would prefer using expressions in the mapping for converting the data.
    What I dislike in alternative 2 is that I have to create a data rule and a conversion expression and then keep the data rule and the conversion expression in sync (in case of changes of the file format).
    I also would prefer to have the data in the staging table in the target format. Well, I might load it into a second staging table with columns having the target format. But that's another mapping and a lot of i/o.
    As far as I know I need the data quality option for using data rules, is that true?
    Is there another alternative without any of these drawbacks?
    Otherwise I think I will go for alternative 1.
    Thanks,
    Carsten.

  • Uploading the data from a flat file into ztable

    Hi,
    I have a requirement where I have to upload the data from 2 flat files into 2 z tables(ZRB_HDR,ZRB_ITM).From the 1st flat file only data for few fields have to be uploaded into ztable(ZRB_HRD) .Fromthe 2nd flat file data for all the fields have to me uploaded into ztable(ZRB_ITM). How can I do this?
    Regards,
    Hema

    hi,
    declare two internal table with structur of your tables.
    your flat files should be .txt files.
    now make use of GUI_UPLOAD function module to upload your flatfile into internal tables.
    CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename            = 'c:\file1.txt'
          has_field_separator = 'X'
        TABLES
          data_tab            = itab1
        EXCEPTIONS
          OTHERS              = 1.
    use this function twice for two tables.
    then loop them individually and make use of insert command.

  • Problem in the BDC program to upload the data from a flat file.

    Hi,
    I am required to write a BDC program to upload the data from a flat file. The conditions are as mentioned below:-
    1) Selection Screen will be prompted to user and user needs to provide:- File Path on presentation server (with F4 help for this obligatory parameter) and File Separator e.g. @,#,$,%,... etc(fields in the file will be separated by using this special character) or fields may be separated by tab(tab delimited).
    2) Finally after the data is uploaded, following messages need to be displayed:-
    a) Total Number of records successfully uploaded.
    b) Session Name
    c) Number of Sessions created.
    Problem is when each record is fetched from flat file, the record needs to be split into individual fields separated by delimiter or in case tab separated, then proceeding in usual manner.
    It would be great if you provide me either the logic, pseudocode, or sample code for this BDC program.
    Thanks,

    Here is an example program,  if you require the delimitor to be a TAB, then enter TAB on the selection screen, if you require the delimitor to be a comma, slash, pipe, whatever, then simply enter that value.  This example is simply the uploading of the file, not the BDC, I assume that you know what to do once you have the data into the internal table.
    REPORT zrich_0001.
    TYPES: BEGIN OF ttab,
            rec TYPE string,
           END OF ttab.
    TYPES: BEGIN OF tdat,
           fld1(10) TYPE c,
           fld2(10) TYPE c,
           fld3(10) TYPE c,
           fld4(10) TYPE c,
           END OF tdat.
    DATA: itab TYPE TABLE OF ttab.
    data: xtab like line of itab.
    DATA: idat TYPE TABLE OF tdat.
    data: xdat like line of idat.
    DATA: file_str TYPE string.
    DATA: delimitor TYPE string.
    PARAMETERS: p_file TYPE localfile.
    PARAMETERS: p_del(5) TYPE c.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      DATA: ifiletab TYPE filetable.
      DATA: xfiletab LIKE LINE OF ifiletab.
      DATA: rc TYPE i.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        CHANGING
          file_table = ifiletab
          rc         = rc.
      READ TABLE ifiletab INTO xfiletab INDEX 1.
      IF sy-subrc = 0.
        p_file = xfiletab-filename.
      ENDIF.
    START-OF-SELECTION.
      TRANSLATE p_del TO UPPER CASE.
      CASE p_del.
        WHEN 'TAB'.
          delimitor = cl_abap_char_utilities=>horizontal_tab.
        WHEN others.
          delimitor = p_del.
      ENDCASE.
      file_str = p_file.
      CALL METHOD cl_gui_frontend_services=>gui_upload
        EXPORTING
          filename = file_str
        CHANGING
          data_tab = itab.
      LOOP AT itab into xtab.
        CLEAR xdat.
        SPLIT xtab-rec AT delimitor INTO xdat-fld1
                                         xdat-fld2
                                         xdat-fld3
                                         xdat-fld4.
        APPEND xdat to idat.
      ENDLOOP.
      LOOP AT idat into xdat.
        WRITE:/ xdat-fld1, xdat-fld2, xdat-fld3, xdat-fld4.
      ENDLOOP.
    Regards,
    Rich Heilman

  • Procurement Card data upload from flat file to database

    Hi All,
    I need to upload Procurement Card data from a flat file to the database in the table BBP_PCMAS.
    I found a BAPI BAPI_PCARD_CREATEMULTIPLE which uploads the data perfectly, however the structure PCMASTER that it takes as input does not contain the field for Blocking reason PCBLOCK - Reason for blocking procurement card. I need to upload this file as well from the flat file.
    Any suggestions?
    Thanks

    Hi,
    You are correct the function module BAPI_PCARD_CREATEMULTIPLE  does not contain the PCBLOCK field.
    Alternatively what you can do is read the PC data after it is created and modify it with the PCBLOCK appropiately. The necessary function modules are given below.
    BBP_PCMAS_READ_PCMAS - Read Data
    BBP_PCMAS_MODIFY_PCMAS - Modify Data
    Note: BBP_PCMAS_MODIFY_PCMAS is a Update Task FM. Hence it shoild be called as given below, ( refer form write_data of the FM BAPI_PCARD_CREATEMULTIPLE)
      call function 'BBP_PCMAS_MODIFY_PCMAS' in update task
           exporting
                i_pcmas     = i_pcmas
    *         I_PCMAS_OLD =
    *         I_DELETE    =
          tables
               t_pcacc     = i_pcacc
    *         T_PCACC_OLD =
          exceptions
               not_found   = 1
               others      = 2.
    Regards
    Kathirvel

Maybe you are looking for

  • How can I uninstall FF4 and go back to FF3.x?

    ''Duplicate post, continue here - [https://support.mozilla.com/en-US/questions/814655]'' I have nothing but constant issues with video not running, my Google Analytics page freezing up, Facebook lagging, and other weird and annoying garbage with Fire

  • Color Palette Filter?

    Is there a filter that will let you set a custom palette and adjust the colors of the original clip to their closest match?  I think I've found a couple filters that will do this for a selection of up to 3-4 colors, but I'm looking for something more

  • How to add a package to flex builder?

    I download a package named com.adobe.serilaztion.json(may be I spell worng), My question is that what should I do to make this package be added into the flex ,just like flash.display.sprite, I can import the package in.

  • Can you blur the background with Touch for phone

    Can you blur the background with Touch for phone.  Can you give images a depth of field look

  • Sql query to find workspace name

    Hi I know that if I run the following query select v('WORKSPACE_ID') from dual it will give me the workspace id any idea how I could get the workspace name instead?