|
| Iniciado por gallen.dbmc, 04,ago. 2015 15:23 - 2 respuestas |
| |
| | | |
|
| |
| Publicado el 04,agosto 2015 - 15:23 |
I have a summary table in which I would like to reset some fields to 0 but the following code doesn't seem to work. HExecuteQuery(QRY_GetBurialTypes)
FOR EACH QRY_GetBurialTypes.Burial_Type Sum_Rpt_BurByYear.Male = 0 Sum_Rpt_BurByYear.Female = 0 Sum_Rpt_BurByYear.Child = 0 HReadSeekFirst(Sum_Rpt_BurByYear, Burial_Type, QRY_GetBurialTypes.Burial_Type) IF HFound() = True THEN HModify(Sum_Rpt_BurByYear) ELSE Sum_Rpt_BurByYear.Burial_Type = QRY_GetBurialTypes.Burial_Type HAdd(Sum_Rpt_BurByYear) END END What am I doing wrong? Thanks Garry |
| |
| |
| | | |
|
| | |
| |
| Publicado el 04,agosto 2015 - 15:49 |
Hi Gary,
you are setting the fields to zero, THEN reading the record (hence setting the values from the disk in the fields), then modifying the recod on disk with its original values (hence doing nothing)
Move your MyField=0 lines after the hfoudn and before the hmodify
Best regards -- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting
Already there: WXShowroom.com, WXReplication (open source) Coming soon: WXEDM (open source) More information on http://www.fabriceharari.com
On 8/4/2015 7:23 AM, Garry Allen wrote:
I have a summary table in which I would like to reset some fields to 0 but the following code doesn't seem to work. HExecuteQuery(QRY_GetBurialTypes)
FOR EACH QRY_GetBurialTypes.Burial_Type Sum_Rpt_BurByYear.Male = 0 Sum_Rpt_BurByYear.Female = 0 Sum_Rpt_BurByYear.Child = 0 HReadSeekFirst(Sum_Rpt_BurByYear, Burial_Type, QRY_GetBurialTypes.Burial_Type) IF HFound() = True THEN HModify(Sum_Rpt_BurByYear) ELSE Sum_Rpt_BurByYear.Burial_Type = QRY_GetBurialTypes.Burial_Type HAdd(Sum_Rpt_BurByYear) END END What am I doing wrong? Thanks Garry |
| |
| |
| | | |
|
| | |
| |
| Publicado el 07,agosto 2015 - 15:30 |
Thanks Fabrice. That solves the problem of zeroing out the fields but it seems I'm not out of the woods yet. Now I have to fill them with the correct values. The Next lines of the program are: HExecuteQuery(QRY_BurialPeriod) FOR EACH Qry_BurialPeriod Sum_Rpt_BurByYear.Burial_Type = QRY_BurialPeriod.Burial_Type HReadSeekFirst(Sum_Rpt_BurByYear,QRY_GetBurialTypes.Burial_Type, QRY_BurialPeriod.Burial_Type,hLockWrite) IF HFound = True THEN IF QRY_BurialPeriod.SEX = "M" THEN Sum_Rpt_BurByYear.Male =Sum_Rpt_BurByYear.Male +1 ELSE Sum_Rpt_BurByYear.Female = Sum_Rpt_BurByYear.Female +1 END IF QRY_BurialPeriod.Age < 17 THEN Sum_Rpt_BurByYear.Child = Sum_Rpt_BurByYear.Child +1 END HModify(Sum_Rpt_BurByYear) END END If the query returns an empty data set I would expect that none of the Sum_Rpt_BurByYear records would be updated but that doesn't seem to be the case: in fact it appears to process the entire Burial file. By the way, the QRY_BurialPeriod code is; SELECT RTRIM(burial.Last_Name) +', ' + RTRIM(burial.First_Name) AS cFullName, burial.Sex AS Sex, burial.Burial_Type AS Burial_Type, ROUND(MONTHS_BETWEEN(burial.Death_Date, burial.Birth_Date)/12,0) AS Age FROM burial WHERE burial.Burial_Date BETWEEN {EDT_dStart} AND {EDT_dEnd} ORDER BY cFullName ASC
I set EDT_dStart and EDT_dEnd to values I knew would return no results and printed Reports on both Queries. Sure enough, the 1st report had no data but the 2nd had many non-zero results for Male, Female, and Child |
| |
| |
| | | |
|
| | | | |
| | |
|