Solved

Can I covert XML data type to varchar

Posted on 2011-09-05
3
1,127 Views
Last Modified: 2012-05-12
Hi All,
Can I convert XML data type from table to varchar, by recreating table.
I tried with following commands,
EXPORT TO ABC.ixf' OF ixf select * from ABC
drop table ABC;
Create table ABC with Varchar column.
LOAD CLIENT FROM ABC.ixf' of ixf insert into ABC;

But While loading I m getting error as
SQL3088N  The source column specified to be loaded into database column "1" is not compatible with the database column, but the database column is not nullable.

Please advise me about Is it possible to convert XML to varchar.
0
Comment
Question by:harsha_james
  • 2
3 Comments
 
LVL 37

Accepted Solution

by:
momi_sabag earned 500 total points
Comment Utility
how about trying

create table abc2 (col varchar(...))

insert into abc2
select cast(xml_column as varchar)
from abc

drop abc
renambe abc2 to abc
0
 

Author Comment

by:harsha_james
Comment Utility
Thanks Momi,
This trick solved my problem.
But is it safe to do this because on Production system, If XML data exceeds varchar limit i.e. 32672  chars then My insert will fail.
Thanks for your support.
0
 
LVL 37

Expert Comment

by:momi_sabag
Comment Utility
you are correct, but you wanted to convert it to varchar
run a test with an xml longer than 32672 and see what happens
you can either try to cast it to clob, or break it to several varchar values or just truncate after the first 32672 bytes
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now