Page 1 of 1

FWMARIADB: RowSet class error when inserting a new record

Posted: Fri Mar 16, 2018 4:02 pm
by vinhesoft
Mr.Rao,

error when inserting a new record, when primary key is numeric

table structure:

CREATE TABLE `admd0013` (
`CODGRU` INT (3) NOT NULL AUTO_INCREMENT,
`NOMGRU` VARCHAR (30) NULL DEFAULT NULL,
`ALTERA` DATE NULL DEFAULT NULL,
PRIMARY KEY (`CODGRU`)
)

oGrupos := oDB:Query( 'select * from ADMD0013 where CODGRU = ?',{0} )
...
oGrupos:ReQuery({27})
...
oGrupos: Append ()
oGrupos: NOMGRU: = cNOMGRU
oGrupos: ALTERA: = date ()
oGrupos: save () << error happens here
...

Error:

Application
===========
   Path and name: F: \ Systems \ WinADMplus \ WinADM.exe (32-bit)
   Size: ********* bytes
   Compiler version: Harbor 3.2.0dev (r1801051438)
   FiveWin version: FWH 18.02
   C compiler version: Borland / Embarcadero C ++ 7.0 (32-bit)
   Windows version: 6.1, Build 7601 Service Pack 1

   Time from start: 0 hours 1 mins 10 secs
   Error occurred at: 03/16/2018, 11:50:09
   Error description: BASE error / 1132 Bound error: array access
   Args:
     [1] = A {...} length: 1
     [2] = N 2

Stack Calls
===========
   Called from:. \ Source \ internal \ FWMARIA.PRG => FWMARIAROWSET: PRIMARYVAL (2339)
   Called from:. \ Source \ internal \ FWMARIA.PRG => FWMARIAROWSET: REQUERY (3114)
   Called from:. \ Source \ internal \ FWMARIA.PRG => FWMARIAROWSET: RESYNC (3407)
   Called from:. \ Source \ internal \ FWMARIA.PRG => FWMARIAROWSET: SAVE (3902)
   Called from: ADMP1190.PRG => SAVE (172)

Re: FWMARIADB: RowSet class error when inserting a new record

Posted: Fri Mar 16, 2018 6:00 pm
by nageswaragunupudi
I have tried to reproduce the error at my end, but for me, it is working correctly. This is my test program run on FWH Demo Server.

Code: Select all

#include "fivewin.ch"
function Main()

   local oCn, cSql, oGroups

   oCn   := FW_DemoDB()

   if oCn:TableExists( "admd0013" )
      oCn:DropTable( "admd0013" )
   endif

   ? "Create Table"

TEXT INTO cSql
CREATE TABLE `admd0013` (
 `CODGRU` INT (3) NOT NULL AUTO_INCREMENT,
 `NOMGRU` VARCHAR (30) NULL DEFAULT NULL,
 `ALTERA` DATE NULL DEFAULT NULL,
 PRIMARY KEY (`CODGRU`)
)
ENDTEXT

   oCn:Execute( cSql )


   XBROWSER ( oGroups := oCn:admd0013 )

   // Add Record 1
   oGroups:Append()
   oGroups:NOMGRU := "Some name"
   oGroups:ALTERA := date()
   oGroups:save()

   // Add Record 2
   oGroups:Append()
   oGroups:NOMGRU := "Second name"
   oGroups:ALTERA := date()
   oGroups:save()

   XBROWSER oGroups

   oGroups:Close()

   oCn:DropTable( "admd0013" )
   oCn:Close()

return nil
 
You can copy the above program, build and run as it is.

Image

I request you to please help me to reproduce the problem. For this purpose, you can use our demo server as in the above program. Please change or modify the above program to reproduce the error.

Re: FWMARIADB: RowSet class error when inserting a new record

Posted: Fri Mar 16, 2018 6:09 pm
by vinhesoft
the error happens only if there is a Requery before insertion:

Look

oGrupos := oDB:Query( 'select * from ADMD0013 where CODGRU = ?',{0} )
...
oGrupos:ReQuery({27})
...
oGrupos: Append ()
oGrupos: NOMGRU: = cNOMGRU
oGrupos: ALTERA: = date ()
oGrupos: save () << error happens here
...

Re: FWMARIADB: RowSet class error when inserting a new record

Posted: Fri Mar 16, 2018 6:36 pm
by nageswaragunupudi
This is the modified program.

Code: Select all

function ForumTest

   local oCn, cSql, oGroups

   oCn   := FW_DemoDB()

   if oCn:TableExists( "admd0013" )
      oCn:DropTable( "admd0013" )
   endif

   ? "Create Table"

TEXT INTO cSql
CREATE TABLE `admd0013` (
 `CODGRU` INT (3) NOT NULL AUTO_INCREMENT,
 `NOMGRU` VARCHAR (30) NULL DEFAULT NULL,
 `ALTERA` DATE NULL DEFAULT NULL,
 PRIMARY KEY (`CODGRU`)
)
ENDTEXT

   oCn:Execute( cSql )

   oGroups  := oCn:RowSet( "SELECT * from admd0013 WHERE codgru = ?", { 0 } )
   oGroups:ReQuery( { 27 } )

   XBROWSER oGroups

   // Add Record 1
   oGroups:Append()
   oGroups:NOMGRU := "First name"
   oGroups:ALTERA := date()
   oGroups:save()

   // Add Record 2
   oGroups:Append()
   oGroups:NOMGRU := "Second name"
   oGroups:ALTERA := date()
   oGroups:save()

   XBROWSER oGroups

   oGroups:Close()

   XBROWSER oCn:admd0013

   oCn:DropTable( "admd0013" )
   oCn:Close()

return nil
 
Please run this program as it is. I am still not getting any error.
First please build and run this program without changes.
Then modify this program to reproduce the error.

Re: FWMARIADB: RowSet class error when inserting a new record

Posted: Fri Mar 16, 2018 7:16 pm
by nageswaragunupudi
Mr João Carlos

I found the problem now.
Please give me some time.
We will come back with a proper solution to the issue.

Re: FWMARIADB: RowSet class error when inserting a new record

Posted: Fri Mar 16, 2018 7:32 pm
by vinhesoft
Mr Rao

Ok, I'll be waiting

thank you

Re: FWMARIADB: RowSet class error when inserting a new record

Posted: Mon Apr 16, 2018 7:05 pm
by vinhesoft
up