Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, June 20, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Having trouble with a statement keep getting error number:-2147217873
Mario
Posts: 6
 
Having trouble with a statement keep getting error number:-2147217873Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Oct 07 11:06 AM
I keep getting this error when inserting a new sale into our database. This is a custom table specific to our sales form. I keep getting this error:
procedure Name: ExecuteSQL
Error Number: -2147217873
Error description: The statement has terminated. :Cannot insert duplicate key row in object 'History' with unique index 'XPKHISTORY'

thanks
[Reply][Quote]
Darron Cockram
Posts: 8
 
Re: Having trouble with a statement keep getting error number:-2147217873Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Oct 07 12:34 PM
Hi Mario,

It means that you are trying to add a record to the history table but the historyid you are trying to insert already exists in the table. How are you generating your historyid?

HTH
Darron
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Having trouble with a statement keep getting error number:-2147217873Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Oct 07 12:34 PM
Mario:


This error is coming from the DB, and it is indeed telling you that you are not inserting unique records as per defined on the referred index/constraint.

I would suggest you first determine what you are trying to insert and why it doesn't get past the Constraint:

- Analyze the XPKHistory index and determine what fields need to be unique.
- Run the SLXProfiler to capture your SQL statements and examine them closer to figure out what is going on.
[Reply][Quote]
Mario
Posts: 6
 
Re: Having trouble with a statement keep getting error number:-2147217873Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Oct 07 12:51 PM
this is what i am using: application.BasicFunctions.getidfor("History")
[Reply][Quote]
Darron Cockram
Posts: 8
 
Re: Having trouble with a statement keep getting error number:-2147217873Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 05 Oct 07 2:51 AM
Hi Mario,

Normally that should be fine for generating a new ID. However I have seen problems if records are bundled from one system and inserted into another. This is because Id's in the sitekeys table do not get updated to reflect the Ids used in the bundled records. Could this be the problem in your case? Check on the ID that is getting generated (just attach a debugger and step through the code or simply add a MsgBox to your code). To determine if it is already exists in the history table run the query:

SELECT Count(HistoryId) FROM History WHERE HistoryId = ''

If the query returns 1 the Id has already been used and records must have been inserted without updating the sitekeys table in which case you'll need to manually update it to fix the problem.

One other possibility that springs to mind is that there is a typo in your code on the line that generates the Id but you have used On Error Resume Next. This means that the Id used in your SQL insert would be an empty string. This would run OK once but subsequent runs would fail due to the fact there is already a HistoryId record with an ID of '' in the table. You can tell if this your problem by checking on the Id that is being generated as previously mentioned. If it's blank there's a problem in the code.

HTH.
Darron
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 6/20/2025 2:44:00 PM