Normal Topic Adding new clients - ID frustrations (Read 903 times)
Rebeccafsg
Member
*
Offline


No personal text

Posts: 4
Joined: May 10th, 2004
Adding new clients - ID frustrations
Jun 17th, 2004 at 3:36pm
Print Post Print Post  
Hi,

We were having some programming problems with Sesame, and I thought I had them all under control, but now it seems that when we go to add clients into our database, the id defaults to 1 instead of adding to the last client id.  This has happened since the last Sesame Update so it may be our programming is not compatible with the new version.

the programming we have is:  (for on form entry)

var vID as Int
var temp_id as Int

// adding new Client record
if @IsNew or ID="" or @Add then
{
  temp_id=@GlobalValue("next_id");

  temp_id=temp_id+1

   vID=@tonumber(@XLR(@fn,99999999,"ID,"ID")) + 1
   if (temp_id> vID) then
               {
                     ID=temp_id;
  }
  else
   { ID=vID}

    LastMod=@Date

}

GlobalValue("curr_rec", @FormResultSetCurrentPosition("Main"))

// set global var to current client id
GlobalValue("curr_id", ID)

any suggestions?

Thanks alot!
Rebecca
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Adding new clients - ID frustrations
Reply #1 - Jun 17th, 2004 at 4:24pm
Print Post Print Post  
My counter works fine with the new version. I noticed that you have combined two methods to generate the next ID, namely Globalvalue and xlookupr.  I am not quite clear why you did that. My code is very simple and it does the job.  Normally any one method will give sequential ID.

var vNumber as Int

if @IsNew or Id = "" or @Add then  
{  
vNumber = @tonumber (@xlookupR (@fn, 9999999999, "Id", "Id"))  
Id = vNumber +1  

}

If you want to troubleshoot your code, please debug the code with Writeln ( ) and you would see where it is failing.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Adding new clients - ID frustrations
Reply #2 - Jun 17th, 2004 at 4:44pm
Print Post Print Post  
Quote:
temp_id=@GlobalValue("next_id");


Where did you assign the value for "Next_Id"?  I see the globalvalue assigned to Curr_ID and Curr_Rec variables.

temp_id is integer variable and @globalvalue ("Next_Id") will give you string value, so I believe, you will have to use @tonumber to convert it to number just as you did it with @xlr code.

temp_id= @tonumber (@GlobalValue("next_id"));

These are just my initial thoughts before really testing the code.

  
Back to top
 
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
ReRe: Adding new clients - ID frustrations
Reply #3 - Jun 17th, 2004 at 4:45pm
Print Post Print Post  
Rebecca,

Your missing a double quote in the below statement. This is probably retuning a "0 + 1".

(@XLR(@fn,99999999,"ID,"ID"))

Let us know how it goes.

Steve
  
Back to top
IP Logged
 
Rebeccafsg
Member
*
Offline


No personal text

Posts: 4
Joined: May 10th, 2004
Re: Adding new clients - ID frustrations
Reply #4 - Jun 18th, 2004 at 4:35pm
Print Post Print Post  
Hi,

Thanks for your suggestions...

Steve, that was a typo in my post, not the actual code... Smiley  my bad.

I actually just changed temp_id=@GlobalValue("next_id") to temp_id=@GlobalValue("curr_id")

and that seems to have fixed it up...  I actually didn't write the original code on this, I'm just taking over for the previous position and learning along the way.

Would there be any foreseeable problems with what I've changed?  Right now it looks like it's working but there could be something that I don't know... just a wonderment on my part.

Thanks again!
Rebecca
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Adding new clients - ID frustrations
Reply #5 - Jun 18th, 2004 at 6:24pm
Print Post Print Post  
Quote:
Would there be any foreseeable problems with what I've changed?  Right now it looks like it's working but there could be something that I don't know... just a wonderment on my part.



Rebecca,

If there is any reference of it in the code somewhere, it might affect. It is hard to say without looking at the complete programming. However, I would not worry about it if this code was only meant to produce sequential ID.
  
Back to top
 
IP Logged