General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 2nd, 2006, 11:37 AM
supertommy6 supertommy6 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 4 supertommy6 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 39 sec
Reputation Power: 0
Missing Semicolon Error

I'm working on a hitcounter for our website, and I'm running into a peculiar error. Here's the code:

Code:
<cfquery datasource="webstats" name="InitialValue">
	INSERT INTO HitCounts( Page, Hit_Count ) 
		VALUES ( '#pagetitle#', 1)
			WHERE NOT EXISTS
				(SELECT * 
					FROM HitCounts
					WHERE Page = '#pagetitle#');
</cfquery>


The error it gives me is:

Quote:
ERROR INFORMATION:
ODBC Error Code = 37000 (Syntax error or access violation)


[Microsoft][ODBC Microsoft Access Driver] Missing semicolon ( at end of SQL statement.


SQL = "INSERT INTO HitCounts( Page, Hit_Count ) VALUES ( 'HomePage', 1) WHERE NOT EXISTS (SELECT * FROM HitCounts WHERE Page = 'HomePage');"


Internet searches haven't been very helpful. I'm hoping somebody here knows what might be happening. Thanks for the help!

Reply With Quote
  #2  
Old June 2nd, 2006, 11:56 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Are you able to run that query against your database directly... as in, not from Coldfusion but in your SQL Server?
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
  #3  
Old June 2nd, 2006, 12:00 PM
supertommy6 supertommy6 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 4 supertommy6 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 39 sec
Reputation Power: 0
I haven't tried that, and I'm honestly not sure how to do it. The datasource is an Access Database. Is there a way to run SQL code in Access?

Reply With Quote
  #4  
Old June 2nd, 2006, 12:44 PM
supertommy6 supertommy6 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 4 supertommy6 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 39 sec
Reputation Power: 0
It occurs to me that this might not do what I want it to do.

What I'm trying to do is add a hit to the appropriate row. If that row doesn't exist, I need it to create that row with an initial hit value of 1.

This is the code I have:

Code:
<cfquery name="AddHits" datasource="webstats">
		UPDATE HitCounts 
			SET Hit_Count = Hit_Count + 1 
			WHERE Page = '#pagetitle#'
	</cfquery>
	<cfquery datasource="webstats" name="InitialValue">
			INSERT INTO HitCounts( Page, Hit_Count ) 
				VALUES ( '#pagetitle#', 1)
				WHERE NOT EXISTS
					(SELECT * FROM HitCounts WHERE Page = '#pagetitle#');
	</cfquery> 


I suppose I could just add each row by hand, but then I will have to do that every time we add a new page.

Let me know if you have any ideas. I really appreciate the help!

Reply With Quote
  #5  
Old June 5th, 2006, 01:08 AM
mail2radhikaraj mail2radhikaraj is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 4 mail2radhikaraj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 12 m 4 sec
Reputation Power: 0
Smile Missing semicolon error

hey buddy,

there is another way to do an insert in sql .

try this out.

INSERT INTO HitCounts( Page, Hit_Count )
select '#pagetitle#', 1
WHERE NOT EXISTS
(SELECT * FROM HitCounts WHERE Page = '#pagetitle#')


hopefully it should work.
set your parameters in the same way you do when u have values.

lemme know if this works .

regards,
Radz

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > Missing Semicolon Error


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 1 hosted by Hostway