I have a table with millions of records which holds information about a user, his or her documents in a BLOB, and a column holding the file size per row. While reporting I need to extract all these records along with their attachments and store them in a folder. However, the constraint is that the folder size should not exceed 4GB.
What I need, is to fetch records only till that record, where the summation of file sizes is less than 4GB. I have hardly any experience in databases, and do not have any DB expert to refer.
for eg - say i need to fetch only records till sum(fileSize) < 9
Name fileSize
A 1
B 2
C 3
D 2
E 9
F 4
My query needs to return records A,B,C and D. Also, i need to store the rowID/uniqueID of the first and last record for another subsequent process. The DB being used is IBM DB2.
Thanks!