PdForXML - Examples |
Top Previous Next |
The examples below cover a number of the extract scenarios you might run into. A common strategy is to use the first example on a regular basis, perhaps nightly, capturing the prior 30 days. Then less frequently, perhaps quarterly or semi-annually, query a larger range to capture corrections or late submissions.
1.ByRecord example: One record per file, previous 180 days. PdForXML.exe byrecord --priortimeunit days --priortimevalue 180 --directory C:\OutDirectory --server db.example.com\example --database EXAMPLE_DB --login Name --password Password --caseidqueryfilename C:\Temp\caseidquery.sql --queryfilename C:\Temp\examplequery.sql --datefieldname CrashDateField --caseidfieldname c.CaseId
2.ByRecord example: One record per file, specify date range. PdForXML.exe byrecord --startdate 2011/10/01 --enddate 2013/9/8 --directory C:\OutDirectory --server db.example.com\example --database EXAMPLE_DB --login Name --password Password --caseidqueryfilename C:\Temp\caseidquery.sql --queryfilename C:\Temp\examplequery.sql --datefieldname CrashDateField --caseidfieldname c.CaseId 3.All example: All records to one file, previous 180 days. PdForXML.exe all --priortimeunit days --priortimevalue 180 --directory C:\OutDirectory --server db.example.com\example --database EXAMPLE_DB --login Name --password Password --queryfilename C:\Temp\examplequery.sql --datefieldname CrashDateField 4.All example: All records to one file, specify date range. PdForXML.exe all --startdate 2011/10/01 --enddate 2013/9/8 --directory C:\OutDirectory --server db.example.com\example --database EXAMPLE_DB --login Name --password Password --queryfilename C:\Temp\examplequery.sql --datefieldname CrashDateField 5.YearDay example: Records grouped by Year and Day of Month, previous 180 days. PdForXML.exe yearday --priortimeunit days --priortimevalue 180 --directory C:\OutDirectory --server db.example.com\example --database EXAMPLE_DB --login Name --password Password --queryfilename C:\Temp\examplequery.sql --datefieldname CrashDateField 6.YearDay example: Records grouped by Year and Day of Month, specify date range. PdForXML.exe yearday --startdate 2011/10/01 --enddate 2013/9/8 --directory C:\OutDirectory --server db.example.com\example --database EXAMPLE_DB --login Name --password Password --queryfilename C:\Temp\examplequery.sql --datefieldname CrashDateField Example SQL QuerySELECT c.CaseId as CaseId, c.Date as Date, 'CO' as State, s1.StreetName as PrimaryStreet, s2.StreetName as CrossStreet FROM Crash c LEFT JOIN Streets s1 ON (s1.StreetId = c.PrimaryStreetId) LEFT JOIN Streets s2 ON (s2.StreetId = c.CrossStreetId) WHERE --{PdWhere} ORDER BY PrimaryStreet, CrossStreet, c.CaseId FOR XML PATH( 'Crash' ), ROOT( 'Crashes' )
Example Case Id QuerySELECT CaseId FROM Crash WHERE --{PdWhere} The query examples above each contain "--{Pdwhere}" in their WHERE clauses. This will be replaced with the appropriate date range during processing. If another WHERE clause needs to be included, prepare it such that PdWhere can still be inserted. WHERE (Jurisdiction = 123) AND --{PdWhere} |