Ask a Question related to Coldfusion Database Access, Design and Development.
-
marksta80 #1
SQL - Syntax Error in valid sql, but only in CF?
Hi CF-people
As a php coder, I'm having quite a hard time getting used to cf :)
I've coded a component which generates a SQL-Insert Statement and (tries to)
execute it. When I cfout and copy/paste it to the (ms-sql) query analyzer it
works but if I want CF to do it, it throws a Syntax Error? Does anybody of you
know where my problem is?
I'd appreciate any kind of hint!
Markus
PS: Thats the Statement:
INSERT INTO Person (id,Name,Vorname,Eintrittsdatum,Email) VALUES (235,
'TestName', 'TestFirstname', '12.07.05', 'test@email.com')
And the Error Statement (unfortunatelly in german)
[Macromedia][SQLServer JDBC Driver][SQLServer]Zeile 1: Falsche Syntax in der
N?he von 'TestName'.
marksta80 Guest
-
your role no longer valid error message and cannot edit page
Unfortunately I don't have access to the file, am asking on behalf of a friend who is skittish about his skills navigating a forum. His question... -
error : syntax error at or near $1 for over select rows
This is the error i am getting when calling select * from cas_reset_qi_changedate('CAS','2003-02-03' ERROR: syntax error at or near "$1" at... -
System.InvalidCastException: Specified cast is not valid. error when updating datagrid
Hello, I am trying to update a record using a data grid. I Have a footer column in my data grid that allows users to add a new record. However, I... -
Help error message - not a valid Freehand File
WIN NT FH10 When I try to open some back up files I am recently getting an error message that reads "Could not convert the document because it is... -
#25818 [Com]: Valid select using OCI8 causes integer overflow error in Oracle
ID: 25818 Comment by: cjbj at hotmail dot com Reported By: iolaire dot mckinnon at vcint dot com Status: Open... -
mpwoodward *TMM* #2
Re: SQL - Syntax Error in valid sql, but only in CF?
On 2005-07-17 10:39:39 -0500, "marksta80" <webforumsuser@macromedia.com> said:
My first guess would be that the date format is throwing it. Try> Hi CF-people
>
> As a php coder, I'm having quite a hard time getting used to cf :)
>
> I've coded a component which generates a SQL-Insert Statement and
> (tries to) execute it. When I cfout and copy/paste it to the (ms-sql)
> query analyzer it works but if I want CF to do it, it throws a Syntax
> Error? Does anybody of you know where my problem is?
>
> I'd appreciate any kind of hint!
> Markus
>
> PS: Thats the Statement:
>
> INSERT INTO Person (id,Name,Vorname,Eintrittsdatum,Email) VALUES (235,
> 'TestName', 'TestFirstname', '12.07.05', 'test@email.com')
>
> And the Error Statement (unfortunatelly in german)
>
> [Macromedia][SQLServer JDBC Driver][SQLServer]Zeile 1: Falsche Syntax
> in der N?he von 'TestName'.
building your statement up one piece at a time to see where it breaks.
For example, can you just insert the ID? Just ID and first name? etc.
(Your ability to do this might be affected by how you have your
nullable fields set in your database.)
Matt
--
Matt Woodward
[email]mpwoodward@gmail.com[/email]
Team Macromedia - ColdFusion
mpwoodward *TMM* Guest
-
MikerRoo #3
re: Using DISTINCT wirh ORDER BY
Use the PreserveSingleQuotes() function in your cfquery...
<CFQUERY ...>
#PreserveSingleQuotes (GeneratedSQL_Text)#
</CFQUERY>
MikerRoo Guest
-
MikerRoo #4
RE: SQL - Syntax Error in valid sql, but only in CF?
Wrap your query string in PreserveSingleQuotes().
MikerRoo Guest
-
marksta80 #5
Re: SQL - Syntax Error in valid sql, but only in CF?
Thank you for your help. I've set up all fields as text fields, so I don't need
to worry (yet) about the data-format.
But I keep getting these syntax errors... but copy&past to query analyzer does
still work.
I'd be really happy if may have another tip.
Thanks
Markus
Here's my code, did I make an mistake?
<cfset insVals= ArrayToList(#values#,", ")>
<cfset insVals= #PreserveSingleQuotes(insVals)#>
<cfset insStr = #insStr# & " (" & ArrayToList(#columns#,",") & ") VALUES (" &
#insVals# & ")">
marksta80 Guest
-
MikerRoo #6
Re: SQL - Syntax Error in valid sql, but only in CF?
That's not quite right.
Use PreserveSingleQuotes() like this:
<CFSET sSQL_Str = "INSERT INTO SomeTable VALUES ('Some text', 25)">
<CFQUERY ... ...>
#PreserveSingleQuotes (sSQL_Str)#
</CFQUERY>
If that's not enough, Post your entire CFQuery code.
Regards,
-- MikeR
MikerRoo Guest
-
marksta80 #7
Re: Re: SQL - Syntax Error in valid sql, but only inCF?
That's how it's done! Thank you very much!
marksta80 Guest



Reply With Quote

