Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
LoadinganExcelSpreadsheetintoanOracleTable(OracleWarehouseBuilder(OWB))
Oracle
BlogsHome
Products&Services
Downloads
Support
Partners
Communities
About
Login
OracleBlog
OracleWarehouseBuilder(OWB)
GettingthemostoutofOWBandtheOracleDatabase
OWBatODTUG'sKalei...|Main|UsingDBMSScheduler...
LoadinganExcelSpreadsheetintoanOracleTable
ByAlexWuonMar01,2010
RecentlywecameacrossaquestionfromthefieldabouthowanExcelspreadsheetcanbeloadedintoan
OracletablewiththehelpofOWB11GR2.Therearemanywaysthatthiscanbeachieved.WithOWB
11GR2,theintroductionofCodeTemplateaddsanewwayofhowaspreadsheetcanbeloaded.Inthis
article,wellreviewsomeoftheoldwaysandexplorethenewwayusingOWB11GR2.
Letsconsideranexamplewherewehave2spreadsheets,hr_employees.xlsandhr_departments.xlsand
wewanttoloadonlytheemployeesintheSalesdepartmentintotheOracletable.Followingisthe
spreadsheetofhr_department.AndthecolumnsfromAtoDaredefinedasdepartment_id,
department_name,manager_idandlocation_id.
Andthehr_employeesspreadsheetlookslikebelow.AndthecolumnsfromAtoKaredefinedas
employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,commission_pct,
manager_idanddepartment_id.
https://blogs.oracle.com/warehousebuilder/entry/loading_an_excel_spreadsheet_into_an_oracle_table
1/13
1/30/2015
LoadinganExcelSpreadsheetintoanOracleTable(OracleWarehouseBuilder(OWB))
Tomakethescenariomoreinteresting,weonlywanttheemployeesintheSalesdepartmentinourresult
table.Belowisthestructureoftheresulttablesales_employeeswheretargetdatawillbestored:
Toloadthesalesemployeesintothetargettable,wehavetojointhedatafrom2spreadsheetsbyusing
thereferencekeydepartment_id.Besides,thecolumnemployee_nameinthetargettable
sales_employeesisdesignedtoincludethefirstnameandthelastnameofanemployee.Hence,a
transformationoperatorisneeded.Forexample,wecanutilizetheOraclepredefinedfunctionCONCAT
toconcatenatethenames.
LetsthinkabouthowtoimplementthisinOWB11GR2release.
1.Thefirstway:accessExcelspreadsheetsthroughtheOracleDatabaseGatewayforODBCandload
databyusingPL/SQLmapping.
TheOracleDatabaseGatewayforODBCcanbesetuptoaccessanExcelfile,makingeachspreadsheet
intheExcelfilelooksasifitwereanOracletable.AndwecanmakeuseofthistocreateaPL/SQL
mappinginOWBtoloadtheExceldataintoanOracletable.First,weneedtosetuptheODBCgateway
fortheExcelfile(See"UsingExcelSpreadsheetsasSource").InOWB,createanODBCmodule
correspondingtotheODBCgatewayandinvoketheImportMetadataWizardtoimportthestructuresof
the2spreadsheetsintoOWB.ThenconstructaPL/SQLmappingasfollows.
https://blogs.oracle.com/warehousebuilder/entry/loading_an_excel_spreadsheet_into_an_oracle_table
2/13
1/30/2015
LoadinganExcelSpreadsheetintoanOracleTable(OracleWarehouseBuilder(OWB))
TheJoinerconditionisconfiguredasbelow.
Whenitsexecuted,OWBwillreadthedatainspreadsheetsthroughOracleDatabaseGatewayfor
ODBC,transformandloadthemintothetargettable.
2.Thesecondway:utilizeflatfilesandloaddatafromconvertedCSVfilestostagingtablesby
SQL*Loadermapping,thenloadthetargetusingPL/SQLmapping.
2.1Firstofall,weneedtoconverttheExcelfromXLSformatintoCSVortextformatsothatOWBflat
filecanaccessit.ThiscanbedonebythirdpartytoolsortheSaveAsfeatureinExcel.Inmycase,I
openthespreadsheetswithMicrosoftExcel,andsavethemashr_employees.csvandhr_departments.csv
respectively.IalsoperformaLinuxshellcommanddos2unixtoconvertanyWindowscharactersinto
Unixformat,formyOWBrepositoryisbuiltonaLinuxplatform.
2.2CreateanOWBflatfilemodulereferencingtothedirectorywheretheCSVfilesare,andusethe
ImportMetadataWizardtoimporttheCSVfiles.
2.3Create2SQL*Loadermappingstoloaddataintothestagingtablesasfollows.
https://blogs.oracle.com/warehousebuilder/entry/loading_an_excel_spreadsheet_into_an_oracle_table
3/13
1/30/2015
LoadinganExcelSpreadsheetintoanOracleTable(OracleWarehouseBuilder(OWB))
Thismappingwillloadthedatainhr_departments.csvintothestagingtableSTAGING_HR_DEPT.
NotethattheloadingtypehasbeenconfiguredasTRUNCATE/INSERTsothatnoduplicatedatawillbe
loadedintothestagingtableaftermultirunning.
Thismappingistoloadthedatainhr_employees.csvintostagingtableSTAGING_HR_EMP,andthe
loadingtypeisalsosetupasTRUNCATE/INSERT.
2.4CreateaPL/SQLmappingtotransformandloaddatafromstagingtablesintofinaltargetasfollows.
https://blogs.oracle.com/warehousebuilder/entry/loading_an_excel_spreadsheet_into_an_oracle_table
4/13
1/30/2015
LoadinganExcelSpreadsheetintoanOracleTable(OracleWarehouseBuilder(OWB))
Thatsit.Afterdeployingandexecutingthe3mappings,datawillbeloadedintotarget.
3.Thethirdway:utilizeOracleExternaltables,extractandloaddatafromexternaltablestothetargetby
PL/SQLmapping.
Externaltablehelpstoexposedatainaflatfileasifitwerearelationaltable.Thusitsmoreflexibleto
involveexternaltableoperatorasasourcethantheflatfileoperatorinamapping.OWBgeneratesthe
SQLandPL/SQLcodesforthemappingwithexternaltable,andmoreoperatorscanbeutilizedinsuch
kindofmapping.Asaresult,onlyonePL/SQLmappingisneededtodotheentirejob.
Forthisexample,wecreate2externaltablesthatreferencethe2CSVfilesrespectively,andthenwejoin
themtogethertoextractandtransformthesalesemployeesintothetargettable.AndthePL/SQL
mappinglookslikethis.
ExternaltableoperatorsandPL/SQLmappingsallowformorecomplexmappingswithouttheuseof
stagingtables.
https://blogs.oracle.com/warehousebuilder/entry/loading_an_excel_spreadsheet_into_an_oracle_table
5/13
1/30/2015
LoadinganExcelSpreadsheetintoanOracleTable(OracleWarehouseBuilder(OWB))
4.Thefourthandnewestway:extractandloaddatafromtheCSVfilestothetargettablebyCode
TemplateMapping.
In11GR2,CodeTemplatemapping(CTmapping)isintroducedforheterogeneousdataextraction,
transformationandloadingbyusingcodetemplates.ThisenhancesOWBtoextractandloaddata(either
withorwithouttransformation)betweendifferentdatabaseplatformseasily.EachCTmappingcontains
oneormoreexecutionunits,andeachunitisindependentandassociatedwithonecodetemplate.It
utilizesthetechnologydefinedinthecodetemplatetomovedata,processdatamovementunitbyunit,
andthenloadsitintothefinaltarget.Becauseoftheindependencyofeachunit,CTMappingallows
userstohandledatafromdifferentsourcesusingdifferenttechnologies.
Forthisexample,weincludethe2fileoperators(forthetwoCSVfiles)andthetargettableinaCT
mapping,andthenhandletheETLin3executionunitsasfollows.
Beforedeployment,wehavetoassignthecodetemplatetoeachexecutionunit,andconfigurethesource
flatfilesandlocationsofthefileoperatorsHR_EMPLOYEES_CSVandHR_DEPARTMENTS_CSV.
Toassigncodetemplatetoanexecutionunit,opentheCTmappingandselecttheexecutionviewtab,
andthenselecttheexecutionunitbox.AndOWBwillpopulatetheavailablecodetemplatesshownin
thedropdownlist.Forexample,whenaboveexecutionunitDEPT_EX_UNITisselected,several
availabletemplatesareshown,suchasLCT_FILETO_SQL,LCT_FILE_TO_ORACLE_SQLLDRand
LCT_FILE_TO_ORACLE_EXTER_TABLE.Thoughwehaveseveraloptions,westillneedto
determinewhichoneisappropriatebaseduponyourdataandthefunctionalityofthetemplate.Besides,
sinceeachexecutionunitisindependent,eveniftheexecutionunitDEPT_EX_UNITand
EMP_EX_UNITaredoingsimilarjobs,wecanassigndifferentcodetemplatetoeachofthem.For
instance,theDEPT_EX_UNITcanhavecodetemplateLCT_FILE_TO_ORACLE_SQLLDRwhile
EMP_EX_UNITcanuseanotherLCT_FILETO_SQL,asshownbelow.Thisgreatlyaugmentsthe
flexibilityofCTmapping.
https://blogs.oracle.com/warehousebuilder/entry/loading_an_excel_spreadsheet_into_an_oracle_table
6/13
1/30/2015
LoadinganExcelSpreadsheetintoanOracleTable(OracleWarehouseBuilder(OWB))
IftheflatfilereferencedbyfileoperatorisimportedthroughImportMetadataWizard,theCTmapping
knowsthelocationandthefilephysicalnameduringcodegeneration.However,wecanstillreconfigure
https://blogs.oracle.com/warehousebuilder/entry/loading_an_excel_spreadsheet_into_an_oracle_table
7/13
1/30/2015
LoadinganExcelSpreadsheetintoanOracleTable(OracleWarehouseBuilder(OWB))
theminthemappingconfigurationeditorifwewanttochangethem.Thisshouldbedonerightbeforethe
firsttimecodegeneration.
Thatsit,itsreadytodeployandexecutetheCTmappingnow.Seetheexecutionresultbelow.The
executionunitEMP_EX_UNITandSALES_EX_UNITutilizeJDBCtoloadthedatawhileexecution
unitDEPT_EX_UNITusesSQL*Loadertechnology.
CTmappingallowsflexibletechnologyfordatamovement,andtheperformanceonlargedatavolumes
dependsonthecodetemplateapplied.ThoughCTmappingallowsmoreoperatorsthanSQL*Loader
mapping,theremaybesomerestrictionswiththeoperators,forexample,someoperatorscanonlybe
supportedintheOracletargetCTmapping,suchasSetOperation.Fordetails,pleasereferto"Mapping
OperatorsthatareOnlySupportedDirectlyinOracleTargetCTMappings".
Sofar,Iveillustrated4waystoloadExcelspreadsheetsintoOracletables,whichoneisbestsuitedfor
https://blogs.oracle.com/warehousebuilder/entry/loading_an_excel_spreadsheet_into_an_oracle_table
8/13
1/30/2015
LoadinganExcelSpreadsheetintoanOracleTable(OracleWarehouseBuilder(OWB))
yourneeds?
Waystoload
Excel
spreadsheet
The1stway:
The2ndway:loaddatafromCSV
loaddata
filesbySQL*Loader
throughODBC
gateway
Precondition
ODBCgateway ACSV/textfileconvertedfrom
forExcelisset Excelisrequired
up.
The3rdway:
loaddatawith
externaltables
The4thway:
loaddataby
codetemplate
PL/SQL
mapping
CTmapping
Mappingtype PL/SQL
mapping
SQL*Loadermapping&PL/SQL
Mappingifdoingmoretransform
Arestaging
No.
tableandextra
mapping
required?
Yeswhentherearemorethanone No.
sourcefiles,ormappingiscomplex.
No.
Whatmapping High.Itcan
operatorsare offerthefull
supported?
rangeof
Warehouse
Builderdata
transformation
capabilities.
Low.Onlyoneflatfilesourceis
allowedwithineachmapping,and
onlyafewoperatorsareapplicable.
Seedocument"Creating
SQL*LoaderMappingstoExtract
DatafromFlatFiles".
Middle.More
thanonefile
operatorscanbe
involvedwithin
onemapping.
CTmappings
supportonlya
subsetof
transformations
availablein
PL/SQL
mappings.See
"Mapping
Operatorsthat
areOnly
Supported
Directlyin
OracleTarget
CTMappings".
High.Itcan
supportthefull
rangeof
Warehouse
Builderdata
transformation
capabilities.
Category:Oracle
Tags:none
Permanentlinktothisentry
https://blogs.oracle.com/warehousebuilder/entry/loading_an_excel_spreadsheet_into_an_oracle_table
9/13
1/30/2015
LoadinganExcelSpreadsheetintoanOracleTable(OracleWarehouseBuilder(OWB))
OWBatODTUG'sKalei...|Main|UsingDBMSScheduler...
Comments:
HowtoloadSQLdatatoOraclebyschedulingajobthatrunsevery15mins,takingthedatafortheslot
of15minutes
PostedbyguestonJuly06,2011at08:18PMPDT#
howtoimportexcelfiletooracletable
PostedbysukhvironMay24,2012at04:47AMPDT#
Hi,
Iamhavingadatainexcelsheet(ex:emptable).
IwantthatdatetobeinsertedorcopyintoOracleemporanyothertable.Howcanigetthis?
Regards,
Rajesh
PostedbyguestonJuly03,2013at03:29AMPDT#
HiRajesh
Didyoureadthroughthisinthedoc
http://docs.oracle.com/cd/E11882_01/owb.112/e10582/loading_ms_data.htm
Cheers
David
PostedbyDavidonJuly08,2013at01:28PMPDT#
PostaComment:
Name: guest
EMail:
URL:
Notifymebyemailofnewcomments
RememberInformation?
YourComment:
HTMLSyntax:NOTallowed
Pleaseanswerthissimplemathquestion
https://blogs.oracle.com/warehousebuilder/entry/loading_an_excel_spreadsheet_into_an_oracle_table
10/13
1/30/2015
LoadinganExcelSpreadsheetintoanOracleTable(OracleWarehouseBuilder(OWB))
6+33=
Preview
Post
About
ETL,CDC,RealTimeDIandDataQualityfortheOracleDatabasefromtheinside.
Search
Entersearchterm:
Searchonlythisblog
RecentPosts
ODI12cMigratingfromOWBtoODIPLSQLProcedures
OWBtoODI12cMigrationinaction
OWBtoODIMigrationUtilitynowavailableforOWB11.2.0.3+CP3LinuxandWindows64bit
standaloneinstallation.
OWBtoODIMigrationUtilityreleasedforWindows64bit.
OWBtoODIMigrationUtilityWebcastThu12thDecember
PlanningthejourneyfromOracleWarehouseBuildertoOracleDataIntegrator
OWBtoODIMigrationUtilityreleased.
OWB11.2.0.4Windowsstandaloneclientreleased
ODI12cisGA
OWBMakingtheMovetoODI
TopTags
11.1.1.6
11g
11gR2
11gr2
12c
accelerator
BI
builder
code_templates
configuration
data
Data_Integration
data_quality
Data_Quality
Data_Warehouse
database
Database
https://blogs.oracle.com/warehousebuilder/entry/loading_an_excel_spreadsheet_into_an_oracle_table
11/13
1/30/2015
LoadinganExcelSpreadsheetintoanOracleTable(OracleWarehouseBuilder(OWB))
dimension
ELT
elt
error
errors
ETL
etl
expert
file
groovy
handling
integration
loading
mapping
Metadata
metadata
migration
odi
ODI
omb
owb
OWB
OWB_11.2
parallel
performance
Process_Flow
sdk
SQL
sql
sqlloader
warehouse
Warehouse_Builder
xml
Categories
Oracle
ApplicationConnectors
Comments
DataAuditor
DataQuality
ETL
SAP
Events
Howto...
Metadata
ODI
Press
Resources
SDK
https://blogs.oracle.com/warehousebuilder/entry/loading_an_excel_spreadsheet_into_an_oracle_table
12/13
1/30/2015
LoadinganExcelSpreadsheetintoanOracleTable(OracleWarehouseBuilder(OWB))
SOAandWebServices
SuccessStories
UserContributedContent
masterdatamanagement
Archives
January2015
Sun Mon Tue Wed Thu Fri Sat
1 2 3
4 5
6 7
8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Today
Bookmarks
OWBBlogPostDirectoryArchive
DataWarehouseInsider
RittmanMeadBlog
OracleDataIntegrationblog
BigDataForums
BIQuotient(Uli)
Menu
BlogsHome
Weblog
Login
Feeds
RSS
All
/Oracle
Comments
Atom
All
/Oracle
Comments
Theviewsexpressedonthisblogarethoseoftheauthoranddonotnecessarilyreflecttheviewsof
Oracle.TermsofUse|YourPrivacyRights|CookiePreferences
https://blogs.oracle.com/warehousebuilder/entry/loading_an_excel_spreadsheet_into_an_oracle_table
13/13