Discussion Locked

Inserting XML into an Oracle DB with SQL

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
In a current project I have a requirment to store a XML file in an Oracle database. The problem I have is that I need to go through a Third Party software that only allows me to execute a SQL statment. Can a XML file be inserted through an SQL statment?

5 replies

by tg_willis

You can do. You could probably store it in a big varchar field(XML is just text right?) Some of the problems you might run into are with characters that potentially interfere with SQL syntax like quotes etc... So you may need to do a little experimenting to come up with an algorithm to process the xml replacing those characters in the XML with those that do not interfere with the SQL syntax. Of course, depending on how you process the xml when storing, you may have to reverse it before you loadit into a DOM.

If I could offer another suggestion, you may want to look at what benefits you expect from having XML stored in the DB. I went down the same path for a project and I came to the conclusion that having XML stored in a column in a DBsounds cool, probably looks cool on a resume, but doesn't really offer any benefits other than securing the XML under the same scheme that the DB is secured. Other than that, doing so may bring about other challenges.

Hope this helps, let me know if you need more clarification.

Tom Willis

by gckirksey

XML file is too big to store in a big varchar and I need to store it in a database to freeze the data for a point in time. Then it will be accessed by another application that only get to a database thus storing on a physical drive not an option.

by tg_willis

I don't know how to post a comment as the site suggests. So, I'll just post another answer.

If the XML file is going to be too big for the Varchar field to handle(which wasn't mentioned in the question) then, I would guess it is not possible to insert it with straight SQL due the limitations on the driver on the client side. I could be wrong.

It sounds like you have a hard requirement to deal with. I'd be curious to know if anyone else has had this problem and what they did to solve it.

by gckirksey

Thanks for the input. I have read on the Oracle site that this is possible with their drivers and a CLOB record type. For now I get my own ADO connection and AppendChunck. Thanks for the suggestion of the big varchar because I did not relize my file has the potential to be too big until I Tested. I will let you know if I get a response.

This discussion is closed to new replies.