PL/SQLXMLgeneration

Hallo,
I am trying to generate xml from oracle. I tried through differrent approaches and i have finally ended up using XSU for PL/SQL, generating XML with DBMS_XMLQuery().
The stored procedure i am running from Application Developement SQLPlus Worksheet follows right after. I use it to generate XML from tables holding spatial polygon information as well.It works just fine for tables containing up to 30-40 records but produces not well-formed xml documents for tables whose records exceed this number.In such cases, it repeats previously extracted row tags. For example after tag <row num="41"> it goes on with <row num="30"> again, until it reaches <row num="41"> again and goes on.Does anyone have any idea about the cause of this
problem?
At first i thought it might be a memory problem so i tried increasing the shared pool size from Initialization parameters from approximately 50 MB to 100 MB, but Oracle responded with an error:applying dynamic parameters failed ORA-02097-This parameter cannot be modified because there is inneficient memory for increasing shared pool size parameter.I also tried increasing memory used by applications from performance options - virtual memory but nothing changed.It still does not accept the modification of shared pool size parameter, producing the same error.
I am working on a PC with Windows 2000, 29 Gb free hard disk and 256 ram. Can the the operating system or the computer memory be the cause??
The stored PL/SQL procedure:
(tablename varchar2)
as
queryCtx DBMS_XMLquery.ctxType;
result CLOB;
errorNum NUMBER;
errorMsg VARCHAR2(200);
PROCEDURE printClobOut(result IN OUT NOCOPY CLOB, flname IN varchar2) IS
xmlstr varchar2(32767);
line varchar2(2000);
offset number;
counter number;
flag boolean;
filename SYS.UTL_FILE.FILE_TYPE;
PROCEDURE recNgo(str IN VARCHAR2) IS
BEGIN
DBMS_OUTPUT.PUT_LINE('UTL_FILE error'||str);
UTL_FILE.FCLOSE(filename);
END;
BEGIN
filename:=SYS.UTL_FILE.FOPEN('c:\TEMP', flname, 'W');
offset:=1;
flag:=false;
loop
xmlstr:=dbms_lob.SUBSTR(result,32767,offset);
exit when xmlstr is null;
DBMS_OUTPUT.PUT_LINE(DBMS_LOB.GETLENGTH(result));
loop
exit when xmlstr is null;
line:=substr(xmlstr,1,instr(xmlstr,chr(10))-1);
if instr(xmlstr,chr(10))=0 then
line:=xmlstr;
flag:=true;
else
flag:=false;
end if;
if flag then
SYS.UTL_FILE.PUT(filename, line);
else
SYS.UTL_FILE.PUT_LINE(filename, line);
end if;
xmlstr:=substr(xmlstr,instr(xmlstr,chr(10))+1);
if flag then
xmlstr:=null;
end if;
end loop;
offset:=offset+16383;
end loop;
UTL_FILE.FCLOSE(filename);
EXCEPTION
WHEN UTL_FILE.INVALID_PATH THEN recNgo('invalid_path');
WHEN UTL_FILE.INVALID_MODE THEN recNgo('invalid_mode');
WHEN UTL_FILE.INVALID_FILEHANDLE THEN recNgo('invalid_filehandle');
WHEN UTL_FILE.INVALID_OPERATION THEN recNgo('invalid_operation');
WHEN UTL_FILE.READ_ERROR THEN recNgo('read_error');
WHEN UTL_FILE.WRITE_ERROR THEN recNgo('write_error');
WHEN UTL_FILE.INTERNAL_ERROR THEN recNgo('internal_error');
END;
begin
queryCtx:=DBMS_XMLQUERY.newContext('select * from '||tablename);
DBMS_XMLquery.setRaiseException(queryCtx, true);
DBMS_XMLquery.setRaiseNoRowsException(queryCtx, true);
result:=DBMS_XMLQUERY.getXML(queryCtx);
printClobOut(result, tablename||'.xml');
DBMS_XMLQUERY.closeContext(queryCtx);
exception
when others then
DBMS_XMLquery.getExceptionContent(queryCtx, errorNum, errorMsg);
dbms_output.put_line('Exception caught '||TO_CHAR(errorNum)||errorMsg);
end;
Is there anything wrong with the code?
Another problem that i am facing, is that i want my generated xml, to start with the xml declaration and a specific encoding. To be more specific, i need the first line of the generated xml to be like:
<?xml version="1.0" encoding="ISO-8859-7"?>
I need this in order for the greek characters to get recognised by the used parser.The problem is that i haven't found a way to produce the encoding attribute as well, through the PL/SQL procedure.Any suggestions??
Regards
Manousos
Athens

Eric, I cannot find a specific documentation reference to guarantee this, but in every sample I've run, the result has been in the native "order" of the collection if an ORDER BY clause is not specified in the query.

Similar Messages

Maybe you are looking for

  • HP c309a and HP eprint Home&Biz

    Hi all, Got a weird problem I wondered if anybody could help with. Using HP eprinthome&Biz to print from my iphone and ipad to my C309a which is connected via Ethernet cable to my wireless router. All works fine providing I connect to the SSID of the

  • Please help me to clear out my RAM......I don't know how!

    I am trying to install a new version of photoshop and it says I need at least 1GB of RAM or more before I can - I've checked my 'about this mac' bit and it says I have 768MB DDR SDRAM. What do I do to give me more memory space? Thank you for any help

  • Unable to rename partition

    I wanted to change the name of a Time Capsule and also the partition on it. I successfully changed the name of the base using Airport Utility (easy).  However, I cannot figure out how to change the partition name.  I used the mv function in Terminal

  • Memory Leaking message when run the log in page in Jdev 11.1.2

    Hi I am re design our 10g application in Jdev 11.1.2, I am using .jsf and ADF business component. at the moment, the project has only two pages. login and home page. when I run the login page, I see the message below. this is happening during the dep

  • Special Characters in the Title Editor PPro

    I'm struggling to copy and paste the special character ŵ in the title editor within P Pro CS6.  I am using a Mac and the built-in font "Eurostile".  So far I have tried copying and pasting from Text Editor and Microsoft Word.  When pasted, it becomes