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

  • Reporting doesn't show the newly installed SCOM Agents

    Hello, I am running SCOM 2012 SP1 on Win2008 R2. I recently deployed scom agent to couple of machines the agents are showing up healthy and i can see the performance and health data from Monitoring tab but when i try to run report i can't find these

  • Portege 3440 CT - need driver for external CD-ROM

    Hello I have installed windows xp + sp2 on Portege 3440ct and PCMCIA card where is connect CD-rom is not recognized. I can't find driver here, anyone can help me? Thanks

  • [solved] Best Practice for SSDs with crypto on it regarding TRIM

    Hi, I was doing some research on this matter but did not find too much information on that that's more useful than confusing. The setup is the following: I have an SSD (Crucial, Marvell-Controller) with two partitions: a small one for /boot and a big

  • Group by - sub query

    A table has three columns - id (primary key), categoryID (numeric) and amount (numeric). The goal is to provide a query that would show categoryID and sum of amounts within that category where categoryID is an odd number and sum of amounts is greater

  • 6gb use from 8gb upgrade

    On the 2010 model macbook pro, only 6gb of the 8gb ram upgrade were useable. Is this the same case with the 2011 model?