export data from the table in xml files

Hello

This thread to get your opinion on how export data tables in a file xml containing the data and another (xsd) that contains a structure of the table.
For example, I have a datamart with 3 dimensions and a fact table. The idea is to have an xml file with data from the fact table, a file xsd with the structure of the fact table, an xml file that contains the data of the 3 dimensions and an xsd file that contains the definition of all the 3 dimensions. So a xml file fact table, a single file xml combining all of the dimension, the fact table in the file a xsd and an xsd file combining all of the dimension.

I never have an idea on how to do it, but I would like to have for your advise on how you would.

Thank you in advance.

You are more or less in the same situation as me, I guess, about the "ORA-01426 digital infinity. I tried to export through UTL_FILE, content of the relational table with 998 columns. You get very quickly in this case in these ORA-errors, even if you work with solutions CLOB, while trying to concatinate the column into a CSV string data. Oracle has the nasty habbit in some of its packages / code to "assume" intelligent solutions and converts data types implicitly temporarily while trying to concatinate these data in the column to 1 string.

The second part in the Kingdom of PL/SQL, it is he's trying to put everything in a buffer, which has a maximum of 65 k or 32 k, so break things up. In the end I just solved it via see all as a BLOB and writing to file as such. I'm guessing that the ORA-error is related to these problems of conversion/datatype buffer / implicit in the official packages of Oracle DBMS.

Fun here is that this table 998 column came from XML source (aka "how SOA can make things very complicated and non-performing"). I have now 2 different solutions 'write data to CSV' in my packages, I use this situation to 998 column (but no idea if ever I get this performance, for example, using table collections in this scenario will explode the PGA in this case). The only solution that would work in my case is a better physical design of the environment, but currently I wonder not, engaged, as an architect so do not have a position to impose it.

-- ---------------------------------------------------------------------------
-- PROCEDURE CREATE_LARGE_CSV
-- ---------------------------------------------------------------------------
PROCEDURE create_large_csv(
    p_sql         IN VARCHAR2 ,
    p_dir         IN VARCHAR2 ,
    p_header_file IN VARCHAR2 ,
    p_gen_header  IN BOOLEAN := FALSE,
    p_prefix      IN VARCHAR2 := NULL,
    p_delimiter   IN VARCHAR2 DEFAULT '|',
    p_dateformat  IN VARCHAR2 DEFAULT 'YYYYMMDD',
    p_data_file   IN VARCHAR2 := NULL,
    p_utl_wra     IN VARCHAR2 := 'wb')
IS
  v_finaltxt CLOB;
  v_v_val VARCHAR2(4000);
  v_n_val NUMBER;
  v_d_val DATE;
  v_ret   NUMBER;
  c       NUMBER;
  d       NUMBER;
  col_cnt INTEGER;
  f       BOOLEAN;
  rec_tab DBMS_SQL.DESC_TAB;
  col_num NUMBER;
  v_filehandle UTL_FILE.FILE_TYPE;
  v_samefile BOOLEAN      := (NVL(p_data_file,p_header_file) = p_header_file);
  v_CRLF raw(2)           := HEXTORAW('0D0A');
  v_chunksize pls_integer := 8191 - UTL_RAW.LENGTH( v_CRLF );
