Whatever the primary key is in that database, you're trying to insert
a duplicate.

Tom

At 7/14/00 05:30 PM, you wrote:
>Below is an error Im getting from a transaction that I didn't write...
>and the developer is long since gone...he sort of documentmented
>his code...but not really.  This is the result from a form input.
>
>Below the result...is the transaction statement.
>
>Below the transaction statement is a function the developer used to
>increment a new record in the table nxstar_e...am I wrong ?  Its used
>as an includes BEFORE the transaction statement gets called and thats
>where the problem exists.  Hence the error message below.  Would
>someone like clue me into what in the hell is going on here...I think
>Im outta my depth.  Ive pulled this thing apart six ways from sunday
>and it still doesn't work...perhaps it never worked...I dont know.
>
>Help
>
>++++++++++++++++++++++++++++++
>ODBC Error Code = 23000 (Integrity constraint violation)
>
>[Microsoft][ODBC SQL Server Driver][SQL Server]Violation of PRIMARY KEY
>constraint 'PK__nxstar_e__076C2375': Attempt to insert duplicate key
>in object 'nxstar_e'.
>
>SQL = "insert into nxstar_e ( tar_num, type, tar_status, synopsis, 
>description,
>prod_id, symptom_code, cust_code, bus_name, address1, address2,
>address3, address4, contact, phone, entered_by, entered_date,
>entered_time, opened_date, opened_time, priority, assigned_to,
>assigned_by, assigned_date, assigned_time ) values
>( 5456, 'CASE', 'NEW', 'sdsdfsdfsdf', 'sdfsdfsdfsdfsdfsdfsdfsdf', ----etc...)
>
>Data Source = "CCare Web"
>
>The error occurred while processing an element with a general
>identifier of (CFQUERY), occupying document position (23:1) to (23:52).
>+++++++++++++++++++++++++++++++
>
>+++++++++++++++++++++++++++++++
><cftransaction>
>
><cfset lsTableName = "nxstar_e">
><cfset lsColumnName = "tar_num">
><cfinclude template = "../common/cc_get_nextid.cfm">
><cfset lsODBCDate = '#CreateODBCDate("#Now()#")#'>
><cfset lsTime = '#TimeFormat("#Now()#", "HH:MM:SS")#'>
>
><cfset llTarNum = #llNextID#>
>
><cfquery name="qInsertCase" datasource="#DSNCCare#">
>insert into nxstar_e (
>tar_num, type,
>tar_status, synopsis, description,
>prod_id,
>symptom_code,
>cust_code, bus_name, address1,
>address2, address3, address4,
>contact, phone,
>entered_by, entered_date, entered_time,
>opened_date, opened_time,
>priority,
>assigned_to, assigned_by, assigned_date, assigned_time
>)
>values
>(
>#llTarNum#, 'CASE',
>'NEW', '#synopsis#', '#description#',
><cfif '#prod_id_other#' is not ''>
>   '#prod_id_other#',
><cfelse>
>   '#prod_id#',
></cfif>
>'#symptom_code#',
>#cust_code#, '#qCustomer.bus_name#', '#qCustomer.address1#',
>'#qCustomer.address2#', '#qCustomer.address3#', '#qCustomer.address4#',
>'#Contact_Name#', '#phone#',
>'WEB', #lsODBCDate#, '#lsTime#',
>#lsODBCDate#, '#lsTime#',
>2, 'WEB', 'WEB', #lsODBCDate#, '#lsTime#'
>)
></cfquery>
>
><cfset lsTableName = "nxsnotes">
><cfset lsColumnName = "note_id">
><cfinclude template = "../common/cc_get_nextid.cfm">
><cfset lsODBCDate = '#CreateODBCDate("#Now()#")#'>
><cfset lsTime = '#TimeFormat("#Now()#", "HH:MM:SS")#'>
>
><cfquery name="qInsertActivity" datasource="#DSNCCare#">
>insert into nxsnotes (
>note_id, id, topic, type,
>synopsis,
>entered_by, entered_date, entered_time,
>opened_date, opened_time,
>completed, completed_by, completed_date, completed_time,
>minutes_spent, billable
>)
>values
>(
>#llNextID#, #llTarNum#, 'CASE', 'CCARE',
>'Time spent adding New Case',
>'WEB', #lsODBCDate#, '#lsTime#',
>#lsODBCDate#, '#lsTime#',
>'CCARE', 'WEB', #lsODBCDate#, '#lsTime#',
>1, 'N'
>)
></cfquery>
>
></cftransaction>
>
>++++++++++++++++++++++++++++++++
>
><cfquery name="qGetLastUsed" datasource="#DSNCCare#">
>select last_used
>from nxsprimr
>where table_name = '#lsTableName#'
>and column_name = '#lsColumnName#'
></cfquery>
>
><cfif IsNumeric(qGetLastUsed.last_used)>
>   <!-- A row was found in the primary key table -->
>   <!-- Increment the value and update the table -->
>
>   <cfset llNextID = qGetLastUsed.last_used + 1>
>
>   <cfquery name="qUpdatePrimary" datasource="#DSNCCare#">
>   update nxsprimr
>   set last_used = #llNextID#
>   where table_name = '#lsTableName#'
>   and column_name = '#lsColumnName#'
>   </cfquery>
>
><cfelse>
>   <!-- A row was not found in the primary key table -->
>   <!-- We need to create the row -->
>
>   <cfquery name="qGetMax" datasource="#DSNCCare#">
>   select max(#lsColumnName#) mymax
>   from #lsTableName#
>   </cfquery>
>
>   <cfset llNextID = qGetMax.mymax + 1>
>
>   <cfquery name="qInsertPrimary" datasource="#DSNCCare#">
>   insert into nxsprimr (table_name, column_name, last_used)
>   values ('#lsTableName#', '#lsColumnName#', #llNextID#)
>   </cfquery>
></cfif>
>------------------------------------------------------------------------------
>Archives: http://www.mail-archive.com/[email protected]/
>To Unsubscribe visit 
>http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or 
>send a message to [EMAIL PROTECTED] with 'unsubscribe' in 
>the body.


------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to