tags:

views:

42

answers:

1

Hi there,

I'm writing some code behind some spreadsheets and I need to loop through some code, like getting data from a database doing some formulas and moving the data to a new sheet. My code for getting the data from the database is getting all of the values in multiple columns where the data has not been reported and has the same file name ( the data is coming from a file ), I have a field which states whether or not it has be reported by a simple "Y" or "N", and a field which holds the filename it came from.

So I need a while that, "WHILE" there's data that hasn't been reported do the rest of my code ( this includes my first SQL statement I said as this get data that hasn't been reported from each individual filename ).

I've been trying to get this to work for days but just have not been able to figure out how, so any help would be very grateful.

Update:

Database has a entity called datareported, can either be "N" or "Y", and also datadatfile which is the name from which the data came from.

So,

WHILE datareported = 'N' THEN
"SELECT (the data rows I want)
FROM tbldata
WHERE datareported='N' and datadatfile =
(SELECT min(datadatfile)
    FROM tbldata WHERE datareported='N')"

This means that I loop through the rest of my code WHILE there is data that hasn't been reported and only bring in data of the same name ( from datadatfile ) so that the code can be run on that data.

That's basically what I want to do and that's pretty much what I have tried. I have tried a few other things and normally get a return of type mis-match.

Cheers,

Sam