BEGIN
  c := DBMS_SQL.OPEN_CURSOR;
  DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
  DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
  --
  FOR j IN 1..col_cnt
  LOOP
    CASE rec_tab(j).col_type
    WHEN 1 THEN
      DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,4000);
    WHEN 2 THEN
      DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
    WHEN 12 THEN
      DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
    ELSE
      DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,4000);
    END CASE;
  END LOOP;
  -- --------------------------------------
  -- This part outputs the HEADER if needed
  -- --------------------------------------
  v_filehandle := UTL_FILE.FOPEN(upper(p_dir),p_header_file,p_utl_wra,32767);
  --
  IF p_gen_header = TRUE THEN
    FOR j        IN 1..col_cnt
    LOOP
      v_finaltxt := ltrim(v_finaltxt||p_delimiter||lower(rec_tab(j).col_name),p_delimiter);
    END LOOP;
    --
    -- Adding prefix if needed
    IF p_prefix IS NULL THEN
      UTL_FILE.PUT_LINE(v_filehandle, v_finaltxt);
    ELSE
      v_finaltxt := 'p_prefix'||p_delimiter||v_finaltxt;
      UTL_FILE.PUT_LINE(v_filehandle, v_finaltxt);
    END IF;
    --
    -- Creating creating seperate header file if requested
    IF NOT v_samefile THEN
      UTL_FILE.FCLOSE(v_filehandle);
    END IF;
  END IF;
  -- --------------------------------------
  -- This part outputs the DATA to file
  -- --------------------------------------
  IF NOT v_samefile THEN
    v_filehandle := UTL_FILE.FOPEN(upper(p_dir),p_data_file,p_utl_wra,32767);
  END IF;
  --
  d := DBMS_SQL.EXECUTE(c);
  LOOP
    v_ret := DBMS_SQL.FETCH_ROWS(c);
    EXIT
  WHEN v_ret    = 0;
    v_finaltxt := NULL;
    FOR j      IN 1..col_cnt
    LOOP
      CASE rec_tab(j).col_type
      WHEN 1 THEN
        -- VARCHAR2
        DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
        v_finaltxt := v_finaltxt || p_delimiter || v_v_val;
      WHEN 2 THEN
        -- NUMBER
        DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
        v_finaltxt := v_finaltxt || p_delimiter || TO_CHAR(v_n_val);
      WHEN 12 THEN
        -- DATE
        DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
        v_finaltxt := v_finaltxt || p_delimiter || TO_CHAR(v_d_val,p_dateformat);
      ELSE
        v_finaltxt := v_finaltxt || p_delimiter || v_v_val;
      END CASE;
    END LOOP;
    --
    v_finaltxt               := p_prefix || v_finaltxt;
    IF SUBSTR(v_finaltxt,1,1) = p_delimiter THEN
      v_finaltxt             := SUBSTR(v_finaltxt,2);
    END IF;
    --
    FOR i IN 1 .. ceil( LENGTH( v_finaltxt ) / v_chunksize )
    LOOP
      UTL_FILE.PUT_RAW( v_filehandle, utl_raw.cast_to_raw( SUBSTR( v_finaltxt, ( i - 1 ) * v_chunksize + 1, v_chunksize ) ), TRUE );
    END LOOP;
    UTL_FILE.PUT_RAW( v_filehandle, v_CRLF );
    --
  END LOOP;
  UTL_FILE.FCLOSE(v_filehandle);
  DBMS_SQL.CLOSE_CURSOR(c);
END create_large_csv;

Tags: Database

