I ran into a problem with mySQL (if that is what you are using) where the max_allowed_packet variable on the server was set to something around 1,048,576 bytes`.
Although your code is not reflecting this... but it appears you put some debug code together to get the rows after 968000. If the grab before was a whole grab then this would maybe apply, otherwise it will not.
If the total number of characters in the query with related_column is more than that(the default value of max_allowed_packet, you should split it into smaller parts and try again?
I did this and set it to 16MB.
--set-variable=max_allowed_packet=16M
Comment on Re: DBD::ODBC won't read past a certain record
Thanks, but I don't think this is the problem. As I said above, this is with SQL Server, and I'm only reading one record at a time (I've tried reading just the TransactionID field, as suggested by one of the other responses, with the same result).