Traction
Of course, every ‘eureka‘ tends to be followed by a few things which bring you back to earth. The first attempt to load the entire set of ST1s, right through to present, went deceptively well. Turns out, though, the use of T-SQL TRY...CATCH syntax without a RAISERROR statement in the CATCH block was swallowing up errors. Including ones which needed attention. On the bright side, though, ERCB.dtsx still read a vast majority of the ST1s, and at the end of it all, there were something like 150,000+ unique wells in the database. But most importantly, it really felt like there was traction on the problem — this Alberta data is going to be on Google Earth sooner, rather than later.
There were also a few surprises with the source data downloaded from the ERCB. The big one was the ‘reiterated’ records described in That Light at the End of the Tunnel… turned out to be a passing trend. The last one showed up was 2004-03-19 (reiterationEndDt). After this, the ERCB went back to the earlier approach of stating the amendment information at the bottom of the ST1 only. Actually, there was exactly one more, on 2007-08-01, but something funny was going on because there were other parts of the same record which appeared to have been edited ‘by hand’. In all of the ST1s, there was no other reference to the license number (0380046), so the August oddball was simply edited from AMENDMENT to NEW. Similarly, there was exactly one situation where a given license (0024639) referenced two different wells. Well, two different producing zones, but they have different unique identifiers. These bits of ERCB whimsy almost brings a tear to my eye. Or maybe it just makes we want to cry, I’m not sure.
Along the same lines, in addition to NEW, AMENDMENT, RESUMPTION and RE-ENTRY identified as possible values for the WELL PURPOSE field on the ST1, another one showed up; DEEPENING, which appeared in 51 ST1s. TRAINING showed up as a well type exactly once, as well. And there was some truly duplicate data (license 0302041), a few six digit license numbers and some incomplete well identifiers, but nothing that couldn’t be sorted out, one way or another.
On another note, the primary key for E._WellDetail is uid_Well, at the end of the table, which seems like a break from the standard. It’s not, really, and thus warrants a little explanation. There’s a one-to-one relationship between E.Well and E._WellDetail, so uid_Well is both the foreign key back to E.Well, and the primary key. Instances of E._WellDetail exist solely at the pleasure of E.Well. For that reason, the trigger E.WellInsertTrg creates a stub instance of E._WellDetail when an instance of E.Well is created. The foreign key is configured so a deletion of an E.Well instance cascades onto E._WellDetail. It should never be necessary to INSERT or DELETE an instance of E._WellDetail directly. So why have two tables, then? Simple — keeping normalized and denormalized data separate.
Code Shavings In addition the above, a few other miscellaneous items; The seq column was added was added to ERCB.LicenseRecord table, and was made a computed column. It looks at statusCd, and if it’s an AMD (amended) , it changes seq to 1. If it’s CNC, it changes seq to 2. Otherwise, it’s zero. It is used to ensure the amendment and cancellation records are sequenced correctly in the ERCB.LicenseRecordRecent. Speaking of which, the latter is the VIEW which looks at ERCB.LicenseRecord and filters out all but the most recent (hence the name) instance for each well license. The scalar-valued, user-defined function ERCB.getLicenseRecordAmt() returns the total number of records which need to be handled by ERCB.putLicenseRecord. If it returns zero, there’s nothing to do, and the rest of the logic in the stored procedure can be skipped.
Posted on 27th June 2008
Under: Developers' Journal | No Comments »