Similar Questions

  • How to export data from the table with the colouring of cells according to value.

    Hi all

    I use jdeveloper 11.1.1.6

    I want to export data from the table with a lot of formatting. as for color cells based on value and so much. How to do this?

    You can find us apache POI-http://poi.apache.org/

    See this http://www.techartifact.com/blogs/2013/08/generate-excel-file-in-oracle-adf-using-apache-poi.html

  • Export data from the table

    Hello. Is it possible to export data from a table in Oracle using SQL Loader? If Yes, can you tell a good examples?

    Hello

    Hello. Is it possible to export data from a table in Oracle using SQL Loader?

    No, with SQL * Loader, you can load data from external files into tables not export.

    coil c:\temp\empdata.txt
    sqlplus abc.sql (assumes that abc.sql runs select * from emp)
    spool off

    It cannot work like this, because the declaration of the COIL is not recognized outside the SQL * Plus the term.

    But, you can include the statement of the COIL in abc.sql like this:

    spool c:\temp\empdata.txt
    select * from emp;
    spool off
    

    Then, you just have to run the SQL script as follows:

    sqlplus  @abc.sql 
    

    However, I advise you to use Oracle SQL Developer, this is a free tool and with it you can export a Table in several types of format (html, xml, csv, xls,...).

    Please find attached a link to this tool:

    http://www.Oracle.com/technetwork/developer-tools/SQL-Developer/Overview/index.html

    Hope this helps.
    Best regards
    Jean Valentine

  • Export data from the database to excel file using the procedure

    Hello

    I need to export data from database to oracle 10 g for the excel file, I try this code:

    First, I create directory to the user sys and give permition to user that I'm working on it
    create or replace directory PALPROV_REPORTS as 'c:\temp';
    
    grant read, write on directory PALPROV_REPORTS to user12 ;
    then I run this code
    declare
        output utl_file.file_type;
    begin
        output := utl_file.fopen( 'user12' , 'emp1.slk', 'w',32000 );
        utl_file.put_line(output, 'line one: some text');
        utl_file.fclose( output );
    end;
    the problem appears as
    ORA-29280: invalid path ORA-06512: at "SYS." UTL_FILE", line 29 ORA-06512: at"SYS." UTL_FILE", line 448 ORA-06512: at line 4

    Notice that I use the operating system windows as a client and a linux as a server database

    The file will be written to the database server or your GNU / linux and I'm quite sure, there is no folder named "c:\temp" on linux. It will probably be ' / tmp' on a unix server.

    And open the file, you must give the name logic directory 'PALPROV_REPORTS' it instead of the user name "utilisateur12".

  • Is it possible to see/get the data from the table to a dump file

    I have files dmp generated using expdp on oracle 11 g...

    expdp_schemas_18MAY2013_1.dmp

    expdp_schemas_18MAY2013_2.dmp

    expdp_schemas_18MAY2013_3.dmp

    Can I use a settings file given below to get the data from the table in the file sql or impdp the only option to load the data of table in database.

    VI test1.par

    USERID = "/ as sysdba".

    DIRECTORY = DATA

    dumpfile=expdp_schemas_18MAY2013%S.dmp

    SCHEMAS = USER1, USER2

    LOGFILE = user_dump_data.log

    SQLFILE = user_dump_data. SQL

    and impdp parfile = test1.par.

    No,

    DataPump cannot retrieve a dumpfile data in a flat file.

    Dean

  • How to save data from the COM port to file?

    Hi all

    can someone tell me please how to save data from the COM port on file? I transfer 1 byte of serial port... attached is the image of the vi... very basic.

    I would like to save the data in a table... I mean, 1 data--> data--> data tab 2 tab 3rd--> tab

    and so on... can anyone help?


  • Export data from the database Table in the CSV file with OWB mapping

    Hello

    is it possible to export data from a database table in a CSV with an owb mapping. I think that it should be possible, but I didn't yet. Then someone can give me some tips how to handle this? Someone has a good article on the internet or a book where such a problem is described.

    Thank you

    Greetings Daniel

    Hi Daniel,.

    But how do I set the variable data file names in the mapping?

    Look at this article on blog OWB
    http://blogs.Oracle.com/warehousebuilder/2007/07/dynamically_generating_target.html

    Kind regards
    Oleg

  • Insert XML data from the Table-> back to null

    Dear Experts,

    -I have table xml as below:

    Example of CREATE TABLE (XML_spec XMLTYPE);

    Insert in the example
    Select ' < name of Message = "dataStaticInvestor" type = "IncomingMessage" >
    < name of field = "batchReference" > OPENINGBATCH000000 < / field > < List name = "data" >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < / list >
    < / message > ' double.

    Select * example;

    create table hasil1 (c1 varchar2 (500), c2 varchar2 (500), c3 varchar2 (500));

    -This step I create the procedure to insert xml data into the table as the batch.

    DECLARE
    x XmlType;
    BEGIN
    Select XML_SPEC in x for example;

    insert into hasil1
    SELECT
    p.Extract('/Record/Field/@externalReference').getstringval (C1),
    p.Extract('/Record/Field/@participantID').getstringval (C2),
    p.Extract('/Record/Field/@participantName').getstringval () as c3
    TABLE (XMLSequence (Extract(x,'Message/List/Record'))) p;
    commit;
    END;
    /

    -when the result of select hasil1, the output is back 3 rows and 3 columns, but all data is a null *.

    Best regards
    Sigcle

    You don't explain what output you need, but I guess something like this:

    SQL> insert into hasil1 (c1, c2, c3)
      2  select x.c1, x.c2, x.c3
      3  from example t
      4     , xmltable(
      5         'Message/List/Record'
      6         passing t.xml_spec
      7         columns c1 varchar2(500) path 'Field[@name="externalReference"]'
      8               , c2 varchar2(500) path 'Field[@name="participantID"]'
      9               , c3 varchar2(500) path 'Field[@name="participantName"]'
     10       ) x
     11  ;
    
    3 rows inserted
    
    SQL> select * from hasil1;
    
    C1                     C2        C3
    ---------------------- --------- --------------------------------
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
     
    
  • Export data from the forms to Excel

    Hello

    I am facing a problem with exporting data from a form to excel.

    When I go to the menu - and file-> export. The export starts then progress, then disappears.

    If I do just steps above and hold down the CTRL key... the excel opens.

    I remember there was a setting to recognize that this export goes to Excel. But have forgotten what I did to solve the problem.

    My pop Blocker is turned off.


    If anyone can help out me... that would be greatly appreciated.

    Thank you

    Hello

    In the browser, please add the URL of the application to the trusted sites list and sign the application again.

    Also, be sure that no errors are reported in the log database (no space).

    Export option in menu Apps does not work under Windows-XP OS
    Export option in menu Apps does not work under Windows-XP OS

    Export form data to Excel the FILE using file > EXPORT
    Export form data to Excel the FILE using file > EXPORT

    Kind regards
    Hussein

  • Extract data from the table on hourly basis

    Hello

    I have a table that has two columns date all the hours of the base and the response time. I want to extract data from the date corresponding previous hourly basis with the response time. The data will be loaded into the table every midnight.

    for example: today date 23/10/2012
    I want to extract data from 22/10/12 00 to the 22/10/12 23

    The sub query pulls the date as demanded, but I'm not able to take the time to answer.

    with one also
    (select min (trunc (lhour)) as mindate, max (trunc (lhour)) as AVG_HR maxdate)
    SELECT to_char (maxdate + (level/25), "dd/mm/yyyy hh24") as a LEVEL CONNECTION dates < = * (1) 24;

    Please help me on this.

    Try this

    SELECT * FROM table_nm
     WHERE to_char(hour,'DD') = to_char(SYSDATE-1,'DD')
    
  • How publish data from the table with some data loss all post in the forum

    I wonder how people are displayed the data in the table or the result of a query with losing them its format from Sqlplus display when they post in the forums of Oracle. I searched on the basis of knowledge of DB but I see no article about it. can you please help me or direct me to this link, I tried different options using code and other tags but nothing has worked, thank you for your help. Thank you.

    Edited by: Ariean October 3, 2011 12:34

    You can click on the link to the FAQ at the top right: http://wikis.sun.com/display/Forums/Forums+FAQ.

  • Export data from Oracle table to a .csv file by putting a condition on the value of a column

    Hello gurus,

    I have the following data in my table

    ROWID name version date

    1 oracle 11.1 20/12/2013

    Java 2 7 12/10/2011

    1 oracle 12.1 28/12/2013

    1 oracle 10.2 12/06/2010

    Now I need a general sql/plsql code who wrote the columns with a specific value to the rowid.

    My output should look like

    1,Oracle,11.1,12/20/2013

    1,Oracle,12.1,12/28/2013

    1,Oracle,10.2,06/12/2010

    Here, I want to pass the value as a parameter dynamically

    Can someone help me with the sql/plsql.

    Hello

    If you use the IN operator:

    Select rowid_col

    || ',' || name_col

    || ',' || version_col

    || ',' || To_char (date_col, 'HH24:MI:SS of Mon-DD-YYYY') AS csv_text

    from your_table

    where rowid_col IN (& input_values);

    then & input_values can be a unique number (e.g. 1) or a list separated by commas (for example, 1,2,3) numbers.  Don't put NO space around the comma.

  • Select this OPTION to generate XML data from the table using XMLELEMENT, XMLAGG gives error ORA-19011 string buffer too small

    My select statement fails with the error:


    The ORA-19011 string buffer too small


    The select statement looks like:


    SELECT TO_CLOB)

    XMLELEMENT ("accounts",

    XMLELEMENT ("count",

    XMLATTRIBUTES)

    rownum AS "recordId."

    To_date('20130520','YYYYMMDD') AS "datestarted."

    123456 AS "previousBatchId."

    56789 AS 'previousRecordId '.

    ),

    ....

    .... .

    .....

    XMLFOREST)

    SIG_ROLE AS "SignatoryRole."

    To_char(TRANSFER_DATE,'YYYY-mm-DD') AS "TransferDate."

    NVL(Reason,0) AS 'reason '.

    ) AS the 'transfer '.

    )

    ()) AS CRDTRPT

    OF ANY_TABLE;

    • It looks like I can choose only 4000 characters using the SELECT statement (please, correct me if I'm wrong)

    I'd use the XMLGEN package. But the environment team says no mounted drives in the future with the arrival of the EXADATA.

    NO HARD DRIVE MOUNTED, NO ACCESS TO THE DATABASE DIRECTORIES

    No UTL_FILE

    I need to use the REEL spool the resulting XML data of the SELECT query.

    SQL is a standard in my org, but I can do with a PL/SQL solution also to load data into a table (cannot use a COIL with PL/SQL)

    What I do is:

    1. a column of type CLOB to a xml_report of the loading of the above SELECT query table
    2. Then using SELECT * FROM xml_report to SPOOL the data to a file report.xml

    No need of XMLTYPE data behind. Xml data stream is fine for me.

    In addition, I need to validate the XML file, also using XSD.

    Problem is that the resulting lines of the select query are supposed to be from 15000 to 20000 bytes long.

    Oracle database version: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    A Suggestion or a solution to this problem would be appreciated.

    (Sorry for the use of "BOLD", just to make it more readable and highlight the imp points)

    Bravo!

    Rahul

    It looks like I can choose only 4000 characters using the SELECT statement (please, correct me if I'm wrong)

    You use the right method.

    There is an implicit conversion from XMLType to the data type VARCHAR2 as expected by the function TO_CLOB, where the limitation, and the error.

    To serialize XMLType to CLOB, use the XMLSerialize function:

    SELECT XMLSerialize (DOCUMENT

    XMLELEMENT ("accounts",

    ...

    )

    )

    OF ANY_TABLE;

    For the rest of the requirement, I wish you good luck trying to spool the XML correctly.

    You may need to play around with the SET LONG and SET LONGCHUNKSIZE commands to operate.

  • XML schema to generate data from the table of data from a repeating subform

    Hi all, I would like to have a check box that when checked, allows you to hide a quote form and make a purchase order form visible, carrying a part of the field of the form of citation data in a new table on the order form. I have attached to this form to https://workspaces.acrobat.com/?d=pqpsXx5VPi * LkMeVKrX57w if you want to take a look. If the check box is cleared, he hid the PO form and to make quite visible.

    The idea behind this is that my client will create his quote and send t to his client. Once the customer accepts the quote, he simply click a button to generate its purchase order send it to its supplier.

    It seems that I have buttons to add lines on the submission form that the problem is more complex. I would be able to do it myself if the table has a fixed number of lines and I was able to use global fields, and naming each cell something different, but because it's a single repeating subform, I can't operate at all.

    I understand that, because it's a repeating subform that I need to create an XML schema to do this, but also can not know for the life of me how to create the schema. I read tons of tutorials, but no idea how to apply it to my specific needs. I've been able to find only info on how to bind the data source once it's been created.

    I would be eternally grateful if someone could help out me.

    Thank you!

    I edited your form and put it here.

    Here's what I did:

    • Script inserted into your box renamed someone who mask/displays the purchase order / sales quotation
    • I have included a script object with a function I wrote to transfer data from as named fields/subforms from one section to another
    • Inserted a few fields in your table of purchase order

    What you need to do is to complete the development of your purchase order table. Make sure that the common fields between the quote and purchase tables have the same name in order to transfer data.

    No necessary schema.

    Kyle

  • How to insert the data from the table file?

    I need to know that how can I insert data into multiple columns by file. I can simply insert data into a table of columns, but could not find a way to put the data in the column all.

    My data in a file store
    ************************************************text.txt***************
    133, nanny, nagina, 14 mph, 45637, 9156729863

    **************************************************************my_data(table)**********
    try to insert into table below...

    Name, ID, last_name, add, PIN. Mob

    *********************************************

    Let me know if you need anything else... :))

    Hey nanny.

    In fact, in SQL Developer, you can open a connection to the target schema, right-click on the Tables node in the Navigator tree, select import the data, then use the data import wizard. It is extremely flexible. Looks like you have a file of comma-separated variables, so if you select Format: csv and import method: Insert it will probably work fine.

    To minimize the risk of errors during import, choose a limit value of preview so that the wizard can review the data type and the size of all columns in several lines of data as possible, and then examine the size/type of data for each column on the next page of the wizard and replace if necessary. For date columns, it is also important to choose the appropriate format mask.

    Hope this helps,
    Gary
    SQL development team

Maybe you are looking for