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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 11th, 2005, 04:53 PM
|3enjam |3enjam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 4 |3enjam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 14 sec
Reputation Power: 0
Error Code = 37000 (Syntax error or access violation)

I'm getting this error when trying to run an UPDATE query:

ODBC Error Code = 37000 (Syntax error or access violation)

[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'test'.

The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (94:1) to (94:30).



here is my code (w/ line nums added):
Code:
47 <cfset PostDate = createodbcdatetime( now() )>
49 <cfquery datasource="Library">
50   INSERT INTO Checkout
51 		(Postdate, Name, COType)
52   VALUES
53 		(#PostDate#, '#FORM.Name#', '#FORM.COType#')
54 </cfquery>
56 <cfquery name="FindRecord" datasource="Library">
57 	SELECT Record
58 	FROM Checkout
59 	WHERE Postdate >= #PostDate#
60 		AND Name = '#FORM.Name#'
61 </cfquery>
63 <cfset #RecordFound# = #FindRecord.Record#>
65 <cfset querytext = "UPDATE Checkout SET "> <!--- initialize the query --->
66
67 <cfset querytext = iif( (isdefined("FORM.ScanItem1")  and FORM.ScanItem1  is not ""), de(querytext & "ScanItem1  = '#FORM.ScanItem1#', SIDateOut1  = #PostDate#,"), de(querytext) )>
<!--- many more of these, removed for space --->

78 <cfset querytext = iif( (isdefined("FORM.LongItem1")  and FORM.LongItem1  is not ""), de(querytext & "LongItem1  = '#FORM.LongItem1#', LIDateOut1  = #PostDate#,"), de(querytext) )>
<!--- many more removed for space --->

89 <cfset querytext = left(querytext, len(querytext) - 1) & " WHERE Record = #RecordFound#"> <!--- remove that last comma, and finalize --->  
90 
91 <cfdump var="#querytext#"> <!--- debugging --->
92 
93 <!--- run it --->
94 <cfquery datasource="Library">
95 	#querytext#
96 </cfquery>


when i copy-paste the cfdump output into the SQL server directly, everything works just fine.

here is a sample query:
Code:
UPDATE Checkout SET ScanItem1 = 'test', SIDateOut1 = {ts '2005-03-11 15:36:24'},ScanItem2 = 'items', SIDateOut2 = {ts '2005-03-11 15:36:24'},ScanItem3 = 'and', SIDateOut3 = {ts '2005-03-11 15:36:24'},ScanItem4 = 'stuff', SIDateOut4 = {ts '2005-03-11 15:36:24'} WHERE Record = 324


i'm baffled as to why this error is occuring, the types are correct, and copy-paste works.

thanks for any help

Reply With Quote
  #2  
Old March 12th, 2005, 08:27 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,343 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 8 h 5 m 22 sec
Reputation Power: 891
if ScanItem1 is a numeric column, you don't want the single quotes around 'test'
__________________
r937.com | rudy.ca

Reply With Quote
  #3  
Old March 14th, 2005, 03:25 PM
|3enjam |3enjam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 4 |3enjam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 14 sec
Reputation Power: 0
all the variable types are correct.

when i copy-paste the query into the database manager directly, the query functions perfectly.

somewhere between coldfusion and the database server, the query is not working.

all ScanItems are nvarchar's and all the Dates are smalldatetime's and Record is an int

Reply With Quote
  #4  
Old March 14th, 2005, 03:29 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,343 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 8 h 5 m 22 sec
Reputation Power: 891
i think you're getting two single quotes for one, or something like that

note that the error message points to test which comes right after a quote

look up the PreserveSingleQuotes() function

it may not be the solution here -- quite frankly, i don't understad your de() function -- but at least it talks about the issue

Reply With Quote
  #5  
Old March 14th, 2005, 03:37 PM
|3enjam |3enjam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 4 |3enjam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 14 sec
Reputation Power: 0
the de(string) function is delayed evaluation function that basically just returns the string inside the function as a string.

the iif(condition, true_expression, false_expression) function returns an evaluated version of true_expression if condiditon is true, and an evaluated version of false_expression if condition is false.

what i mean by evaluated version of the string is this:
if the string 'thisvar' is a variable, it will return the value of that variable, if 'thisvar' is merely a string and not a varible, the iif() function will return an error saying that it cannot evaluate the 'thisvar' variable, the de() function circumvents this by evaluating the string within it as merely a string.

i know its a little confusing at first, but the problem is not with the iif() or de() functions, the query runs fine when copy-pasted, and this is where my consternation lies: why not work when run from cold fusion and run fine when copy-pasted with ZERO edits into the SQL database manager directly?

but i will try your preservesinglequotes() function and see if that helps...

Reply With Quote
  #6  
Old March 14th, 2005, 03:49 PM
|3enjam |3enjam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 4 |3enjam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 14 sec
Reputation Power: 0
UPDATE:

i have made those changes to the code and now it works.

still confused as to why, but relieved.

thanks for your help.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Error Code = 37000 (Syntax error or access violation)


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