Sounds like Pollid is linked to another table. If there are any
relationships or existing data you'll have to work within those constraints.

Maybe inserting data into the other table first then into the other one?

J.


John Wilker
Web Applications Consultant
Allaire Certified ColdFusion Developer

Office: 909-943-8428
www.billtracker.org <http://www.billtracker.org>


-----Original Message-----
From: sebastian palmigiani [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 16, 2001 4:38 PM
To: CF-Talk
Subject: I'm stumped


I get the following error with a stored procedure. I am using CF 4.0. What
is stumping me is that when I run the query in the analyzer it works. For
example, this work:


INSERT INTO PollMembers
(PollID, MemberID, MyVote, LastUpdate)
VALUES('MC-03-5-2001-14-33-22', 'PWOO2', 'A', GetDate())

--------------------
ODBC Error Code = 23000 (Integrity constraint violation)

[Microsoft][ODBC SQL Server Driver][SQL Server]INSERT statement conflicted
with COLUMN FOREIGN KEY constraint 'FK_PollMembers_Polls'. The conflict
occurred in database 'arica', table 'Polls', column 'PollID'.

SQL = "spInsertMyVote"

Data Source = "arica"

The error occurred while processing an element with a general identifier of
(CFSTOREDPROC), occupying document position (92:1) to (93:33).
------------------

The Tables are:

Polls                   PollMembers                Members
PollID VARCHAR(25) PK   PollID VARCHAR(25) FK      MemberID CHAR(10) PK
PollName                MemberID CHAR(10) FK       FirstName
etc.                    etc                        etc

I have triple checked the relationships and they are fine.

Here is the stored procedure in CF:

--------------------
<cflock name="SESSION.SessionID" timeout="10">
<cfset MemberID = SESSION.MemberID>
</cflock>

<cfstoredproc procedure="spInsertMyVote"
              datasource="arica">

<cfprocparam type="In"
             cfsqltype="CF_SQL_VARCHAR"
             dbvarname="@PollID"
             value="TRIM(FORM.PollID)">

<cfprocparam type="In"
             cfsqltype="CF_SQL_CHAR"
             dbvarname="@MemberID"
             value="#TRIM(MemberID)#">

<cfprocparam type="In"
             cfsqltype="CF_SQL_CHAR"
             dbvarname="@MyVote"
             value="#TRIM(FORM.TheVote)#">


</cfstoredproc>
-------------------

Here it is in SQL Server:

CREATE PROCEDURE spInsertMyVote (@PollID VARCHAR(25), @MemberID CHAR(10),
@MyVote CHAR(3))

AS


INSERT INTO PollMembers
(PollID, MemberID, MyVote, LastUpdate)
VALUES(@PollID, @MemberID, @MyVote, GetDate())

-------------------

It's got to be something with CF. Why would it work in the SQL Query
Analyzer?

Thanks,
Sebastian
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to