New topic: R2012 treats recordsets differently than prior versions
<http://forums.realsoftware.com/viewtopic.php?t=46381> Page 1 of 1 [ 2 posts ] Previous topic | Next topic Author Message dgdavidge Post subject: R2012 treats recordsets differently than prior versionsPosted: Sat Dec 29, 2012 1:39 pm Joined: Fri Jun 02, 2006 1:43 pm Posts: 172 Location: Santa Ynez, CA I have a meter billing program that prepares invoices. I create a recordset that contains a record with the meter reading the last time that meter was billed and the next record contains the latest meter reading. It has worked without a problem for several years, but fails if I run it in the debugger or compiled with either 2012R1.2, or 2012R2. The logic isrs = db.SQLSelect(sql) while not rs.EOF // use the data (the meter reading last time it was billed) lastRecord = rs.Field("MeterID").IntegerValue rs.movenext if lastRecord = rs.Field("MeterID").IntegerValue then //use the data (the current meter reading) end if wend In earlier version of RS (and RB before RS), this works fine. In the newest version, the rs.movenext advances two records so the program never sees the final meter readings. I can switch back and forth between RS2011R4.3 and RS2012R2 using the same program and the same database and it runs on the earlier one and not on the later one. It appears the new version is treating both sides of the Union as one record instead of two as previously. I have not been able to figure out how to get the data from what was the second record. Is this a bug, or just something I don't understand? This is the SQL string value from the debuggerSELECT A.Name, C.TenCode, B.MeterNo, B.Total, MAX(B.DateTime), (B.LastBilled), B.ReadingID, A.TarifID, A.Selected, A.MeterID, C.TenID FROM Meters A, Readings B, Tenants C WHERE A.Selected = '1' AND B.MeterNo = A.MeterID and C.TenID = A.TenantID and B.LastBilled <> '' GROUP BY A.Name UNION SELECT A.Name, C.TenCode, B.MeterNo, B.Total, (B.DateTime), MAX(B.LastBilled), B.ReadingID, A.TarifID, A.Selected, A.MeterID, C.TenID FROM Meters A, Readings B, Tenants C WHERE A.Selected = '1' AND B.MeterNo = A.MeterID and C.TenID = A.TenantID GROUP BY A.Name ORDER BY C.TenCode, B.MeterNo, B.ReadingID Top DaveS Post subject: Re: R2012 treats recordsets differently than prior versionsPosted: Sat Dec 29, 2012 2:07 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4370 Location: San Diego, CA This code has one other issue. If your rs.movenext passed the EOF the your 2nd rs.field has nothing to read rs.movenext should be the LAST statement inside the loop under this circumstance rs = db.SQLSelect(sql) while not rs.EOF // use the data (the meter reading last time it was billed) lastRecord = rs.Field("MeterID").IntegerValue rs.movenext if lastRecord = rs.Field("MeterID").IntegerValue then //use the data (the current meter reading) end if wend here is how I might handle it.... rs = db.SQLSelect(sql) lastRecord=-99999 // some value that will never occur in real life while not rs.EOF // use the data (the meter reading last time it was billed) CurrentRecord = rs.Field("MeterID").IntegerValue if CurrentRecord=LastRecord then // MeterID has not changed else // MeterID has changed end if lastRecord=Current_Record rs.movenext wend _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 2 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
