NetTalk Central

Author Topic: c8/nt5.33 Repeat Inserts Funny  (Read 3823 times)

hilton

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
c8/nt5.33 Repeat Inserts Funny
« on: September 01, 2011, 01:35:56 PM »
Hi Bruce,

I have noticed another funny when doing multiple inserts.  Whilst I have a workaround for the problem, it struck me that it might be of interest to you.

I have a Netwebform that contains:
1. a field for entering a customer code
2. a field for entering a date
3. a NetwebBrowse to show customer adjustments from the date entered for the customer entered.  If no customer entered, then all adjustments.
4. the browse has a related updateprocedure
5. if a specific customer is entered in 1 above then the update form will use this code assuming that this is the customer for which you want to enter the adjustment(if not you can change it).
6. if we assume that you want to enter 3 adjustments for the same customer, the first insert is fine, the second insert is fine, however, after the second insert both the fields in 1 and 2 above are cleared which means that the customer in the update form reverts to zero.

I spent quite a lot of time trying to fathom it out but could not.  At no stage in the code do I clear the fields in 1 and 2 out.  I am letting you know just in case it rings a bell with you with other reported happenings.  As I said, I have a workaround, but I can see that it could be problematical.  I will keep my eyes wide open to see if it happens in similar circumstances as I will be using the technique again.

Bye,
Hilton.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: c8/nt5.33 Repeat Inserts Funny
« Reply #1 on: September 01, 2011, 10:59:34 PM »
any chance you can make an example for me Hilton?

cheers
Bruce

hilton

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: c8/nt5.33 Repeat Inserts Funny
« Reply #2 on: September 04, 2011, 12:44:47 AM »
Hello Bruce,

As soon as I am able I will try to create a small example and let you have it.

Bye,
Hilton.

hilton

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: c8/nt5.33 Repeat Inserts Funny
« Reply #3 on: September 04, 2011, 01:58:46 AM »
Hi Bruce,

I think I can see why it is happening.

Each time a multiple insert is done(in the browse's update procedure), the code somehow goes back to the parent Netwebform that contains all the objects(including the browse and it's related update procedure) and as a minimum performs the routine STOREMEM.  There it performs the code:

  if p_web.IfExistsValue('loc:CustomerCode') = 0
    p_web.SetSessionValue('loc:CustomerCode',loc:CustomerCode)
  Else
    loc:CustomerCode = p_web.GetSessionValue('loc:CustomerCode')
  End

This results in the loc:CustomerCode session value being set to zero for the second iteration of the update procedure.

To solve the problem, I have put the following code in the embed point just prior to the code above:

 If p_web.ifExistsValue('loc:CustomerCode') = 0 then
    p_web.SetValue('loc:CustomerCode',p_web.gsv('loc:CustomerCode'))
 end

This means that I have had to set loc:CustomerCode up again so that it will end up in the sessionvalue loc:CustomerCode and therefore flow thru to the update procedure in the browse.  This added code solves the problem quite nicely.

Just in case the above makes the problem clear to you, I will hold off creating an example.  I hope that my explanation is not too clumsy.

Bye,
Hilton.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: c8/nt5.33 Repeat Inserts Funny
« Reply #4 on: September 05, 2011, 05:34:31 AM »
I'd really like that example Hilton - I think it'd make a lot of your explanation a bit easier to understand <g>.

cheers
Bruce

hilton

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: c8/nt5.33 Repeat Inserts Funny
« Reply #5 on: September 06, 2011, 12:09:19 AM »
Hi Bruce,

Attached are two zip files of the app and files etc plus the dict. The login page is localhost:88/loginform. When you have it running enter m as the user and m as the password.

Under Customer & Related choose Adjustments from the menu.

Enter Customer 7 on the first page and then do an INSERT.  The customer on the insert page will be 7.
Enter a value and Save.  Then Cancel back to the first page(netwebform) and the customer will be 0.  I do not believe that it should be reset to zero it should remain 7.

You will see in the procedure CustAdjustments  routine STOREMEM code that I have commented out(for the sake of the example) to solve the problem.

Any problems by me sending the wrong stuff, please let me know

Bye,
Hilton.

[attachment deleted by admin]