Welcome! Log In Create A New Profile

Advanced

HModify statement giving error

Posted by Prolay Sarkar 
Prolay Sarkar
HModify statement giving error
January 26, 2009 04:44PM
Hi,

I have a problem modifying record in a database. When i try to desiralize the record and directly do HModify it gives me a error so i tried this method it works fine sometimes and sometimes it doesn't. HRecNum = 0

Deserialize(customer,buff,psdXML)
HReadSeek(core_customer,PK_core_customer,["1","123"])
IF HFound() THEN
nr=HRecNum(core_customer)
MemoryToFile(customer,core_customer)
IF HModify(core_customer,nr) THEN // The error occurs here
resultstring="True"
ELSE
resultstring="False"
END
END

What is the proper way to modify a record. This function is in web service. Should HModify work directly ??

Regards,
Prolay
DerekT
Re: HModify statement giving error
January 26, 2009 07:32PM
Prolay

What error do you get?

Are you getting the correct REcNum ?
HReadSeekFirst is a generic search and will return a record where the search is greater than or equal to a sought value.

Try using HReadSeekFirst for an identical search.

Regards

DerekT
Prolay Sarkar
Re: HModify statement giving error
January 26, 2009 07:59PM
Hi Derek,

Error is "duplicate error" and i am getting hrecnum as 0 and Hfound is also true..so confused!!


Regards,
Prolay
Fabrice Harari
Re: HModify statement giving error
January 26, 2009 08:10PM
Hi...

duplicate errors means that you are modifying the value of a unique key INTO a value already existing in the file (ie of another record), which means that you ahve a LOGICAL error in your process

Best regards

Prolay Sarkar
Re: HModify statement giving error
January 26, 2009 08:22PM
Hi ,

I have checked it throughly. I am not changing the key values

Regards,
Prolay
DerekT
Re: HModify statement giving error
January 26, 2009 09:23PM
Prolay

I do not want to argue but if you are getting a duplicate error the 'Yes you are'.

That's why I said to use HreadSeekFirst()

If you are getting the incorrect record from HreadSeek() then your HModify will be trying to update the UniqueID of the record in memory with the UniqueID of the record in your array - ergo Duplicate Key Error.

Check through step by step in the debugger and make sure you are getting the correct record although as this is an intermittent error it may take some time.

Try changing your code to.....
Deserialize(customer,buff,psdXML) 
IF NOT HReadSeekFirst(core_customer,PK_core_customer,["1","123"])  THEN
     Error("Your Error message")
ELSE
     MemoryToFile(customer,core_customer) 
     IF NOT HModify(core_customer) THEN
          resultstring="True" 
     ELSE 
          resultstring="False" 
     END 
END

Hope this helps

DerekT
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: