|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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:
Internet searches haven't been very helpful. I'm hoping somebody here knows what might be happening. Thanks for the help! |
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
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?
|
|
#4
|
|||
|
|||
|
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! |
|
#5
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Databases > General SQL Development > Missing Semicolon Error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|