niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Oracle
pl/sql xmltype extract and single quotes
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
Author Message
karlman
*nix forums beginner


Joined: 14 Feb 2005
Posts: 1

PostPosted: Mon Feb 14, 2005 11:23 pm    Post subject: Re: pl/sql xmltype extract and single quotes Reply with quote

Works perfectly! Thank you!
Back to top
Hexathioorthooxalate
*nix forums beginner


Joined: 31 May 2005
Posts: 36

PostPosted: Sun Feb 13, 2005 10:59 am    Post subject: Re: pl/sql xmltype extract and single quotes Reply with quote

Quote:
Is there a way to have it returned as a single quote?
Is there a way to do the same process above with XML
saved in a varchar2 field?

Have a look at the Oracle package DBMS_XMLGEN, the specific subprogram of
interest to you is CONVERT

Regards
Hex



<karlman@pacbell.net> wrote in message
news:1108192413.730948.40520@f14g2000cwb.googlegroups.com...
Quote:
I am using PL/SQL and have created a table with a column of XMLTYPE. I
am able to put XML data in it and extract it into columns in a view.

If XML that has a single quote it, the single quote itself is returned
as &apos;

Is there a way to have it returned as a single quote?

This is the code I am using.

To insert:
=====================
INSERT INTO sa_test (test_id,test_xml)
VALUES (1,
sys.xmltype.createxml('<data><fname>Joe''s</fname><lname>Cool</lname></data>'));

To extract:
=====================
SELECT
test_id,t.test_xml.extract('//fname/text()').getstringval() fname ,
t.test_xml.extract('//lname/text()').getstringval() lname
FROM sa_test t

OUTPUT
=====================
1 Joe&apos;s Cool



Second question: Is there a way to do the same process above with XML
saved in a varchar2 field?



Thank you!!!

Karl Albrecht
Back to top
karlman@pacbell.net
*nix forums beginner


Joined: 12 Feb 2005
Posts: 1

PostPosted: Sat Feb 12, 2005 6:13 am    Post subject: pl/sql xmltype extract and single quotes Reply with quote

I am using PL/SQL and have created a table with a column of XMLTYPE. I
am able to put XML data in it and extract it into columns in a view.

If XML that has a single quote it, the single quote itself is returned
as &apos;

Is there a way to have it returned as a single quote?

This is the code I am using.

To insert:
=====================
INSERT INTO sa_test (test_id,test_xml)
VALUES (1,
sys.xmltype.createxml('<data><fname>Joe''s</fname><lname>Cool</lname></data>'));

To extract:
=====================
SELECT
test_id,t.test_xml.extract('//fname/text()').getstringval() fname ,
t.test_xml.extract('//lname/text()').getstringval() lname
FROM sa_test t

OUTPUT
=====================
1 Joe&apos;s Cool



Second question: Is there a way to do the same process above with XML
saved in a varchar2 field?



Thank you!!!

Karl Albrecht
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 3:45 am | All times are GMT
navigation Forum index » Databases » Oracle
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts database Share Memory Limit (2 GB ) in a Instance is tota... sadanjan@gmail.com IBM DB2 0 Fri Jul 21, 2006 12:57 pm
No new posts Single Bit Error Correction & Double Eror Detection using... Hari C 3 Fri Jul 21, 2006 11:43 am
No new posts FAQ 4.34 How do I extract selected columns from a string? PerlFAQ Server Perl 0 Fri Jul 21, 2006 7:03 am
No new posts determine pointer to point to array or single item during... yancheng.cheok@gmail.com C++ 5 Fri Jul 21, 2006 1:17 am
No new posts how to run qmail on two ips in a single server anu bhaskar Qmail 6 Thu Jul 20, 2006 9:13 am

Problem Mortgage | Hacker | Salvage cars | Hacker | Mortgages
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1425s ][ Queries: 20 (0.0658s) ][ GZIP on - Debug on ]