Performance problems loading an XML file into oracle database

Hello ODI Guru's,
I am trying to load and XML file into the database after doing simple business validations. But the interface takes hours to complete.
1. The XML files are large in size >200 Mb. We have an XSD file for the schema definition instead of a DTD.
2. We used the external database feature for loading these files in database.
The following configuration was used in the XML Data Server:
jdbc:snps:xml?f=D:\CustomerMasterData1\CustomerMasterInitialLoad1.xml&d=D:\CustomerMasterData1\CustomerMasterInitialLoad1.xsd&re=initialLoad&s=CM&db_props=oracle&ro=true
3. Now we reverse engineer the XML files and created models using ODI Designer
4. Similar thing was done for the target i.e. an Oracle database table as well.
5. Next we created a simple interface with one-to-one mapping from the XSD schema to the Oracle database table and executed the interface. This execution takes more than one hour to complete.
6. We are running ODI client on Windows XP Professional SP2.
7. The Oracle database server(Oracle 10g 10.2.0.3) for the target schema as well as the ODI master and work repositories are on the same machine.
8. I tried changing the following properties but it is not making much visible difference:
use_prepared_statements=Y
use_batch_update=Y
batch_update_size=510
commit_periodically=Y
num_inserts_before_commit=30000
I have another problem that when I set batch_update_size to value greater that 510 I get the following error:
java.sql.SQLException: class org.xml.sax.SAXException
class java.lang.ArrayIndexOutOfBoundsException said -32413
at com.sunopsis.jdbc.driver.xml.v.a(v.java)
The main concern is why should the interface taking so long to execute.
Please send suggestions to resolve the problem.
Thanks in advance,
Best Regards,
Nikunj

Approximately how many rows are you trying to insert?
One of the techniques which I found improved performance for this scenario was to extract from the xml to a flat file, then to use SQL*LOADER or external tables to load the data into Oracle.

