I was bitching a blue streak about this issue in CB and realized I needed input on this, just in case my head's not on straight.

I get 10 files a month. They generally report the ongoing state of a list of accounts, each a monthly snapshot.

For the sake of argument, let's assume I can cobble together a primary key for these files, be it an explicit account number or a string composite of fields.

I'm merging these things into one table that looks more or less as follows:

table account_stuff account_id int, source_file varchar, host_key varchar(huge), open_date date, close_date date
The idea is to create generic account ids (a new field that I'm generating) to correspond to each account across the 10 files as needed, based on a monthly load proccess.

So the open_date corresponds to either "the date that the account started showing up in the file" or "the open date specified in the file" (if one exists.)

Close date is as you'd figure, optimistically the 'specified close date' or, more interestingly "the last month in which the account appeared on an input file."

I'm cobbling this together now. But the rough pseudocode in my head seems a bit gross for reasons I can't quite put my finger on. It smells funny:

- For each input file that's loaded - Check it's list of primary keys against the account_stuff host_key for a match. - If there's not a match, add a row. - Check the list of account_stuff 'source_file's host_keys against t +he imported file. - If there are missing rows, update with a close_date
So basically it looks like "left outer join, test for nulls, then right outer join and test for nulls."

I was going to drive this entirely in perl, but it's starting to look like I could slap it into a series of stored procs.

What am I missing here?


In reply to Assigning account numbers, intuiting open and close dates by Voronich

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.