Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Posts
    3

    Question Unanswered: creating a xml file in PL/SQL

    hi
    i'm new to sql and especially to this xml stuff and i'm just in trouble creating a xml file.
    i've got a working function which generates me a CLOB variable:

    CREATE OR REPLACE FUNCTION createXML(plateCode IN STRING) RETURN clob IS
    queryCtx dbms_xmlquery.ctxType;
    result clob;
    BEGIN
    queryCtx := dbms_xmlquery.newContext('select * from table where id = 32');
    result := dbms_xmlquery.getXml(queryCtx);
    return result;
    END createXML;

    now i need to put the result into a xml file. how do i do that? where is it stored?

    thanx
    pan

  2. #2
    Join Date
    Dec 2003
    Posts
    74
    it depends on what you want to do with the file.

    do you want to write the xml file to disk? then you would need to use utl_file.fopen to write the file to disk

  3. #3
    Join Date
    Dec 2003
    Posts
    3

    Talking

    thx, that answer came realy fast
    can you give me an example plz?

    and yes i want to save the file on my harddrive => c:\temp\result.xml
    or so

    greetz
    pan

  4. #4
    Join Date
    Dec 2003
    Posts
    74
    this should do the trick for you

    declare
    file utl_file.file_type;
    begin

    file := utl_file.fopen ('C:\','flatfile','w'); -- W MEAN WRITE

    /*the directory you are writing to has to be listed in the init.ora file UTL_FILE_DIR. You can only write to the disk the database is on. This parameter can be "*" for all the directories on that disk */

    if ( utl_file.is_open(file) ) then
    utl_file.put_line (file, 'write to file');
    utl_file.fflush (file);
    utl_file.fclose (file);
    end if;

    end;
    Last edited by edwinjames; 12-18-03 at 11:52.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •