Xml in a clob
I'm currently storing xml in a clob datatype using Intermedia Text. The main purpose for this is because the information is variable, sometimes 5 fields sometimes 10. My problem is that I can't run queries against the data because the sections (indexes) must be built ahead of time and because the data is variable 1 set of sections won't work. Any and all ideas are appreciated.
Have you tried using the AUTO_SECTION_GROUP?
Similar Messages
-
Parse a xml file from clob column.
Dear,
i have been suffreing a problem about xml.
i have a table with two columns, one is bfile data type other is clob data type. A xml data is stored into both cloumns
as clob and bfile. My xml data format is correct.
when i took xml data from bfile column, then dbms_xmlparser.parseClob successfully parse my xml data.
Code below:
=======================================
dbms_lob.createtemporary(l_clob, cache=>FALSE);
dbms_lob.loadFromFile(dest_lob => l_clob,
src_lob => l_bfile,
amount => dbms_lob.getLength(l_bfile));
l_parser := dbms_xmlparser.newParser;
dbms_xmlparser.parseClob(l_parser, l_clob); ========================================
But when i took xml data form clob clumn directly, then dbms_xmlparser.parseClob parse failed and go to exception.
Code below:
====================================================================
dbms_lob.createtemporary(l_clob, cache=>FALSE);
select xml_cfile,xml_bfile
into l_clob ,l_bfile
from xml_load_in
l_parser := dbms_xmlparser.newParser;
dbms_xmlparser.parseClob(l_parser, l_clob); --failed parse
====================================================================
declare
l_bfile BFILE;
l_clob CLOB;
l_parser dbms_xmlparser.Parser;
l_doc dbms_xmldom.DOMDocument;
begin
dbms_lob.createtemporary(l_clob, cache=>FALSE);
select xml_cfile,xml_bfile
into l_clob ,l_bfile
from xml_load_in
l_parser := dbms_xmlparser.newParser;
dbms_xmlparser.parseClob(l_parser, l_clob);
l_doc := dbms_xmlparser.getDocument(l_parser);
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
exception
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
dbms_xmldom.freeDocument(l_doc);
End;
Example:
======--File_name := Outward.xml;
CREATE OR REPLACE DIRECTORY
MY_INWARD AS
'D:\PBM\Inward\';
CREATE TABLE XML_LOAD_IN
( XML_CFILE CLOB,
XML_BFILE BFILE
INSERT INTO XML_LOAD_IN ( XML_CFILE, XML_BFILE )
VALUES (
'<?xml version="1.0" encoding="UTF-8"?>
<BACPSInterface>
<OCE>
<EHR>
<StandardLevel>03</StandardLevel>
<TestFiledIndicator>T</TestFiledIndicator>
<ImmediateDestRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</ImmediateDestRoutingNumber>
<ImmediateOriginRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</ImmediateOriginRoutingNumber>
<FileCreationDate>20090714</FileCreationDate>
<FileCreationTime>1047</FileCreationTime>
<ResendIndicator>N</ResendIndicator>
<ECESettlementDate>20090714</ECESettlementDate>
<ECESessionTime>1047</ECESessionTime>
<ECESettlementTime>1047</ECESettlementTime>
<ECEtype>01</ECEtype>
<CountryCode>BD</CountryCode>
</EHR>
<Collection>
<CHR>
<CashLetterBusinessDate>20090714</CashLetterBusinessDate>
<CashLetterCreationDate>20090714</CashLetterCreationDate>
<CashLetterCreationTime>1047</CashLetterCreationTime>
<CashLetterRecordTypeInd>I</CashLetterRecordTypeInd>
<CashLetterDocTypeIndicator>G</CashLetterDocTypeIndicator>
<CashLetterID>1</CashLetterID>
<OriginatorContactName>Bank Asia</OriginatorContactName>
<OriginatorContactPhoneNumber>XXX</OriginatorContactPhoneNumber>
</CHR>
<ForwardBundle>
<BHR>
<CollectionTypeIndicator>I</CollectionTypeIndicator>
<DestRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</DestRoutingNumber>
<ECEInstitutionRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</ECEInstitutionRoutingNumber>
<BundleBusinessDate>20090714</BundleBusinessDate>
<BundleCreationDate>20090714</BundleCreationDate>
<BundleID>1</BundleID>
<ReturnLocationRoutingNumber>070127538</ReturnLocationRoutingNumber>
</BHR>
<CDR>
<CDR num="1">
<ECESettlementDate>20090714</ECESettlementDate>
<ECESessionTime>1047</ECESessionTime>
<ECESettlementTime>1047</ECESettlementTime>
<ECEItemType>N</ECEItemType>
<IssuingBranchRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</IssuingBranchRoutingNumber>
<AccountNumber>0000334008221</AccountNumber>
<ChequeSequenceNumber>1601735</ChequeSequenceNumber>
<ItemAmount>500</ItemAmount>
<ECEInstitutionItemSequencNum>0701275380000001</ECEInstitutionItemSequencNum>
<DocumentationTypeIndicator>I</DocumentationTypeIndicator>
<ReturnAcceptanceIndicator>6</ReturnAcceptanceIndicator>
<MICRValidIndicator>1</MICRValidIndicator>
<BOFDIndicator>Y</BOFDIndicator>
<ChequeDetailRecAddendumCount>0</ChequeDetailRecAddendumCount>
<CorrectionIndicator>0</CorrectionIndicator>
<RepresentmentIndicator>0</RepresentmentIndicator>
<ArchiveTypeIndicator>F</ArchiveTypeIndicator>
</CDR>
<CDR num="2">
<ECESettlementDate>20090714</ECESettlementDate>
<ECESessionTime>1047</ECESessionTime>
<ECESettlementTime>1047</ECESettlementTime>
<ECEItemType>N</ECEItemType>
<IssuingBranchRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</IssuingBranchRoutingNumber>
<AccountNumber>0000345682256</AccountNumber>
<ChequeSequenceNumber>1234567</ChequeSequenceNumber>
<ItemAmount>1000</ItemAmount>
<ECEInstitutionItemSequencNum>0701275380000002</ECEInstitutionItemSequencNum>
<DocumentationTypeIndicator>I</DocumentationTypeIndicator>
<ReturnAcceptanceIndicator>6</ReturnAcceptanceIndicator>
<MICRValidIndicator>1</MICRValidIndicator>
<BOFDIndicator>Y</BOFDIndicator>
<ChequeDetailRecAddendumCount>0</ChequeDetailRecAddendumCount>
<CorrectionIndicator>0</CorrectionIndicator>
<RepresentmentIndicator>0</RepresentmentIndicator>
<ArchiveTypeIndicator>F</ArchiveTypeIndicator>
</CDR>
</CDR>
<CDA>
<CDA num="1">
<AddendumRecordNumber>1</AddendumRecordNumber>
<BOFDRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>75</DistrictCode>
<BranchCode>12</BranchCode>
<CheckDigit>8</CheckDigit>
</BOFDRoutingNumber>
<BOFDBusinessEndorsementDate>20090714</BOFDBusinessEndorsementDate>
<BOFDDepositAccountNumber>0000334008221</BOFDDepositAccountNumber>
<BOFDDepositBranch>753</BOFDDepositBranch>
<PayeeName>XXX</PayeeName>
<TruncationIndicator>Y</TruncationIndicator>
<BOFDConversionIndicator>2</BOFDConversionIndicator>
<BOFDCorrectionIndicator>0</BOFDCorrectionIndicator>
</CDA>
<CDA num="2">
<AddendumRecordNumber>1</AddendumRecordNumber>
<BOFDRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>75</DistrictCode>
<BranchCode>12</BranchCode>
<CheckDigit>8</CheckDigit>
</BOFDRoutingNumber>
<BOFDBusinessEndorsementDate>20090714</BOFDBusinessEndorsementDate>
<BOFDDepositAccountNumber>0000345682256</BOFDDepositAccountNumber>
<BOFDDepositBranch>753</BOFDDepositBranch>
<PayeeName>XXX</PayeeName>
<TruncationIndicator>Y</TruncationIndicator>
<BOFDConversionIndicator>2</BOFDConversionIndicator>
<BOFDCorrectionIndicator>0</BOFDCorrectionIndicator>
</CDA>
</CDA>
<CDC>
<CDC num="1">
<AddendumCRecordNumber>1</AddendumCRecordNumber>
<EndorsingBankRountingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</EndorsingBankRountingNumber>
<EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
<EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
<EndorsingBankItemSequenceNum>0701275380000001</EndorsingBankItemSequenceNum>
<TruncationIndicator>Y</TruncationIndicator>
<EndorsingBankConversionInd>2</EndorsingBankConversionInd>
<EndorsingBankCorrectionInd>0</EndorsingBankCorrectionInd>
</CDC>
<CDC num="2">
<AddendumCRecordNumber>1</AddendumCRecordNumber>
<EndorsingBankRountingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</EndorsingBankRountingNumber>
<EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
<EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
<EndorsingBankItemSequenceNum>0701275380000002</EndorsingBankItemSequenceNum>
<TruncationIndicator>Y</TruncationIndicator>
<EndorsingBankConversionInd>2</EndorsingBankConversionInd>
<EndorsingBankCorrectionInd>0</EndorsingBankCorrectionInd>
</CDC>
</CDC>
<IVD>
<IVD num="1">
<ImageIndicator>1</ImageIndicator>
<ImageCreatorRountingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</ImageCreatorRountingNumber>
<ImageCreatorDate>20090714</ImageCreatorDate>
<ImageViewFormatIndicator>0</ImageViewFormatIndicator>
<ImageViewCompressionAlg>0</ImageViewCompressionAlg>
<ViewSideIndicator>0</ViewSideIndicator>
<ViewDescriptor>0</ViewDescriptor>
<DigitalSignatureIndicator>1</DigitalSignatureIndicator>
<DigitalSignatureMethod>0</DigitalSignatureMethod>
<SecurityKeySize>12235</SecurityKeySize>
<ImageRecreateIndicator>0</ImageRecreateIndicator>
</IVD>
<IVD num="2">
<ImageIndicator>1</ImageIndicator>
<ImageCreatorRountingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</ImageCreatorRountingNumber>
<ImageCreatorDate>20090714</ImageCreatorDate>
<ImageViewFormatIndicator>0</ImageViewFormatIndicator>
<ImageViewCompressionAlg>0</ImageViewCompressionAlg>
<ViewSideIndicator>0</ViewSideIndicator>
<ViewDescriptor>0</ViewDescriptor>
<DigitalSignatureIndicator>1</DigitalSignatureIndicator>
<DigitalSignatureMethod>0</DigitalSignatureMethod>
<SecurityKeySize>12235</SecurityKeySize>
<ImageRecreateIndicator>0</ImageRecreateIndicator>
</IVD>
</IVD>
<IVT>
<IVT num="1">
<ECEInstitutionRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</ECEInstitutionRoutingNumber>
<BundleBusinessDate>20090714</BundleBusinessDate>
<CycleNumber>0</CycleNumber>
<ECEInstitutionItemSeqNumber>0701275380000001</ECEInstitutionItemSeqNumber>
<ClippingOrigin>
<Origin>0</Origin>
<CoordinateH1>0000</CoordinateH1>
<CoordinateH2>0000</CoordinateH2>
<CoordinateV1>0000</CoordinateV1>
<CoordinateV2>0000</CoordinateV2>
</ClippingOrigin>
<LengthofImageReferenceKey>0</LengthofImageReferenceKey>
<LengthofDigitalSignature>0</LengthofDigitalSignature>
<LengthofImageData>1</LengthofImageData>
<OffsetToImageData>01001000</OffsetToImageData>
</IVT>
<IVT num="2">
<ECEInstitutionRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</ECEInstitutionRoutingNumber>
<BundleBusinessDate>20090714</BundleBusinessDate>
<CycleNumber>0</CycleNumber>
<ECEInstitutionItemSeqNumber>0701275380000002</ECEInstitutionItemSeqNumber>
<ClippingOrigin>
<Origin>0</Origin>
<CoordinateH1>0000</CoordinateH1>
<CoordinateH2>0000</CoordinateH2>
<CoordinateV1>0000</CoordinateV1>
<CoordinateV2>0000</CoordinateV2>
</ClippingOrigin>
<LengthofImageReferenceKey>0</LengthofImageReferenceKey>
<LengthofDigitalSignature>0</LengthofDigitalSignature>
<LengthofImageData>1</LengthofImageData>
<OffsetToImageData>01001000</OffsetToImageData>
</IVT>
</IVT>
<IVA>
<IVA num="1">
<GlobalImageQuality>0</GlobalImageQuality>
<GlobalImageUsability>1</GlobalImageUsability>
<ImagingBankSpecificTest>1</ImagingBankSpecificTest>
</IVA>
<IVA num="2">
<GlobalImageQuality>0</GlobalImageQuality>
<GlobalImageUsability>1</GlobalImageUsability>
<ImagingBankSpecificTest>1</ImagingBankSpecificTest>
</IVA>
</IVA>
<BCR>
<ItemsWithinBundleCount>2</ItemsWithinBundleCount>
<BundleTotalAmount>1500</BundleTotalAmount>
<MICRValidTotalAmount>1500</MICRValidTotalAmount>
</BCR>
</ForwardBundle>
<CCR>
<BundleCount>1</BundleCount>
<ItemWithinCashLetterCount>2</ItemWithinCashLetterCount>
<CashLetterTotalAmount>1500</CashLetterTotalAmount>
<ImagesWithinCashLetterCount>2</ImagesWithinCashLetterCount>
<ECEInstitutionName>Bank Asia</ECEInstitutionName>
<SettlementDate>20090714</SettlementDate>
</CCR>
</Collection>
<ECR>
<CashLetterCount>1</CashLetterCount>
<TotalRecordCount>2</TotalRecordCount>
<TotalItemCount>2</TotalItemCount>
<FileTotalAmount>1500</FileTotalAmount>
<ImmediateOriginContactName>Bank Asia</ImmediateOriginContactName>
<ImmediateOriginContactNumber>XXX</ImmediateOriginContactNumber>
</ECR>
</OCE>
</BACPSInterface>'
, BFILENAME('MY_INWARD','Outward.xml'));
COMMIT;What version of Oracle (4 digits) and what is the error?
This runs without error on 10.2.0.4 (though you can go directly from a CLOB to a DOMDocument via dbms_xmldom)
-- Created on 9/14/2009 by JH20567
declare
-- Local variables here
l_clob CLOB;
l_parser dbms_xmlparser.Parser;
l_doc dbms_xmldom.DOMDocument;
begin
-- Test statements here
l_clob := '<?xml version="1.0" encoding="UTF-8"?>
<BACPSInterface>
<OCE>
<EHR>
<StandardLevel>03</StandardLevel>
<TestFiledIndicator>T</TestFiledIndicator>
<ImmediateDestRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</ImmediateDestRoutingNumber>
<ImmediateOriginRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</ImmediateOriginRoutingNumber>
<FileCreationDate>20090714</FileCreationDate>
<FileCreationTime>1047</FileCreationTime>
<ResendIndicator>N</ResendIndicator>
<ECESettlementDate>20090714</ECESettlementDate>
<ECESessionTime>1047</ECESessionTime>
<ECESettlementTime>1047</ECESettlementTime>
<ECEtype>01</ECEtype>
<CountryCode>BD</CountryCode>
</EHR>
<Collection>
<CHR>
<CashLetterBusinessDate>20090714</CashLetterBusinessDate>
<CashLetterCreationDate>20090714</CashLetterCreationDate>
<CashLetterCreationTime>1047</CashLetterCreationTime>
<CashLetterRecordTypeInd>I</CashLetterRecordTypeInd>
<CashLetterDocTypeIndicator>G</CashLetterDocTypeIndicator>
<CashLetterID>1</CashLetterID>
<OriginatorContactName>Bank Asia</OriginatorContactName>
<OriginatorContactPhoneNumber>XXX</OriginatorContactPhoneNumber>
</CHR>
<ForwardBundle>
<BHR>
<CollectionTypeIndicator>I</CollectionTypeIndicator>
<DestRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</DestRoutingNumber>
<ECEInstitutionRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</ECEInstitutionRoutingNumber>
<BundleBusinessDate>20090714</BundleBusinessDate>
<BundleCreationDate>20090714</BundleCreationDate>
<BundleID>1</BundleID>
<ReturnLocationRoutingNumber>070127538</ReturnLocationRoutingNumber>
</BHR>
<CDR>
<CDR num="1">
<ECESettlementDate>20090714</ECESettlementDate>
<ECESessionTime>1047</ECESessionTime>
<ECESettlementTime>1047</ECESettlementTime>
<ECEItemType>N</ECEItemType>
<IssuingBranchRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</IssuingBranchRoutingNumber>
<AccountNumber>0000334008221</AccountNumber>
<ChequeSequenceNumber>1601735</ChequeSequenceNumber>
<ItemAmount>500</ItemAmount>
<ECEInstitutionItemSequencNum>0701275380000001</ECEInstitutionItemSequencNum>
<DocumentationTypeIndicator>I</DocumentationTypeIndicator>
<ReturnAcceptanceIndicator>6</ReturnAcceptanceIndicator>
<MICRValidIndicator>1</MICRValidIndicator>
<BOFDIndicator>Y</BOFDIndicator>
<ChequeDetailRecAddendumCount>0</ChequeDetailRecAddendumCount>
<CorrectionIndicator>0</CorrectionIndicator>
<RepresentmentIndicator>0</RepresentmentIndicator>
<ArchiveTypeIndicator>F</ArchiveTypeIndicator>
</CDR>
<CDR num="2">
<ECESettlementDate>20090714</ECESettlementDate>
<ECESessionTime>1047</ECESessionTime>
<ECESettlementTime>1047</ECESettlementTime>
<ECEItemType>N</ECEItemType>
<IssuingBranchRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</IssuingBranchRoutingNumber>
<AccountNumber>0000345682256</AccountNumber>
<ChequeSequenceNumber>1234567</ChequeSequenceNumber>
<ItemAmount>1000</ItemAmount>
<ECEInstitutionItemSequencNum>0701275380000002</ECEInstitutionItemSequencNum>
<DocumentationTypeIndicator>I</DocumentationTypeIndicator>
<ReturnAcceptanceIndicator>6</ReturnAcceptanceIndicator>
<MICRValidIndicator>1</MICRValidIndicator>
<BOFDIndicator>Y</BOFDIndicator>
<ChequeDetailRecAddendumCount>0</ChequeDetailRecAddendumCount>
<CorrectionIndicator>0</CorrectionIndicator>
<RepresentmentIndicator>0</RepresentmentIndicator>
<ArchiveTypeIndicator>F</ArchiveTypeIndicator>
</CDR>
</CDR>
<CDA>
<CDA num="1">
<AddendumRecordNumber>1</AddendumRecordNumber>
<BOFDRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>75</DistrictCode>
<BranchCode>12</BranchCode>
<CheckDigit>8</CheckDigit>
</BOFDRoutingNumber>
<BOFDBusinessEndorsementDate>20090714</BOFDBusinessEndorsementDate>
<BOFDDepositAccountNumber>0000334008221</BOFDDepositAccountNumber>
<BOFDDepositBranch>753</BOFDDepositBranch>
<PayeeName>XXX</PayeeName>
<TruncationIndicator>Y</TruncationIndicator>
<BOFDConversionIndicator>2</BOFDConversionIndicator>
<BOFDCorrectionIndicator>0</BOFDCorrectionIndicator>
</CDA>
<CDA num="2">
<AddendumRecordNumber>1</AddendumRecordNumber>
<BOFDRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>75</DistrictCode>
<BranchCode>12</BranchCode>
<CheckDigit>8</CheckDigit>
</BOFDRoutingNumber>
<BOFDBusinessEndorsementDate>20090714</BOFDBusinessEndorsementDate>
<BOFDDepositAccountNumber>0000345682256</BOFDDepositAccountNumber>
<BOFDDepositBranch>753</BOFDDepositBranch>
<PayeeName>XXX</PayeeName>
<TruncationIndicator>Y</TruncationIndicator>
<BOFDConversionIndicator>2</BOFDConversionIndicator>
<BOFDCorrectionIndicator>0</BOFDCorrectionIndicator>
</CDA>
</CDA>
<CDC>
<CDC num="1">
<AddendumCRecordNumber>1</AddendumCRecordNumber>
<EndorsingBankRountingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</EndorsingBankRountingNumber>
<EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
<EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
<EndorsingBankItemSequenceNum>0701275380000001</EndorsingBankItemSequenceNum>
<TruncationIndicator>Y</TruncationIndicator>
<EndorsingBankConversionInd>2</EndorsingBankConversionInd>
<EndorsingBankCorrectionInd>0</EndorsingBankCorrectionInd>
</CDC>
<CDC num="2">
<AddendumCRecordNumber>1</AddendumCRecordNumber>
<EndorsingBankRountingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</EndorsingBankRountingNumber>
<EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
<EndorsingBankEndorsementDate>20090714</EndorsingBankEndorsementDate>
<EndorsingBankItemSequenceNum>0701275380000002</EndorsingBankItemSequenceNum>
<TruncationIndicator>Y</TruncationIndicator>
<EndorsingBankConversionInd>2</EndorsingBankConversionInd>
<EndorsingBankCorrectionInd>0</EndorsingBankCorrectionInd>
</CDC>
</CDC>
<IVD>
<IVD num="1">
<ImageIndicator>1</ImageIndicator>
<ImageCreatorRountingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</ImageCreatorRountingNumber>
<ImageCreatorDate>20090714</ImageCreatorDate>
<ImageViewFormatIndicator>0</ImageViewFormatIndicator>
<ImageViewCompressionAlg>0</ImageViewCompressionAlg>
<ViewSideIndicator>0</ViewSideIndicator>
<ViewDescriptor>0</ViewDescriptor>
<DigitalSignatureIndicator>1</DigitalSignatureIndicator>
<DigitalSignatureMethod>0</DigitalSignatureMethod>
<SecurityKeySize>12235</SecurityKeySize>
<ImageRecreateIndicator>0</ImageRecreateIndicator>
</IVD>
<IVD num="2">
<ImageIndicator>1</ImageIndicator>
<ImageCreatorRountingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</ImageCreatorRountingNumber>
<ImageCreatorDate>20090714</ImageCreatorDate>
<ImageViewFormatIndicator>0</ImageViewFormatIndicator>
<ImageViewCompressionAlg>0</ImageViewCompressionAlg>
<ViewSideIndicator>0</ViewSideIndicator>
<ViewDescriptor>0</ViewDescriptor>
<DigitalSignatureIndicator>1</DigitalSignatureIndicator>
<DigitalSignatureMethod>0</DigitalSignatureMethod>
<SecurityKeySize>12235</SecurityKeySize>
<ImageRecreateIndicator>0</ImageRecreateIndicator>
</IVD>
</IVD>
<IVT>
<IVT num="1">
<ECEInstitutionRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</ECEInstitutionRoutingNumber>
<BundleBusinessDate>20090714</BundleBusinessDate>
<CycleNumber>0</CycleNumber>
<ECEInstitutionItemSeqNumber>0701275380000001</ECEInstitutionItemSeqNumber>
<ClippingOrigin>
<Origin>0</Origin>
<CoordinateH1>0000</CoordinateH1>
<CoordinateH2>0000</CoordinateH2>
<CoordinateV1>0000</CoordinateV1>
<CoordinateV2>0000</CoordinateV2>
</ClippingOrigin>
<LengthofImageReferenceKey>0</LengthofImageReferenceKey>
<LengthofDigitalSignature>0</LengthofDigitalSignature>
<LengthofImageData>1</LengthofImageData>
<OffsetToImageData>01001000</OffsetToImageData>
</IVT>
<IVT num="2">
<ECEInstitutionRoutingNumber>
<BankCode>070</BankCode>
<DistrictCode>12</DistrictCode>
<BranchCode>75</BranchCode>
<CheckDigit>8</CheckDigit>
</ECEInstitutionRoutingNumber>
<BundleBusinessDate>20090714</BundleBusinessDate>
<CycleNumber>0</CycleNumber>
<ECEInstitutionItemSeqNumber>0701275380000002</ECEInstitutionItemSeqNumber>
<ClippingOrigin>
<Origin>0</Origin>
<CoordinateH1>0000</CoordinateH1>
<CoordinateH2>0000</CoordinateH2>
<CoordinateV1>0000</CoordinateV1>
<CoordinateV2>0000</CoordinateV2>
</ClippingOrigin>
<LengthofImageReferenceKey>0</LengthofImageReferenceKey>
<LengthofDigitalSignature>0</LengthofDigitalSignature>
<LengthofImageData>1</LengthofImageData>
<OffsetToImageData>01001000</OffsetToImageData>
</IVT>
</IVT>
<IVA>
<IVA num="1">
<GlobalImageQuality>0</GlobalImageQuality>
<GlobalImageUsability>1</GlobalImageUsability>
<ImagingBankSpecificTest>1</ImagingBankSpecificTest>
</IVA>
<IVA num="2">
<GlobalImageQuality>0</GlobalImageQuality>
<GlobalImageUsability>1</GlobalImageUsability>
<ImagingBankSpecificTest>1</ImagingBankSpecificTest>
</IVA>
</IVA>
<BCR>
<ItemsWithinBundleCount>2</ItemsWithinBundleCount>
<BundleTotalAmount>1500</BundleTotalAmount>
<MICRValidTotalAmount>1500</MICRValidTotalAmount>
</BCR>
</ForwardBundle>
<CCR>
<BundleCount>1</BundleCount>
<ItemWithinCashLetterCount>2</ItemWithinCashLetterCount>
<CashLetterTotalAmount>1500</CashLetterTotalAmount>
<ImagesWithinCashLetterCount>2</ImagesWithinCashLetterCount>
<ECEInstitutionName>Bank Asia</ECEInstitutionName>
<SettlementDate>20090714</SettlementDate>
</CCR>
</Collection>
<ECR>
<CashLetterCount>1</CashLetterCount>
<TotalRecordCount>2</TotalRecordCount>
<TotalItemCount>2</TotalItemCount>
<FileTotalAmount>1500</FileTotalAmount>
<ImmediateOriginContactName>Bank Asia</ImmediateOriginContactName>
<ImmediateOriginContactNumber>XXX</ImmediateOriginContactNumber>
</ECR>
</OCE>
</BACPSInterface>';
l_parser := dbms_xmlparser.newParser;
dbms_xmlparser.parseClob(l_parser, l_clob);
l_doc := dbms_xmlparser.getDocument(l_parser);
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
dbms_xmldom.freeDocument(l_doc);
end; -
Reading Xml file from clob column in the staging table
Hi,
I am trying to poll the staging table with the database adapter which has CLOB column type containing XML file. How do I extract the XML file from CLOB and map the fields to the another variable with definite schema.
Thanks,
Edited by: chaitu123 on Sep 20, 2009 8:16 AM1) when you create DBAdapter on a table which having the clob column watch closely the created xsd for the DBAdapter the clob cloumn element should be a String data type
2) create xsd for Xml File and create variable for the xsd element
3) use ora:parseEscapedXML("yourDBAdapterclobElement") to XmlFileVarilable
Krishna -
Xml content in CLOB in Oracle 8i
Not sure if this is the right forum. If not, please let me know where I can post this query.
We are using Oracle 8i. We have to store the content of an xml file in a CLOB field in the database. Here is the code we are using to insert xml in the CLOB:
CREATE OR REPLACE PROCEDURE test( dir VARCHAR2,
file1 VARCHAR2,
name VARCHAR2 := NULL) IS
theBFile BFILE;
theCLob CLOB;
theDocName VARCHAR2(200) := NVL(name,file1);
BEGIN
-- (1) Insert a new row into xml_documents with an empty CLOB, and
-- (2) Retrieve the empty CLOB into a variable with RETURNING..INTO
INSERT INTO xml_documents(docname,xmldoc) VALUES(theDocName,empty_clob())
RETURN xmldoc INTO theCLob;
-- (3) Get a BFile handle to the external file
theBFile := BFileName(dir,file1);
-- (4) Open the file
dbms_lob.fileOpen(theBFile);
-- (5) Copy the contents of the BFile into the empty CLOB
dbms_lob.loadFromFile(dest_lob => theCLob,
src_lob => theBFile,
amount => dbms_lob.getLength(theBFile));
-- (6) Close the file and commit
dbms_lob.fileClose(theBFile);
COMMIT;
END;
The data appears to be inserted but is corrupted. When we query the table, the field value has junk chars like inverted question marks. What could be wrong? Could it be settings on the server or are we missing something?
Please let us know. Thanks in advance.
regards,
Kameshwari.Unfortenately this forum is related to XML DB, which is the marketing namefor the native XML capabilities that were instroduced in database 9.2.x. You could try either the General database forum
General Database Discussions
or the General XML forums
General XML -
XML document in CLOB with reference to external DTD
If you place the xml document in clob using dbms_lob and the document has reference to external (system) DTD then it gives an error 'Error opening external DTD'. Whats the work around. See example below...
declare
xmlstring CLOB;
xmlstring1 CLOB;
os_file BFILE := bfilename('BFILE_DIR','family.xml');
> > > rowsp INTEGER; > > > errnum NUMBER; > > > errmsg VARCHAR2(2000);
> > > time VARCHAR2(20); > > > begin
> > > select to_char(sysdate,'MM/DD/YYYY HH24:MI:SS')
> > > into time from dual; > > > dbms_output.put_line(time);
> > > dbms_lob.createtemporary(xmlstring, true, > > > dbms_lob.session);
> > > dbms_lob.fileopen(os_file, > > dbms_lob.file_readonly);
> > > dbms_lob.loadfromfile(xmlstring, os_file,
> > > dbms_lob.getlength(os_file));
> > > select to_char(sysdate,'MM/DD/YYYY HH24:MI:SS')
> > > into time from dual; > > > dbms_output.put_line(time);
> > > xmlgen.resetOptions; > > > xmlgen.setRowTag('family');
> > > --xmlgen.setIgnoreTagCase(xmlgen.IGNORE_CASE);
> > > rowsp := xmlgen.insertXML('family',xmlString);
> > > dbms_output.put_line(' Rows processed = '| | > > > TO_CHAR(rowsp));
> > > dbms_lob.freetemporary(xmlstring);
> > > dbms_lob.fileclose(os_file); > > > commit; > > > exception
> > > when no_data_found then > > > rollback;
> > > dbms_lob.freetemporary(xmlstring);
> > > dbms_lob.fileclose(os_file); > > > errnum := abs(SQLCODE);
> > > errmsg := SQLERRM;
> > > dbms_output.put_line(errnum| |'----'| |errmsg); > > > when others then
> > > rollback; > > > dbms_lob.freetemporary(xmlstring);
> > > dbms_lob.fileclose(os_file); > > > errnum := abs(SQLCODE);
> > > errmsg := SQLERRM;
> > > dbms_output.put_line(errnum| |'----'| |errmsg); > > > end;Can be one of two problems.
One
Your database user does not have
privileges to open a socket inside
the database. This will prevent
the XML parser running inside the DB
from retrieving the DTD which it must
do to properly parse the document.
Two
you are sitting behind a corporate
firewall and need to properly set
the Proxy Server host and port to
properly retrieve the DTD.
From looking at your code it would appear
that your job can more easily be done by
using the OracleXML putXML command line
utility outside the database.
You can specify the -D options to your
JavaVM to set the System properties for
the proxy server if need be like this:
java -DproxySet=true -DproxyHost=yourproxyserver OracleXML putXML -
I was trying to check the well-formedness of XML in a CLOB. I have an xml file called Claim77804.xml. I was working on Building Oracle XML applications by Steve Muench. I created the procedure and it was created succesfully but it does not do what it says in the code:
SQL> CREATE OR REPLACE PROCEDURE CheckXMLInCLOB(c CLOB,
2 wellFormed OUT BOOLEAN,
3 error OUT VARCHAR2) IS
4 parser xmlparser.Parser;
5 xmldoc xmldom.DOMDocument;
6 XMLParseError EXCEPTION;
7
8 -- Associate the XMLParseError exception with the -20100 error code
9 PRAGMA EXCEPTION_INIT( XMLParseError, -20100 );
10
11 BEGIN
12
13 -- (1) Create a new parser
14 parser := xmlparser.newParser;
15
16 -- (2) Attempt to parse the XML document in the CLOB
17 xmlparser.ParseCLOB(parser,c);
18
19 -- (3) Free the parser.
20 xmlparser.freeParser(parser);
21
22 -- If the parse succeeds, we'll get here
23 wellFormed := TRUE;
24 EXCEPTION
25 -- If the parse fails, we'll jump here.
26 WHEN XMLParseError THEN
27 xmlparser.freeParser(parser);
28 wellFormed := FALSE;
29 error := SQLERRM;
30 END;
31
32 /
Procedure created.
Is there anything i should be doing? Please advise me.Don't worry. I have solved the question. Don't bother answering. Thanks for nothing guys.
-
Retrieve XML stored in CLOB as columns
Hi,
I have the below table that holds XML in a CLOB
CREATE TABLE testxml
(idcol NUMBER(3), xml_data CLOB
INSERT
INTO testxml VALUES
201,
<TRADE>
<TRADETYPE>SWAP</TRADETYPE>
<SUBTYPE>CDS</SUBTYPE>
<TRADEHEADER>
<ACTION>NEW</ACTION>
<SOURCEID>ABS-CD</SOURCEID>
<TRADEID>20595896</TRADEID>
</TRADEHEADER>
<TRADELEGS>
<TRADELEG>
<PAY_OR_RECEIVE>P</PAY_OR_RECEIVE>
<FIXED_FLOAT_IND>FLT</FIXED_FLOAT_IND>
<DAY_COUNT_BASIS>A365F</DAY_COUNT_BASIS>
<ORIG_PRIMARY_CURRENCY>ZAR</ORIG_PRIMARY_CURRENCY>
<FIRST_VALUE_DATE>20120511</FIRST_VALUE_DATE>
</TRADELEG>
<TRADELEG>
<PAY_OR_RECEIVE>R</PAY_OR_RECEIVE>
<FIXED_FLOAT_IND>FIX</FIXED_FLOAT_IND>
<DAY_COUNT_BASIS>A365F</DAY_COUNT_BASIS>
<ORIG_PRIMARY_CURRENCY>ZAR</ORIG_PRIMARY_CURRENCY>
<FIRST_VALUE_DATE>20120511</FIRST_VALUE_DATE>
</TRADELEG>
</TRADELEGS>
<PVS>
<PV_SOURCE>ABS-CD</PV_SOURCE>
<PV>
<NPV>0</NPV>
<NPV_CCY>ZAR</NPV_CCY>
<VALUATION_DATE>20130628</VALUATION_DATE>
<LEG_NUMBER>1</LEG_NUMBER>
</PV>
<PV>
<NPV>2214864.54</NPV>
<NPV_CCY>ZAR</NPV_CCY>
<VALUATION_DATE>20130628</VALUATION_DATE>
<LEG_NUMBER>2</LEG_NUMBER>
</PV>
</PVS>
<CREDIT_DERIVATIVES>
<CREDIT_DERIVATIVE>
<NOMINAL>100000000</NOMINAL>
<MATURITY_DATE>20170620</MATURITY_DATE>
<BUY_SELL_INDICATOR>SELL</BUY_SELL_INDICATOR>
<CURRENCY>ZAR</CURRENCY>
</CREDIT_DERIVATIVE>
<CREDIT_DERIVATIVE>
<NOMINAL>100002000</NOMINAL>
<MATURITY_DATE>20170620</MATURITY_DATE>
<BUY_SELL_INDICATOR>BUY</BUY_SELL_INDICATOR>
<CURRENCY>USD</CURRENCY>
</CREDIT_DERIVATIVE>
</CREDIT_DERIVATIVES>
</TRADE>
I need the data to be retrieved as columns. I have tried the below SQL but it works for one XMLTable i.e. TRADELEGS. But If I try to use another XMLTable for PVS then it does a cartesian join.
SELECT id,
xmltype(xml_data).extract('/TRADE/TRADETYPE/text()').getStringVal() AS TRADETYPE,
xmltype(xml_data).extract('/TRADE/SUBTYPE/text()').getStringVal() AS SUBTYPE,
xmltype(xml_data).extract('/TRADE/TRADEHEADER/ACTION/text()').getStringVal() AS ACTION,
x.PAY_OR_RECEIVE,
x.FIXED_FLOAT_IND
FROM testxml,
XMLTable( '/TRADE/TRADELEGS/TRADELEG' passing XMLTYPE(xml_data)
columns
PAY_OR_RECEIVE VARCHAR2(20) PATH 'PAY_OR_RECEIVE'
, FIXED_FLOAT_IND VARCHAR2(20) PATH 'FIXED_FLOAT_IND' ) x;
The below query does not work:
SELECT id,
xmltype(xml_data).extract('/TRADE/TRADETYPE/text()').getStringVal() AS TRADETYPE,
xmltype(xml_data).extract('/TRADE/SUBTYPE/text()').getStringVal() AS SUBTYPE,
xmltype(xml_data).extract('/TRADE/TRADEHEADER/ACTION/text()').getStringVal() AS ACTION,
tradeleg.PAY_OR_RECEIVE,
tradeleg.FIXED_FLOAT_IND
,xmltype(xml_data).extract('/TRADE/PVS/PV_SOURCE/text()').getStringVal() AS PV_SOURCE
,pvs.npv,
pvs.VALUATION_DATE
FROM testxml,
XMLTable( '/TRADE/TRADELEGS/TRADELEG' passing XMLTYPE(xml_data)
columns
PAY_OR_RECEIVE VARCHAR2(1) PATH 'PAY_OR_RECEIVE'
, FIXED_FLOAT_IND VARCHAR2(3) PATH 'FIXED_FLOAT_IND' ) tradeleg
,XMLTable( '/TRADE/PVS/PV' passing XMLTYPE(xml_data)
columns
NPV NUMBER PATH 'NPV'
, VALUATION_DATE VARCHAR2(8) PATH 'VALUATION_DATE' ) pvs
WHERE id = 1;
I need the output for TRADELEGS, PVS and CREDIT_DERIVATIVES.
Regards,
VikramBut If I try to use another XMLTable for PVS then it does a cartesian join.
Of course it does. You have to use a join condition of some kind.
What's the correlation between TRADELEGS, PVS and CREDIT_DERIVATIVES?
I guess you can relate a PV to a TRADELEG via the LEG_NUMBER, right? But what about CREDIT_DERIVATIVE to PV or to TRADELEG?
I need the output for TRADELEGS, PVS and CREDIT_DERIVATIVES.
Explain what that output should look like. -
I'm try to load xml document from CLOB in following way:
--- procedure loadXML.sql -----
CREATE OR REPLACE PROCEDURE loadXML
IS
CONTENT CLOB := ' ';
SOURCE bfile := BFILENAME('XMLFILES', 'N_95_A.xml');
begin
DBMS_LOB.OPEN(SOURCE, DBMS_LOB.LOB_READONLY);
DBMS_LOB.loadFromFile(CONTENT, SOURCE, DBMS_LOB.getLength(SOURCE));
DBMS_LOB.fileClose(SOURCE);
insert into OFERTY (OFDOCUMENT)
values (sys.XMLtype.createXML(CONTENT));
commit;
end;
and I get
SQL> @e:\myxml\loadXML
declare
ERROR at line 1:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00210: expected '<' instead of '<'
ORA-06512: at "SYS.XMLTYPE", line 0
ORA-06512: at line 1
ORA-06512: at line 8
What is wrong?Have you tried simply outputting iusing the htp.p function? for example:
/* ... inside a PL/SQL region */
declare
lclb_output clob;
begin
select doc_xml into lclb_output from mf_xml_docs where doc_id = :P1_DOC_ID;
htp.p(lclb_output); -- you may have to split this into chunks and loop through, depending on how big the clob is
end; -
Parsing XML passed as CLOBs to stored procedures
I am a newbie using XML with PL/SQL. I would like to pass XML as a CLOB to a stored procedure, parse the nodes in a loop and insert or update records. Something like this:
The xml:
<emps>
<emp>
<empno>7369</empno>
<ename>SMITH</ename>
</emp>
<emp>
<empno>7499</empno>
<ename>ALLEN</ename>
</emp>
</emps>
In the stored procedure:
CREATE update_emps( xmlCLob in CLOB )
begin
load xmlClob into parser p
nodelist = p.someMethod( '/emps/emp' )
for each node in nodelist
insert into emp( empno, ename) values ( node.empno, node.ename
end loop
cleanup
end
Any assistance you could provide would be greatly appreciated.
TIAIf the file size is not large, it seems easier to use XSLT to transform the doc and using XSU to do the updates.
-
How to retreive soap xml data from clob column in a table
Hi,
I am trying to retrieve the XML tag value from clob column.
Table name = xyz and column= abc (clob datatype)
data stored in abc column is as below
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:head="http://www.abc.com/gcgi/shared/system/header" xmlns:v6="http://www.abc.com/gcgi/services/v6_0_0_0" xmlns:sys="http://www.abc.com/gcgi/shared/system/systemtypes">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<RqHeader soapenv:mustUnderstand="0" xmlns="http://www.abc.com/gcgi/shared/system/header">
<DateAndTimeStamp>2011-12-20T16:02:36.677+08:00</DateAndTimeStamp>
<UUID>1000002932</UUID>
<Version>6_0_0_0</Version>
<ClientDetails>
<Org>ABC</Org>
<OrgUnit>ABC</OrgUnit>
<ChannelID>HBK</ChannelID>
<TerminalID>0000</TerminalID>
<SrcCountryCode>SG</SrcCountryCode>
<DestCountryCode>SG</DestCountryCode>
<UserGroup>HBK</UserGroup>
</ClientDetails>
</RqHeader>
<wsa:Action>/SvcImpl/bank/
SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq</wsa:Action></soapenv:Header>
<soapenv:Body>
<v6:AlertDeleteInqRq>
<v6:Base>
<v6:VID>20071209013112</v6:VID>
<!--Optional:-->
<v6:Ref>CTAA00000002644</v6:Ref>
</v6:Base>
</v6:AlertDeleteInqRq>
</soapenv:Body>
</soapenv:Envelope>
And i want to retrieve the values of tag
<ChannelID> and <v6:VID>
can somebody help, i have tried with extractvalue but not able to get the valuesI have used the below two queries but not able to get the expected results. Both queries result into no values.
select xmltype(MED_REQ_PAYLOAD).extract('//ClientDetails/Org','xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" || xmlns="http://www.abc.com/gcgi/shared/system/header"').getStringValue() from ESB_OUTPUT_TEMP where SOAPACTION = '/SvcImpl/bank/alerts/v6_0_0_0/SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq'
select EXTRACTVALUE(xmltype(MED_REQ_PAYLOAD),'/RqHeader/) from ESB_OUTPUT_TEMP where SOAPACTION = '/SvcImpl/bank/SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq'
Well, for starters, both queries are syntactically wrong :
- non terminated string
- incorrect namespace mapping declaration
- unknown XMLType method "getStringValue()"
Secondly, all those functions are deprecated now.
Here's an up-to-date example using XMLTable. It will retrieve the two tag values you mentioned :
SQL> select x.*
2 from esb_output_temp t
3 , xmltable(
4 xmlnamespaces(
5 'http://schemas.xmlsoap.org/soap/envelope/' as "soap"
6 , 'http://www.abc.com/gcgi/shared/system/header' as "head"
7 , 'http://www.abc.com/gcgi/services/v6_0_0_0' as "v6"
8 )
9 , '/soap:Envelope'
10 passing xmlparse(document t.med_req_payload)
11 columns ChannelID varchar2(10) path 'soap:Header/head:RqHeader/head:ClientDetails/head:ChannelID'
12 , VID varchar2(30) path 'soap:Body/v6:AlertDeleteInqRq/v6:Base/v6:VID'
13 ) x
14 ;
CHANNELID VID
HBK 20071209013112
You may also want to store XML in XMLType columns for both performance and storage optimizations. -
Filtering xml records from CLOB database column
Hi,
I have a xml data stored in a CLOB field in database.
I need to retrieve the contents that match my filter criteria.
Say my xml is like below,
<ROOT>
<EMP>
<EMP_NO>1</EMP_NO>
<SAL>100</SAL>
</EMP>
<EMP>
<EMP_NO>2</EMP_NO>
<SAL>200</SAL>
</EMP>
<EMP>
<EMP_NO>3</EMP_NO>
<SAL>300</SAL>
</EMP>
</ROOT>
I want to fetch the entire xml tree but filtered based on the SAL field, WHERE SAL>100.
So my resulting xml should be
<ROOT>
<EMP>
<EMP_NO>2</EMP_NO>
<SAL>200</SAL>
</EMP>
<EMP>
<EMP_NO>3</EMP_NO>
<SAL>300</SAL>
</EMP>
</ROOT>
I will be having 'n' number of columns, and I cant specify everything in COLUMNS clause.
I want to select all nodes, but filter based on few fields.
I tried using it as below, but I feel it took some time for it to display results.
select x.*
from emp t
, xmltable(
'/ROOT'
passing xmltype(t.doc)
columns VSAL number PATH './EMP/SAL'
, OTHER xmltype PATH '.'
) x
where x.VSAL>100
Please suggest me a solution that doesnt consume much time.
I think the problem with my query is OTHER xmltype PATH '.'
Here 'xmltype' datatype is expensive I think, because after I included that, the query took some time.
I cant hardcode the SAL value of 100 as its dynamic. So I am unable to use this method of filtering.
select x.*
from emp t
, xmltable(
'/ROOT[.//EMP/SAL>100]'
passing xmltype(t.doc)
) x
Thanks!
Edited by: Chit on Mar 24, 2012 10:12 AMHi,
I want to fetch the entire xml tree but filtered based on the SAL field, WHERE SAL>100.Then you have to rebuild the document keeping only the elements satisfying the condition (and yes, you can bind XQuery variables too) :
SQL> select xmlserialize(document x.doc as clob indent)
2 from emp t
3 , xmltable(
4 '<ROOT>
5 {
6 for $i in /ROOT/EMP
7 where $i/SAL > $minsal
8 return $i
9 }
10 </ROOT>'
11 passing xmlparse(document t.doc)
12 , 100 as "minsal"
13 columns doc xmltype path '.'
14 ) x
15 ;
XMLSERIALIZE(DOCUMENTX.DOCASCL
<ROOT>
<EMP>
<EMP_NO>2</EMP_NO>
<SAL>200</SAL>
</EMP>
<EMP>
<EMP_NO>3</EMP_NO>
<SAL>300</SAL>
</EMP>
</ROOT>
Or you can just delete the nodes you don't want :
SQL> var minsal number
SQL> exec :minsal := 100
PL/SQL procedure successfully completed
SQL> select xmlserialize(document
2 deletexml( xmlparse(document t.doc)
3 , '/ROOT/EMP[SAL<='||:minsal||']' )
4 as clob indent
5 )
6 from emp t
7 ;
XMLSERIALIZE(DOCUMENTDELETEXML
<ROOT>
<EMP>
<EMP_NO>2</EMP_NO>
<SAL>200</SAL>
</EMP>
<EMP>
<EMP_NO>3</EMP_NO>
<SAL>300</SAL>
</EMP>
</ROOT>
Please suggest me a solution that doesnt consume much time.
I think the problem with my query is OTHER xmltype PATH '.'The real problem is the CLOB text storage.
If you want performance, use binary XMLType or object-relational. -
Creating xml file and inert tin to xml file in clob column
i have a table
CREATE TABLE XMLCLOB of XMLType
XMLTYPE store AS CLOB;
now i want to create a xml file by qurying emp table ie select sal,empname from emp.
the cretaed xml file is saved in the xmlclob table how to do that?You will need to use Oracle XML function EXTRACT or EXTRACTVALUE in order to read the data before inserting into Oracle table. These functions need to be used in select statement.
Syntax:
EXTRACT(XMLType_Instance>, <XPath_string>, <namespace_string>)
EXTRACTVALUE(XMLType_Instance>, <XPath_string>, <namespace_string>) -
Newbie trying to query an XML field in Clob
I've been unsuccessfully trying to query XML data in a CLOB field today without much success.
The clob field stores approvals (Edited, Reviewed, Published) for each version.
I'm trying to get the latest version (in this case 13) and what state (name) it is at (in this case 'Reviewed')
Below is an example of the table and field with a single XML column...
desc WIKI.OS_PROPERTYENTRY
Name Null? Type
ENTITY_NAME NOT NULL VARCHAR2(125)
ENTITY_ID NOT NULL NUMBER(19)
ENTITY_KEY NOT NULL VARCHAR2(200)
KEY_TYPE NUMBER(10)
BOOLEAN_VAL NUMBER(1)
DOUBLE_VAL FLOAT(126)
STRING_VAL VARCHAR2(255)
TEXT_VAL CLOB
LONG_VAL NUMBER(19)
INT_VAL NUMBER(10)
DATE_VAL DATE
SQL> select xmltype(text_val) from wiki.os_propertyentry where entity_id = 7274716 and entity_key = 'com.comalatech.workflow.approvals';
XMLTYPE(TEXT_VAL)
<ApprovalChecks>
<ApprovalCheck>
<name>Edited</name>
<version>7</version>
<approvers>
<Approver>
<approved>true</approved>
<user>bgra030</user>
<date>2008-10-31 13:47:25.638 NZDT</date>
<comment>Initial import from Word document without change</comment>
</Approver>
</approvers>
<weight>10</weight>
<id>1</id>
<stateId>0</stateId>
<attachments/>
</ApprovalCheck>
<ApprovalCheck>
<name>Reviewed</name>
<version>7</version>
<approvers>
<Approver>
<approved>true</approved>
<user>bgra030</user>
<date>2008-10-31 13:47:30.532 NZDT</date>
<comment/>
</Approver>
</approvers>
<weight>20</weight>
<id>2</id>
<stateId>0</stateId>
<attachments/>
</ApprovalCheck>
<ApprovalCheck>
<name>Signoff</name>
<version>7</version>
<approvers>
<Approver>
<approved>true</approved>
<user>bgra030</user>
<date>2008-10-31 13:47:32.532 NZDT</date>
<comment/>
</Approver>
</approvers>
<weight>30</weight>
<id>3</id>
<stateId>0</stateId>
<attachments/>
</ApprovalCheck>
<ApprovalCheck>
<name>Edited</name>
<version>8</version>
<approvers>
<Approver>
<approved>true</approved>
<user>bgra030</user>
<date>2008-11-02 10:54:07.903 NZDT</date>
<comment>Updated references re Wiki, removed unwanted sections</comment>
</Approver>
</approvers>
<weight>10</weight>
<id>4</id>
<stateId>0</stateId>
<attachments/>
</ApprovalCheck>
<ApprovalCheck>
<name>Reviewed</name>
<version>8</version>
<approvers>
<Approver>
<approved>true</approved>
<user>bgra030</user>
<date>2008-11-02 10:54:10.552 NZDT</date>
<comment/>
</Approver>
</approvers>
<weight>20</weight>
<id>5</id>
<stateId>0</stateId>
<attachments/>
</ApprovalCheck>
<ApprovalCheck>
<name>Signoff</name>
<version>8</version>
<approvers>
<Approver>
<approved>true</approved>
<user>bgra030</user>
<date>2008-11-02 10:54:13.161 NZDT</date>
<comment/>
</Approver>
</approvers>
<weight>30</weight>
<id>6</id>
<stateId>0</stateId>
<attachments/>
</ApprovalCheck>
<ApprovalCheck>
<name>Edited</name>
<version>9</version>
<approvers>
<Approver>
<approved>true</approved>
<user>bgra030</user>
<date>2009-11-13 08:53:00.649 NZDT</date>
<comment>Testing approval information</comment>
</Approver>
</approvers>
<weight>10</weight>
<id>7</id>
<stateId>0</stateId>
<attachments/>
</ApprovalCheck>
<ApprovalCheck>
<name>Edited</name>
<version>9</version>
<approvers>
<Approver>
<approved>false</approved>
<user>bgra030</user>
<date>2009-11-13 08:53:13.830 NZDT</date>
<comment/>
</Approver>
</approvers>
<weight>10</weight>
<id>8</id>
<stateId>0</stateId>
<attachments/>
</ApprovalCheck>
<ApprovalCheck>
<name>Edited</name>
<version>12</version>
<approvers>
<Approver>
<approved>true</approved>
<user>bgra030</user>
<date>2009-11-23 11:08:14.666 NZDT</date>
<comment>Changes due to self auditing, using Study Audit Checklist and DM Study Checklist</comment>
</Approver>
</approvers>
<weight>10</weight>
<id>9</id>
<stateId>0</stateId>
<attachments/>
</ApprovalCheck>
<ApprovalCheck>
<name>Reviewed</name>
<version>12</version>
<approvers>
<Approver>
<approved>true</approved>
<user>bgra030</user>
<date>2009-11-23 11:08:20.345 NZDT</date>
<comment/>
</Approver>
</approvers>
<weight>20</weight>
<id>10</id>
<stateId>0</stateId>
<attachments/>
</ApprovalCheck>
<ApprovalCheck>
<name>Signoff</name>
<version>12</version>
<approvers>
<Approver>
<approved>true</approved>
<user>bgra030</user>
<date>2009-11-23 11:08:23.997 NZDT</date>
<comment/>
</Approver>
</approvers>
<weight>30</weight>
<id>11</id>
<stateId>0</stateId>
<attachments/>
</ApprovalCheck>
<ApprovalCheck>
<name>Edited</name>
<version>13</version>
<approvers>
<Approver>
<approved>true</approved>
<user>bgra030</user>
<date>2011-10-31 10:42:37.703 NZDT</date>
<comment>No change, just change of name of a linked page</comment>
</Approver>
</approvers>
<weight>10</weight>
<id>12</id>
<stateId>0</stateId>
<attachments/>
</ApprovalCheck>
<ApprovalCheck>
<name>Reviewed</name>
<version>13</version>
<approvers>
<Approver>
<approved>true</approved>
<user>bgra030</user>
<date>2011-10-31 10:42:40.596 NZDT</date>
<comm
1 row selected.My query is way off,... I can't even get it to run, let alone getting the record I want without some hard coding...
Can anyone help?
Thanks in advance.
select y.y_name, y.y_version, z.z_approved, z.z_user, z.z_date, z.z_comment
from WIKI.os_propertyentry t,
XMLTABLE('$p/ApprovalChecks/ApprovalCheck'
PASSING t.text_val as "p"
COLUMNS y_name VARCHAR2(30) PATH 'ApprovalCheck/name',
y_version NUMBER PATH 'ApprovalCheck/version',
Approver XMLTYPE PATH 'ApprovalCheck/approvers/Approver/*') y,
XMLTABLE('$a/Approver'
PASSING y.Approver as "a"
COLUMNS z_approved VARCHAR2(8) PATH 'Approver/approved',
z_user VARCHAR2(30) PATH 'Approver/user',
z_date DATE PATH 'Approver/date',
z_comment VARCHAR2(100) PATH 'Approver/comment') z
where entity_id = 7274716 and entity_key = 'com.comalatech.workflow.approvals'
and t.name = 'Reviewed'
and t.version = 13;
PASSING t.text_val as "p"
ERROR at line 4:
ORA-00932: inconsistent datatypes: expected - got CLOBFurther to the above, the query returns a single record okay,...
SQL > l
1 with all_versions as (
2 select c.title, y.y_name, y.y_version, z.z_approved, z.z_user, z.z_date z_date, z.z_comment,
3 row_number() over( order by to_timestamp_tz(z_date, 'YYYY-MM-DD HH24:MI:SS.FF3 TZD') desc ) as rn
4 from wiki.os_propertyentry t, wiki.content c,
5 XMLTABLE('$p/ApprovalChecks/ApprovalCheck'
6 PASSING xmltype(t.text_val) as "p"
7 COLUMNS y_name VARCHAR2(30) PATH 'name',
8 y_version NUMBER PATH 'version',
9 Approver XMLTYPE PATH 'approvers/Approver/*') y,
10 XMLTABLE('$a'
11 PASSING y.Approver as "a"
12 COLUMNS z_approved VARCHAR2(8) PATH '/approved',
13 z_user VARCHAR2(30) PATH '/user',
14 z_date VARCHAR2(30) PATH '/date',
15 z_comment VARCHAR2(100) PATH '/comment') z
16 where c.contentid = t.entity_id
17 and c.spaceid = (select spaceid from wiki.spaces where spacename = 'Quality')
18 and entity_id = 7274716
19 and entity_key = 'com.comalatech.workflow.approvals'
20 )
21 select title, y_name, y_version
22 from all_versions
23* where rn = 1
SQL> /
TITLE Y_NAME Y_VERSION
Quality Audits (NIHI-5001) Signoff 17
1 row selected.... but I want to now query on all records, not just one.
When I comment out the clause (and entity_id = xxxxx) I now get an error. I should have got ~300 records,.... what do I need to do to make this work?
SQL > 18
18* and entity_id = 7274716
SQL> > c /and/-- and
18* -- and entity_id = 7274716
SQL > l
1 with all_versions as (
2 select t.entity_id, c.title, y.y_name, y.y_version, z.z_approved, z.z_user, z.z_date z_date, z.z_comment,
3 row_number() over( order by to_timestamp_tz(z_date, 'YYYY-MM-DD HH24:MI:SS.FF3 TZD') desc ) as rn
4 from wiki.os_propertyentry t, wiki.content c,
5 XMLTABLE('$p/ApprovalChecks/ApprovalCheck'
6 PASSING xmltype(t.text_val) as "p"
7 COLUMNS y_name VARCHAR2(30) PATH 'name',
8 y_version NUMBER PATH 'version',
9 Approver XMLTYPE PATH 'approvers/Approver/*') y,
10 XMLTABLE('$a'
11 PASSING y.Approver as "a"
12 COLUMNS z_approved VARCHAR2(8) PATH '/approved',
13 z_user VARCHAR2(30) PATH '/user',
14 z_date VARCHAR2(30) PATH '/date',
15 z_comment VARCHAR2(100) PATH '/comment') z
16 where c.contentid = t.entity_id
17 and c.spaceid = (select spaceid from wiki.spaces where spacename = 'Quality')
18 -- and entity_id = 7274716
19 and entity_key = 'com.comalatech.workflow.approvals'
20 )
21 select entity_id, title, y_name, y_version
22 from all_versions
23* where rn = 1
wikiprod: OPS$IT_DBA > /
PASSING xmltype(t.text_val) as "p"
ERROR at line 6:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00241: entity reference is not well formed
Error at line 8
ORA-06512: at "SYS.XMLTYPE", line 272
ORA-06512: at line 1 -
Display XML Document from CLOB Column on page
Hi,
I have been reading all the CLOB postings that I can find, but I still cannot get my page to do what I want.
I have a very simjple table:
MF_XML_DOCS (DOC_ID NUMBER, DOC_XML CLOB)
I can populate this table OK but I am having problems getting the cotent back out. I want a simple page that takes an ID Number and displays the XML Document for that ID (select doc_xml from mf_xml_docs where doc_id = :P1_DOC_ID). Everything I try either truncates the text (or errors) at 4000 or 32767 characters or reads the XML tags as tags and does not display them. I want a simple display of the XML Document (and I don't mind if it is in an 'updateable' field or not):
<Parent>
<name>Dad</name>
<Children>
<Child>
<name>Number 1 Son</name>
</Child>
<Child>
<name>Number 2 Son</name>
</Child>
</children>
</Parent>But when I do something that works for large (32767+) documents all I see is 'Dad Number 1 Son Number 2 Son'.
Help!!
many thanks,
MartinHave you tried simply outputting iusing the htp.p function? for example:
/* ... inside a PL/SQL region */
declare
lclb_output clob;
begin
select doc_xml into lclb_output from mf_xml_docs where doc_id = :P1_DOC_ID;
htp.p(lclb_output); -- you may have to split this into chunks and loop through, depending on how big the clob is
end; -
Remove an element from XML present in CLOB column
Hi,
I need to remove element TEST2 and TEST3 from the below XML which is present in the CLOB column of a table. I need to do this using DBMS_XMLDOM package of Oracle as my existing code is using the same -
<ROOT>
<LEAF1>
<TEST1>TEXT1</TEST1>
<TEST2>TEXT2</TEST2>
<TEST3>TEXT3</TEST3>
</LEAF1>
</ROOT>
Hence the final o/p should be like
<ROOT>
<LEAF1>
<TEST1>TEXT1</TEST1>
</LEAF1>
</ROOT>
Please suggest how to achieve this.Something like this?
Anton
declare
t_doc dbms_xmldom.DOMDocument;
t_root dbms_xmldom.DOMNode;
t_node dbms_xmldom.DOMNode;
t_buf varchar2(1000);
begin
t_doc := dbms_xmldom.newDOMDocument( xmltype( '<ROOT>
<LEAF1>
<TEST1>TEXT1</TEST1>
<TEST2>TEXT2</TEST2>
<TEST3>TEXT3</TEST3>
</LEAF1>
</ROOT>' ) );
t_root := dbms_xmldom.makeNode( t_doc );
t_node := dbms_xmldom.removeChild( t_root, dbms_xslprocessor.selectSingleNode( t_root, '/ROOT/LEAF1/TEST2' ) );
t_node := dbms_xmldom.removeChild( t_root, dbms_xslprocessor.selectSingleNode( t_root, '/ROOT/LEAF1/TEST3' ) );
dbms_xmldom.writetoBuffer( t_root, t_buf );
dbms_output.put_line( t_buf );
end;
Maybe you are looking for
-
Can I use an mp3 file as one of my basic tracks in which to overdub onto?
On the iPad I will want to take existing song files (say mp3) and have them be a track in which to overdub. Is this doable and if so is the process as simple as it is on my desktop computer?
-
DVD will play on iMac, not on DVD player
I'm burning dual layer DVDs from iDVD. The DVDs won't play on my DVD player, but will play fine using the DVD player on the iMac. Anyone have any idea why?
-
Report to Display All Authorizations for User
Dear Experts, Is the any standard report or table from which we can get the full authorization details of a user. EX: User Name -> Role -> T-Codes -> Authorization Objects -> Field Values. Atleast pointing User Name -> Authorization Objects -> Field
-
We have Dashboard 'AAAAA' where all the reports to this Dashboard are coming from Shared folder 'bbbbbb' .Do i have the previlege to hide the shared folder 'bbbbbb' to all the users and give access only to Dashboard 'AAAAA'. In general users want to
-
How to authorize my new PC to DL my music on icloud?
How do I authorize my new pc to dl music on my icloud account?