Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loading xml containing single quotes

Status
Not open for further replies.

Thargy

Technical User
Nov 15, 2005
1,348
GB
Hello,

I am trying to load data into an xmltype, using sqlplus.
Since this load is part of a whole sequence of scripts, I can't jump ship half way, and use sql loader.

What I want to be able to do is load an xml schema into an xmltype field, by saying
Code:
INSERT INTO MESSAGE_DOCUMENT VALUES (1,
   XMLTYPE.createxml('blah blah blah');

However, I have hit two problems, the blah blah part is >4,000 characters (so it has to be split somehow) and it contains single quotes.

Thus, if I attempt to use replace or translate, it only works on the xml until it encounters the first single quote, and then errors.

Does anyone have any ideas as to how I can overcome this?

Regards

Tharg

Grinding away at things Oracular
 
taupirho,

I've finally cracked the problem.

The solution is:-

1 Replace all single quotes in the source with a caret(^).
2 Create a staging table with a clob datatype.
3 Insert into clob in chunks < 4,000 characters, replacing caret with single quote.
4 Update target table by making xml from the clob
5 commit and delete the clob staging table.

Job done.

Thanks for the assist.

Tharg

Grinding away at things Oracular
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top