CLOB extraction [message #608865] |
Tue, 25 February 2014 14:11 |
|
OraFaq13
Messages: 14 Registered: May 2013
|
Junior Member |
|
|
CREATE TABLE "DEV"."clob_test"
(
"id" NUMBER NOT NULL ENABLE,
"clob_val" CLOB,
CONSTRAINT "CLOB_TEST_PK" PRIMARY KEY ("id")
);
The clob_val column will have value like given below and we wanted to extract the FIELD, OLD_VALUE, NEW_VALUE tag values and stored them in a different table.
"(CLOB) {
"MODIFIED_DATA" : [{
"FIELD" : "END DATE",
"OLD_VALUE" : "",
"NEW_VALUE" : "11/22/2013"
}, {
"FIELD" : "ADDRESS LINE 1",
"OLD_VALUE" : "35606 CRESTVIEW DR",
"NEW_VALUE" : "35606 CRESTVIEW APT 222"
}, {
"FIELD" : "CITY",
"OLD_VALUE" : "YUCAIPA",
"NEW_VALUE" : "RANCHO CORDOVA"
}, {
"FIELD" : "ZIP CODE",
"OLD_VALUE" : "92399",
"NEW_VALUE" : "95670"
}
], {
"BUTTON" : "SAVE AND RETURN BUTTON"
}
}"
Its not going to get stored as XML tags so not sure how to extract those tag values. Any help would be appreciated.
PS: Version info
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
"CORE 11.2.0.1.0 Production"
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
|
|
|
|
|
Re: CLOB extraction [message #608868 is a reply to message #608865] |
Tue, 25 February 2014 14:59 |
|
Michel Cadot
Messages: 68645 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
It is not XML but JSON.
I don't there is a built-in PL/SQL package for this but it is not hard to create one (check what has be done for XML functions in Oracle).
I also think there is some chance you find some (PL/SQL or not PL/SQL) ones in the web, and if it is in Java you can embed it into the DB.
[Updated on: Tue, 25 February 2014 15:00] Report message to a moderator
|
|
|
|
Re: CLOB extraction [message #608871 is a reply to message #608869] |
Tue, 25 February 2014 17:23 |
|
BlackSwan
Messages: 26766 Registered: January 2009 Location: SoCal
|
Senior Member |
|
|
I am not sure what your problem is.
1 declare
2 vclob clob := '1234567890abcdefghijklnopqrstuvwxyz';
3 begin
4 dbms_output.enable(31000);
5 dbms_output.put_line(substr(vclob,1,10)|| ' --- ' || substr(vclob,11,12));
6* end;
SQL> /
1234567890 --- abcdefghijkl
PL/SQL procedure successfully completed.
|
|
|