Similar Messages

  • Load XML file into oracle database

    Hi
    i have a xml file and the XSD(Schema definition file for XML). i need to load the xml file into the database.
    Can you please tell me the best approach for this ?

    There are plenty of examples of this on the XML DB Forum.
    Here is a link to the FAQ for that forum...
    XML DB FAQ

  • Help for loading of XML File into Oracle 10.2 DB.

    Hello People,
    I need help with below XML File, I need to get it loaded into Oracle 10.2.After brainstorming I could have figured out 2 best ways to do so :
    1.Through ctrl file and log file using SQL Loader
    2.Using XQuery and XML datatype.
    Tried with option 1 but dint succeed.Could you please help me out with a solution of the same ??
    <?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?>
    - <sta:entity-data xmlns:sta="http://www.vendavo.com/omi/StandardDeal" xsi:schemaLocation="http://www.vendavo.com/omi/StandardDeal StandardDeal-ImportAgreement 100912 - Updated.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    - <StandardDeal>
    <IsImported>true</IsImported>
    <ModelNReferenceID>00144105-009-000</ModelNReferenceID>
    <DealName>00144105-009-000CV Magellan Arteriocyte Inc 1164385</DealName>
    <AccountGroup>SoldTo</AccountGroup>
    <CustomerSalesData.VCustomer.VName>0001164385</CustomerSalesData.VCustomer.VName>
    <DistrictManager />
    <MultipleSalesReps>false</MultipleSalesReps>
    <OnBehalfOf>Brian Smith</OnBehalfOf>
    <FOBDestination>false</FOBDestination>
    <ConsultingGroupInformation />
    <AgreementStartDate>11/15/2007</AgreementStartDate>
    <AgreementEndDate>12/31/2013</AgreementEndDate>
    <BaselineReviewDate>01/10/2013</BaselineReviewDate>
    <BaseLineReviewPeriod>Quarterly</BaseLineReviewPeriod>
    <RequestedDate>10/12/2012</RequestedDate>
    <RFPDueDate>10/12/2012</RFPDueDate>
    <WaiveFreight>false</WaiveFreight>
    - <HeaderDiscountPercentageoffALP>
    - <VPercentage documentId="1">
    <Amount>0</Amount>
    </VPercentage>
    </HeaderDiscountPercentageoffALP>
    <CustomerCommitmentType>Others</CustomerCommitmentType>
    <ManualApproval>true</ManualApproval>
    <LegalReviewRequired>false</LegalReviewRequired>
    <TechnologyClause>false</TechnologyClause>
    <ComplianceTracking>false</ComplianceTracking>
    <ComplianceStatus>false</ComplianceStatus>
    <VState.VLabel>draft</VState.VLabel>
    <Eval>false</Eval>
    <CustomerAccepted>true</CustomerAccepted>
    <VNotes>CV Magellan Arteriocyte Inc 1164385</VNotes>
    - <VItems>
    - <StandardDealLineItem documentId="5235485">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>MAG100</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235486">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>MAG100</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <EffectiveFrom>11/15/2007</EffectiveFrom>
    <DurationMonths>19</DurationMonths>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VValidity.from>11/15/2007</VValidity.from>
    <VValidity.to>05/31/2009</VValidity.to>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235487">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>MAG100</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <EffectiveFrom>11/15/2007</EffectiveFrom>
    <DurationMonths>74</DurationMonths>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VValidity.from>11/15/2007</VValidity.from>
    <VValidity.to>12/31/2013</VValidity.to>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235489">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>MAG200</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235490">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>MAG200</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <EffectiveFrom>11/15/2007</EffectiveFrom>
    <DurationMonths>19</DurationMonths>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VValidity.from>11/15/2007</VValidity.from>
    <VValidity.to>05/31/2009</VValidity.to>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235491">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>MAG200</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <EffectiveFrom>11/15/2007</EffectiveFrom>
    <DurationMonths>74</DurationMonths>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VValidity.from>11/15/2007</VValidity.from>
    <VValidity.to>12/31/2013</VValidity.to>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235493">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>RMAG100</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235494">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>RMAG100</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <EffectiveFrom>11/15/2007</EffectiveFrom>
    <DurationMonths>74</DurationMonths>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VValidity.from>11/15/2007</VValidity.from>
    <VValidity.to>12/31/2013</VValidity.to>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235495">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>RMAG100</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <EffectiveFrom>11/15/2007</EffectiveFrom>
    <DurationMonths>19</DurationMonths>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VValidity.from>11/15/2007</VValidity.from>
    <VValidity.to>05/31/2009</VValidity.to>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235497">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>309604</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235498">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>309604</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <EffectiveFrom>11/15/2007</EffectiveFrom>
    <DurationMonths>74</DurationMonths>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VValidity.from>11/15/2007</VValidity.from>
    <VValidity.to>12/31/2013</VValidity.to>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235499">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>309604</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <EffectiveFrom>11/15/2007</EffectiveFrom>
    <DurationMonths>19</DurationMonths>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VValidity.from>11/15/2007</VValidity.from>
    <VValidity.to>05/31/2009</VValidity.to>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235501">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>309653</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235502">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>309653</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <EffectiveFrom>11/15/2007</EffectiveFrom>
    <DurationMonths>74</DurationMonths>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VValidity.from>11/15/2007</VValidity.from>
    <VValidity.to>12/31/2013</VValidity.to>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235503">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>309653</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <EffectiveFrom>11/15/2007</EffectiveFrom>
    <DurationMonths>19</DurationMonths>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VValidity.from>11/15/2007</VValidity.from>
    <VValidity.to>05/31/2009</VValidity.to>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235505">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>BOS350</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235506">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>BOS350</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <EffectiveFrom>11/15/2007</EffectiveFrom>
    <DurationMonths>19</DurationMonths>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VValidity.from>11/15/2007</VValidity.from>
    <VValidity.to>05/31/2009</VValidity.to>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    - <StandardDealLineItem documentId="5235655">
    <IsImported>true</IsImported>
    <VCatalogEntity.VName>AMS300</VCatalogEntity.VName>
    <PricingCPG>Magellan</PricingCPG>
    - <ExpectedAnnualQuantity>
    - <VQuantity>
    <VAmount>1</VAmount>
    <VUOM>EA</VUOM>
    </VQuantity>
    </ExpectedAnnualQuantity>
    <EffectiveFrom>11/15/2007</EffectiveFrom>
    <DurationMonths>74</DurationMonths>
    <PercentageBase>false</PercentageBase>
    <DiscountALP>N/A</DiscountALP>
    - <DiscountPercentage>
    - <VPercentage documentId="2">
    <Amount />
    </VPercentage>
    </DiscountPercentage>
    <ProposedAgreementPrice />
    - <CustomerRequestedPrice>
    - <VMoney documentId="4">
    <Amount />
    </VMoney>
    </CustomerRequestedPrice>
    <Monthly>No</Monthly>
    <PpaNoCap>N/A</PpaNoCap>
    - <ProjectedMarketShare>
    - <VPercentage documentId="5">
    <Amount>0</Amount>
    </VPercentage>
    </ProjectedMarketShare>
    <CustomerCommitted>Yes</CustomerCommitted>
    <VValidity.from>11/15/2007</VValidity.from>
    <VValidity.to>12/31/2013</VValidity.to>
    <VState.VName>draft</VState.VName>
    </StandardDealLineItem>
    </VItems>
    </StandardDeal>
    </sta:entity-data>
    Regards,
    Ekta

    1.Through ctrl file and log file using SQL LoaderPlease clarify :
    Do you want to load the entire file into a single column (XMLType or CLOB), or do you want to extract XML data and store it into different relational columns?
    Please also edit your first post and use tags to enclose the XML source, and do not copy/paste directly from your browser, use "view source" feature so that the content doesn't retain navigation characters (+/-).
    Edited by: odie_63 on 11 nov. 2012 13:20                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to load a XML file into the database

    Hi,
    I've always only loaded data into the database by using SQL-Loader and the data format was Excel or ASCII
    Now I have to load a XML.
    How can I do?
    The company where I work has Oracle vers. 8i (don't laugh, please)
    Thanks in advance!

    Hi,
    Tough job especially if the XML data is complex. The have been some similar question in the forum:
    Using SQL Loader to load an XML File -- use 1 field's data for many records
    SQL Loader to upload XML file
    Hope they help.
    Regards,
    Sujoy

  • How to load excel-csv file into oracle database

    Hi
    I wanted to load excel file with csv extension(named as trial.csv) into
    oracle database table(named as dept),I have given below my experiment here.
    I am getting the following error,how should I rectify this?
    For ID column I have defined as number(5) datatype, in my control file I have defined as interger external(5),where as in the Error log file why the datatype for ID column is comming as character?
    1)my oracle database table is
    SQL> desc dept;
    Name Null? Type
    ID NUMBER(5)
    DNAME CHAR(20)
    2)my data file is(trial.csv)
    ID     DNAME
    11     production
    22     purchase
    33     inspection
    3)my control file is(trial.ctl)
    LOAD DATA
    INFILE 'trial.csv'
    BADFILE 'trial.bad'
    DISCARDFILE 'trial.dsc'
    APPEND
    INTO TABLE dept
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    (ID POSITION(1:5) INTEGER EXTERNAL(5)      
    NULLIF ID=BLANKS,
    DNAME POSITION(6:25) CHAR
         NULLIF DNAME=BLANKS
    3)my syntax on cmd prompt is
    c:\>sqlldr scott/tiger@xxx control=trial.ctl direct=true;
    Load completed - logical record count 21.
    4)my log file error message is
    Column Name Position Len Term Encl Datatype
    ID           1:5 5 , O(") CHARACTER
    NULL if ID = BLANKS
    DNAME 6:25 20 , O(") CHARACTER
    NULL if DNAME = BLANKS
    Record 1: Rejected - Error on table DEPT, column ID.
    ORA-01722: invalid number
    Record 21: Rejected - Error on table DEPT, column ID.
    ORA-01722: invalid number
    Table DEPT:
    0 Rows successfully loaded.
    21 Rows not loaded due to data errors.
    0 Rows not loaded because all WHEN clauses were failed.
    0 Rows not loaded because all fields were null.
    Bind array size not used in direct path.
    Column array rows : 5000
    Stream buffer bytes: 256000
    Read buffer bytes: 1048576
    Total logical records skipped: 0
    Total logical records read: 21
    Total logical records rejected: 21
    Total logical records discarded: 0
    Total stream buffers loaded by SQL*Loader main thread: 0
    Total stream buffers loaded by SQL*Loader load thread: 0
    5)Result
    SQL> select * from dept;
    no rows selected
    by
    balamuralikrishnan.s

    Hi everyone!
    The following are the steps to load a excell sheet to oracle table.i tried to be as simple as possible.
    thanks
    Step # 1
    Prapare a data file (excel sheet) that would be uploaded to oracle table.
    "Save As" a excel sheet to ".csv" (comma seperated values) format.
    Then save as to " .dat " file.
    e.g datafile.bat
    1,Category Wise Consumption Summary,Expected Receipts Report
    2,Category Wise Receipts Summary,Forecast Detail Report
    3,Current Stock List Category Wise,Forecast rule listing
    4,Daily Production Report,Freight carrier listing
    5,Daily Transactions Report,Inventory Value Report
    Step # 2
    Prapare a control file that define the data file to be loaded ,columns seperation value,name and type of the table columns to which data is to be loaded.The control file extension should be " .ctl " !
    e.g i want to load the data into tasks table ,from the datafile.dat file and having controlfile.ctl control file.
    SQL> desc tasks;
    Name Null? Type
    TASK_ID NOT NULL NUMBER(14)
    TASK_NAME VARCHAR2(120)
    TASK_CODE VARCHAR2(120)
    : controlfile.ctl
    LOAD DATA
    INFILE 'e:\datafile.dat'
    INTO TABLE tasks
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    (TASK_ID INTEGER EXTERNAL,
    TASK_NAME CHAR,
    TASK_CODE CHAR)
    The above is the structure for a control file.
    Step # 3
    the final step is to give the sqlldr command to execute the process.
    sqlldr userid=scott/tiger@abc control=e:\controlfile.ctl log=e:\logfile.log
    Message was edited by:
    user578762

  • Loading an XML file into a database table.

    What is the convenient way to parse XML data present in a data file in server?

    Hi;
    Please check:
    http://riteshkk2000.blogspot.com/2012/01/loadimport-xml-file-into-database-table .html
    http://docs.oracle.com/cd/E18283_01/appdev.112/e16659/xdb03usg.htm#BABIFADB
    http://www.oracle.com/technetwork/articles/quinlan-xml-095823.html
    Regard
    Helios

  • Techinical issue loading an XML file in to database

    hi,
    i am trying to load an XML file into Oracle database using SSIS 2005. the XML file is huge with 4000+ columns and also has many sub catogoreys. if i try to load the file using XSD it is taking lot of space to read the entire file upto 10GB even if the data row in the file is only one. I am only loading 60 columns out of the 4000+ columns. please provide me any alternatives that you can think of.
    Thanks in advance.
    Deb

    Stew Ashton wrote:
    I think Oracle's support for loading XML data to relational tables could be improved. I haven't found a scalable solution for very large XML files that doesn't involve breaking the file up into little parts or writing / copying a good bit of code.XML DB provides two efficient ways to load XML data relationally :
    - Object-Relational storage and FTP : the file is send to the XDB repository and inserted into the default XMLType table declared during schema registration. The underlying storage structures (collections, nested tables) are loaded directly while the data source is read.
    Then it's just a matter of building views over the XMLType table to present the data relationally.
    We can process several GBs with this method.
    - Binary XML and streaming XPath evaluation : binary XML is a post-parsed format which is optimized for streaming processing, it's available since 11.1 and now the default starting with 11.2.0.2.
    and you are supposed to parse the whole thing and return any errors before actually doing anything.That's the DOM view of things.
    XML DB doesn't use DOM when documents are first stored as XMLType (binary or OR storage), or when it does, for example if a functional evaluation of XQuery is required, then a "lazy DOM" model is used where only the needed part(s) of the XML is (are) retrieved.

  • Load XML file into oracle xml buffer

    Hi guys,
    I'm a starter in Oracle XML Development, I wander how I can load a xml file into oracle xml buffer(xmlctx* document) through programming with c++ in visual studio.
    When I use orastream structure, it compiled failed.
    Thank you very much!
    Edited by: pomelo on 2010-11-15 下午5:39

    try this
    LOAD DATA
    INFILE '/home/oraread/'
    INTO TABLE xmlloadtable
    (id,
    file_name          filler,
    data_xml          lobfile(file_name) terminated by eof
    )you can add the file_name field as a column to your table between the id and xml column and remove the filler word in the .ldr file if you need to keep the name of the file

  • Loading XML File into Oracle 10G XE

    I am trying to load an XML file into 10G XE from the Utilities interface, I have created a Table to load into but when I try to load I get the following cryptic error "XML Load Error". There is no other information, can someone give me some insight where to start to resolve this problem?

    The error messages when importing fails provided by APEX 2.1 are not very useful as they do not provide any clue...
    If possible, you can try to load XML file with SQL*Loader - probably you will get then more useful error messages.

  • How to load a XML file into a table

    Hi,
    I've been working on Oracle for many years but for the first time I was asked to load a XML file into a table.
    As an example, I've found this on the web, but it doesn't work
    Can someone tell me why? I hoped this example could help me.
    the file acct.xml is this:
    <?xml version="1.0"?>
    <ACCOUNT_HEADER_ACK>
    <HEADER>
    <STATUS_CODE>100</STATUS_CODE>
    <STATUS_REMARKS>check</STATUS_REMARKS>
    </HEADER>
    <DETAILS>
    <DETAIL>
    <SEGMENT_NUMBER>2</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>3</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic administration</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>4</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic finance</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>5</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic logistics</REMARKS>
    </DETAIL>
    </DETAILS>
    <HEADER>
    <STATUS_CODE>500</STATUS_CODE>
    <STATUS_REMARKS>process exception</STATUS_REMARKS>
    </HEADER>
    <DETAILS>
    <DETAIL>
    <SEGMENT_NUMBER>20</SEGMENT_NUMBER>
    <REMARKS> base polytechnic</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>30</SEGMENT_NUMBER>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>40</SEGMENT_NUMBER>
    <REMARKS> base polytechnic finance</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>50</SEGMENT_NUMBER>
    <REMARKS> base polytechnic logistics</REMARKS>
    </DETAIL>
    </DETAILS>
    </ACCOUNT_HEADER_ACK>
    For the two tags HEADER and DETAILS I have the table:
    create table xxrp_acct_details(
    status_code number,
    status_remarks varchar2(100),
    segment_number number,
    remarks varchar2(100)
    before I've created a
    create directory test_dir as 'c:\esterno'; -- where I have my acct.xml
    and after, can you give me a script for loading data by using XMLTABLE?
    I've tried this but it doesn't work:
    DECLARE
    acct_doc xmltype := xmltype( bfilename('TEST_DIR','acct.xml'), nls_charset_id('AL32UTF8') );
    BEGIN
    insert into xxrp_acct_details (status_code, status_remarks, segment_number, remarks)
    select x1.status_code,
            x1.status_remarks,
            x2.segment_number,
            x2.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns header_no      for ordinality,
              status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '$d/ACCOUNT_HEADER_ACK/DETAILS[$hn]/DETAIL'
      passing acct_doc as "d",
              x1.header_no as "hn"
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS'
    ) x2
    END;
    This should allow me to get something like this:
    select * from xxrp_acct_details;
    Statuscode status remarks segement remarks
    100 check 2 rp polytechnic
    100 check 3 rp polytechnic administration
    100 check 4 rp polytechnic finance
    100 check 5 rp polytechnic logistics
    500 process exception 20 base polytechnic
    500 process exception 30
    500 process exception 40 base polytechnic finance
    500 process exception 50 base polytechnic logistics
    but I get:
    Error report:
    ORA-06550: line 19, column 11:
    PL/SQL: ORA-00932: inconsistent datatypes: expected - got NUMBER
    ORA-06550: line 4, column 2:
    PL/SQL: SQL Statement ignored
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    and if I try to change the script without using the column HEADER_NO to keep track of the header rank inside the document:
    DECLARE
    acct_doc xmltype := xmltype( bfilename('TEST_DIR','acct.xml'), nls_charset_id('AL32UTF8') );
    BEGIN
    insert into xxrp_acct_details (status_code, status_remarks, segment_number, remarks)
    select x1.status_code,
            x1.status_remarks,
            x2.segment_number,
            x2.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '/ACCOUNT_HEADER_ACK/DETAILS'
      passing acct_doc
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS'
    ) x2
    END;
    I get this message:
    Error report:
    ORA-19114: error during parsing the XQuery expression: 
    ORA-06550: line 1, column 13:
    PLS-00201: identifier 'SYS.DBMS_XQUERYINT' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    ORA-06512: at line 4
    19114. 00000 -  "error during parsing the XQuery expression: %s"
    *Cause:    An error occurred during the parsing of the XQuery expression.
    *Action:   Check the detailed error message for the possible causes.
    My oracle version is 10gR2 Express Edition
    I do need a script for loading xml files into a table as soon as possible, Give me please a simple example for understanding and that works on 10gR2 Express Edition
    Thanks in advance!

    The reason your first SQL statement
    select x1.status_code,
            x1.status_remarks,
            x2.segment_number,
            x2.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns header_no      for ordinality,
              status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '$d/ACCOUNT_HEADER_ACK/DETAILS[$hn]/DETAIL'
      passing acct_doc as "d",
              x1.header_no as "hn"
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS'
    ) x2
    returns the error you noticed
    PL/SQL: ORA-00932: inconsistent datatypes: expected - got NUMBER
    is because Oracle is expecting XML to be passed in.  At the moment I forget if it requires a certain format or not, but it is simply expecting the value to be wrapped in simple XML.
    Your query actually runs as is on 11.1 as Oracle changed how that functionality worked when 11.1 was released.  Your query runs slowly, but it does run.
    As you are dealing with groups, is there any way the input XML can be modified to be like
    <ACCOUNT_HEADER_ACK>
    <ACCOUNT_GROUP>
    <HEADER>....</HEADER>
    <DETAILS>....</DETAILS>
    </ACCOUNT_GROUP>
      <ACCOUNT_GROUP>
      <HEADER>....</HEADER>
      <DETAILS>....</DETAILS>
      </ACCOUNT_GROUP>
    </ACCOUNT_HEADER_ACK>
    so that it is easier to associate a HEADER/DETAILS combination?  If so, it would make parsing the XML much easier.
    Assuming the answer is no, here is one hack to accomplish your goal
    select x1.status_code,
            x1.status_remarks,
            x3.segment_number,
            x3.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns header_no      for ordinality,
              status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '$d/ACCOUNT_HEADER_ACK/DETAILS'
      passing acct_doc as "d",
      columns detail_no      for ordinality,
              detail_xml     xmltype       path 'DETAIL'
    ) x2,
    xmltable(
      'DETAIL'
      passing x2.detail_xml
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS') x3
    WHERE x1.header_no = x2.detail_no;
    This follows the approach you started with.  Table x1 creates a row for each HEADER node and table x2 creates a row for each DETAILS node.  It assumes there is always a one and only one association between the two.  I use table x3, which is joined to x2, to parse the many DETAIL nodes.  The WHERE clause then joins each header row to the corresponding details row and produces the eight rows you are seeking.
    There is another approach that I know of, and that would be using XQuery within the XMLTable.  It should require using only one XMLTable but I would have to spend some time coming up with that solution and I can't recall whether restrictions exist in 10gR2 Express Edition compared to what can run in 10.2 Enterprise Edition for XQuery.

  • How to load a java file into Oracle?

    Hello,
    I have some problem in loading a java file into Oracle 8i. I used "loadjava -user <userName/Password> -resolve <javaClassName>" command.
    JAVA Version used JDK 1.5
    When calling this class file from a trigger gives this error
    ORA-29541: class ANTONY1.DBTrigger could not be resolved.
    Can anyone help me to resolve this problem?

    Hello,
    Which username did you use to load the class, and which user is running the trigger?
    The default resolver searches only the current user's schema and PUBLIC so the java class needs to be loaded into one of these.
    cheers,
    Anthony

  • Loading an XML file into the table without creating a directory .

    Hi,
    I wanted to load an XML file into a table column . But I should not create a directory in the server and placing the XML file there and giving the path in the insert query. Can anybody help me here?
    Thanks in advance.

    You could write a java stored procedure that retrieves the file into a clob. Wrap that in a function call and use it in your insert statement.
    This solution require read privileges granted by sys and is therefore only feasible if the top-level directory/directories are known or you get read-access to everything.

  • A query while  importing  an XML file into a Database Table

    Hi,
    I am Creating an ODI Project to import an XML file into a Database Table.With the help of the following link
    http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/odi/odi_11g/odi_project_xml-to-table/odi_project_xml-to-table.htm
    I am facing a problem while creating Physical Schema for the XML Source Model.
    For the
    Schema(Schema)
    and
    Schema(Work Schema) field they have selected GEO_D.
    What is GEO_D here??
    or
    What I have to select here?
    1) schema of the xml file (NB:-I havn't created any .xsd or .dtd file for my .xml file)
    or
    2)my target servers schema
    Please tell me what I'll do??
    Thanks

    and
    Schema(Work Schema) field they have selected GEO_D.
    What is GEO_D here??This is the schema name which is specified in the XML file .
    What I have to select here?
    1) schema of the xml file (NB:-I havn't created any .xsd or .dtd file for my .xml file)Yes
    2)my target servers schema
    Please tell me what I'll do??
    Thanks

  • Regarding loading of excel data  into oracle database

    hello,
    Can someone help me in knowing that how can we load excel sheets data into oracle database.
    I will be really thankful to you.
    Gursimran

    Hi,
    There is tool given by oracle "Oracle Bulk Loader "
    you can use this.
    But in order use this you need a control file, which specifies how data should be loaded into the database; and a data file, which specifies what data should be loaded.
    Example :- this is the control file which has information how the data is processed.
    LOAD DATA
    INFILE test.dat
    INTO TABLE test
    FIELDS TERMINATED BY '|'
    (i, s)
    Example :- test.dat which is the data file or say your excel sheet or document
    (1, 'foo')
    (2, 'bar')
    (3, ' baz')
    example of Loading :-
    sqlldr <yourName> control=<ctlFile> log=<logFile> bad=<badFile>
    sqlldr testing control=test.ctl log=test.log
    Thanks
    Pavan Kumar N

  • How to insert a image file into oracle database

    hi all
    can anyone guide me how to insert a image file into oracle database now
    i have created table using
    create table imagestore(image blob);
    but when inserting i totally lost don't know what to do how to write query to insert image file

    Hi I don't have time to explain really, I did have to do this a while ago though so I will post a code snippet. This is using the commons file upload framework.
    Firstly you need a multi part form data (if you are using a web page). If you are not using a web page ignore this bit.
    out.println("<form name=\"imgFrm\" method=\"post\" enctype=\"multipart/form-data\" action=\"FileUploadServlet?thisPageAction=reloaded\" onSubmit=\"return submitForm();\"><input type=\"FILE\" name=\"imgSource\" size='60' class='smalltext' onKeyPress='return stopUserInput();' onKeyUp='stopUserInput();' onKeyDown='stopUserInput();' onMouseDown='noMouseDown(event);'>");
    out.println("   <input type='submit' name='submit' value='Submit' class='smalltext'>");
    out.println("</form>"); Import this once you have the jar file:
    import org.apache.commons.fileupload.*;Now a method I wrote to upload the file. I am not saying that this is correct, or its the best way to do this. I am just saying it works for me.
    private boolean uploadFile(HttpServletRequest request, HttpSession session) throws Exception {
            boolean result = true;
            String fileName = null;
            byte fileData[] = null;
            String fileUploadError = null;
            String imageType = "";
            String error = "";
            DiskFileUpload fb = new DiskFileUpload();
            List fileItems = fb.parseRequest(request);
            Iterator it = fileItems.iterator();
            while(it.hasNext()){
                FileItem fileItem = (FileItem)it.next();
                if (!fileItem.isFormField()) {
                    fileName = fileItem.getName();
                    fileData = fileItem.get();
                    // Get the imageType from the filename extension
                    if (fileName != null) {
                        int dotPos = fileName.indexOf('.');
                        if (dotPos >= 0 && dotPos != fileName.length()-1) {
                            imageType = fileName.substring(dotPos+1).toLowerCase();
                            if (imageType.equals("jpg")) {
                                imageType = "jpeg";
            String filePath = request.getParameter("FILE_PATH");
            session.setAttribute("filePath", filePath);
            session.setAttribute("fileData", fileData);
            session.setAttribute("fileName", fileName);
            session.setAttribute("imageType", imageType);
            return result;  
         } And now finally the method to actually write the file to the database:
    private int writeImageFile(byte[] fileData, String fileName, String imageType, String mode, Integer signatureIDIn, HttpServletRequest request) throws Exception {
            //If the previous code found a file that can be uploaded then
            //save it into the database via a pstmt
            String sql = "";
            UtilDBquery udbq = getUser(request).connectToDatabase();
            Connection con = null;
            int signatureID = 0;
            PreparedStatement pstmt = null;
            try {
                udbq.setUsePreparedStatements(true);
                con = udbq.getPooledConnection();
                con.setAutoCommit(false);
                if((!mode.equals("U")) || (mode.equals("U") && signatureIDIn == 0)) {
                    sql = "SELECT SEQ_SIGNATURE_ID.nextval FROM DUAL";
                    pstmt = con.prepareStatement(sql);
                    ResultSet rs = pstmt.executeQuery();
                    while(rs.next()) {
                       signatureID = rs.getInt(1);
                    if (fileName != null && imageType != null) {
                        sql = "INSERT INTO T_SIGNATURE (SIGNATURE_ID, SIGNATURE) values (?,?)";
                        InputStream is2 = new ByteArrayInputStream(fileData);
                        pstmt = con.prepareStatement(sql);
                        pstmt.setInt(1, signatureID);
                        pstmt.setBinaryStream(2, is2, (int)(fileData.length));
                        pstmt.executeUpdate();
                        pstmt.close();
                        con.commit();
                        con = null;
                if(mode.equals("U") && signatureIDIn != 0) {
                    signatureID = signatureIDIn.intValue();
                    if (fileName != null && imageType != null) {
                        sql = "UPDATE T_SIGNATURE SET SIGNATURE = ? WHERE SIGNATURE_ID = ?";
                        InputStream is2 = new ByteArrayInputStream(fileData);
                        pstmt = con.prepareStatement(sql);
                        pstmt.setBinaryStream(1, is2, (int)(fileData.length));
                        pstmt.setInt(2, signatureID);
                        pstmt.executeUpdate();
                        pstmt.close();
                        con.commit();
                        con = null;
            } catch (Exception e) {
                con = null;
                throw new Exception(e.toString());
            return signatureID;
       }

Maybe you are looking for