NetTalk Central

Author Topic: Duplicate Check broken between 5.01 and 5.05??  (Read 2765 times)

Neil Porter

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Duplicate Check broken between 5.01 and 5.05??
« on: December 09, 2010, 03:32:59 AM »
Unfortunately I think I might have found a bug in 5.05. I always tend to assume that I’m doing something wrong when something doesn’t work, but in this case I’m getting distinctly different results between version 5.01 and 5.05 versions of the webserver templates, which makes me think that Bruce might have changed something.

I’ve upgraded to 5.05 as it appears to fix a problem that I was having with trying to display a popup browse (I’ve embedded a browse into a popup form, and that seems to work ok with this version). Unfortunately I’ve just found that every time I try to insert a new record in to one of my SQL tables I get a “Creates Duplicate Key” error on my primary key. Exactly the same app, and the same database with 5.01 works fine and allows the insert without the error.

A bit of background: I’m using MSSQL 2005/2008. I have a JOBID column that is an SQL identity field. I have a Primary Key on that field which is also my unchanging key in my netwebform. I have the EmulateAutoNumKey value set to 1 in my dictionary.

I have child browses that I need to populate during the insert of my parent record, so I have both the “prime Auto Inc if necessary” and “Prime Auto Inc even if not necessary” ticked, and I don’t have the “Ignore Key being not unique” ticked, although this doesn’t seem to have any effect either way.

I can’t see any difference between the generated code in the Check For Duplicates routine, with either template, so I’m not quite sure where to go now. Has anyone else seen this problem?

TIA,

Neil Porter
Clarion 11.0.13244
NetTalk 11.04

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11204
    • View Profile
Re: Duplicate Check broken between 5.01 and 5.05??
« Reply #1 on: December 09, 2010, 05:35:39 AM »
Hi Niel,

I've fixed an auto-increment bug in 5.06, so as soon as I have that up I'll let you know.
I'm not sure if it's the same thing, but it's a good place to start.

cheers
Bruce

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11204
    • View Profile
Re: Duplicate Check broken between 5.01 and 5.05??
« Reply #2 on: December 09, 2010, 05:37:04 AM »
In the meantime you can test the fix to see if it works for you;

In NetWEb.Tpw, find the line

p_web.formsettings.action = Loc:Act

replace that 1 line with the following 5 lines;

    if p_web.GetSessionValue('%Procedure:Primed') = 1
      p_web.formsettings.action = Net:ChangeRecord
    Else
      p_web.formsettings.action = Loc:Act
    End


Let me know.

cheers
Bruce

Neil Porter

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Duplicate Check broken between 5.01 and 5.05??
« Reply #3 on: December 09, 2010, 07:05:49 AM »
Hi Bruce,

I've made the change to the template, and recompilled. I'm afraid that it doesn't seem to have fixed error.

Regards,

Neil
Clarion 11.0.13244
NetTalk 11.04

Neil Porter

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Duplicate Check broken between 5.01 and 5.05??
« Reply #4 on: December 10, 2010, 02:47:52 AM »
HI Bruce,

I've done some further digging now, and you are quite correct, that it is that section from netweb.tpw that seems to be causing the problem. Even with your suggested modification i still get an error, but if I remove the whole section in red it seems to work fine.

  If p_web.Formstate = ''
    p_web.formsettings.file = 'Jobs'
    p_web.formsettings.key = 'JOB:PK_Jobs'
      clear(p_web.formsettings.FieldName)
    p_web.formsettings.recordid[1] = p_web.RestoreValue('JOB:JobID')
    p_web.formsettings.FieldName[1] = 'JOB:JobID'
    IF p_web.GetSessionValue('UpdateJobs:Prime') = 1
      p_web.formsettings.action = Net:ChangeRecord
    ELSE
      p_web.formsettings.action = Loc:Act
    END

    If p_web.GetValue('_parentPage') <> ''
      p_web.formsettings.parentpage = p_web.GetValue('_parentPage')
    else
      p_web.formsettings.parentpage = 'UpdateJobs'
    end
    p_web.formsettings.proc = 'UpdateJobs'
    p_web.FormState = p_web.AddSettings()
  end
  if loc:viewonly and p_web.IfExistsValue('LookupField')
    packet = clip(packet) & p_web.CreateInput('hidden','LookupField',p_web.GetValue('LookupField')) & '<13,10>'
  end
  packet = clip(packet) & p_web.CreateInput('hidden','FormState',p_web.FormState) & '<13,10>'
 
My only concern, is that in removing these lines, it may impact somewhere else, that isn't immediately obvious to me.

Regards,

Neil.
Clarion 11.0.13244
NetTalk 11.04

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11204
    • View Profile
Re: Duplicate Check broken between 5.01 and 5.05??
« Reply #5 on: December 10, 2010, 05:18:46 AM »
I don't think you can remove that whole block. If p_web.formsettings.action is not set, then nothing will happen when you click on the Save Button (in some/many cases.)

I think the next step is if you can put some example together for me.

cheers
Bruce