ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 20th, 2005, 05:58 AM
samb1 samb1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 67 samb1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 42 m 42 sec
Reputation Power: 4
Database duplicate problem

Guys can anyone help?
I have tried to use the INSERT...ON DUPLICATE KEY UPDATE in Coldfusion. After I run the query my database columns now get filled with the string "thisJD" in the description column, the string "thisTitle" in the Title column etc. They should contain the variable values, not the string.

Here is my code:



Thanks

Reply With Quote
  #2  
Old April 20th, 2005, 08:38 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,661 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 14 h 23 m 22 sec
Reputation Power: 53
The problem is definitely here:

on duplicate key update Description ="thisJD", Title = "thisTitle", Salary = "thisSalary", Location ="thisLocation", Hours ="thisHours", Contract ="thisContract", CloseDate ="thisClosDate", IntDate="thisIntDate", CurrentDate="now()"

I'm assuming that "on duplicate key" is similar to Oracle's MERGE, meaning if the record is already there do an update instead of an insert. But you aren't using variables here, you're using literal strings. Try something like this:

on duplicate key update Description ="#thisJD#", Title = "#thisTitle#", etc...

you should also be able to use <cfqueryparam> if you choose. If you have more questions about this command you'd probably have more luck in the MySQL forum. At first glance it seems to me like the update statement also needs a where clause or it will update every row in the table.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Last edited by kiteless : April 20th, 2005 at 08:44 AM.

Reply With Quote
  #3  
Old April 21st, 2005, 06:29 AM
samb1 samb1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 67 samb1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 42 m 42 sec
Reputation Power: 4
Thanks for the reply Kiteless, I do want to update all the fields. I tried inserting the # to use the variables but I get an error:
DataDirect][SequeLink JDBC Driver]Invalid parameter binding(s).
On line 63: on duplicate key update Description ="#thisJD#", Title = "#thisTitle#", Salary = "#thisSalary#", Location ="#thisLocation#"

Reply With Quote
  #4  
Old April 21st, 2005, 07:30 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,696 r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 6 Days 16 h 40 m 48 sec
Reputation Power: 986
try using standard sql single quotes, not coldfusion doublequotes

on duplicate key
update Description = '#thisJD#'
, Title = '#thisTitle#'
, Salary = '#thisSalary#'
, Location = '#thisLocation#'
, Hours = '#thisHours#'
, Contract = '#thisContract#'
, CloseDate = '#thisClosDate#'
, IntDate = '#thisIntDate#'
, CurrentDate = now()

and note, no quotes on the function now()
__________________
r937.com | rudy.ca

Reply With Quote
  #5  
Old April 21st, 2005, 05:23 PM
samb1 samb1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 67 samb1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 42 m 42 sec
Reputation Power: 4
Thank you very much for your time guys, r937 the single quotes worked a treat.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Database duplicate problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway