Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Monday, November 25, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - ADO General
Forum to discuss ADO specific questions for use with SalesLogix. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to ADO General | New ThreadView:  Search:  
 Author  Thread: Incorrect Syntax Error
Leon
Posts: 5
 
Incorrect Syntax ErrorYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 May 10 5:16 PM
Hi All,

I have the following query embedded in my .Net code:

select distinct
u.userid,
u.username,
us.defaultseccodeid,
Convert(Varchar(3), Left(IsNull(u.FirstName, ''), 1) + Left(IsNull(u.MiddleName, ''), 1) + Left(IsNull(u.LastName, ''), 1)) AS Initials
from seccode s
inner join secrights sr on sr.seccodeid = s.seccodeid
inner join userinfo u on u.userid = sr.accessid
inner join usersecurity us on u.userid = us.userid
where s.seccodetype = 'G'
and s.seccodeid = 'F6UJ9A00000H'
AND us.Type <> 'R' ORDER BY u.username

and am getting an error "Incorrect syntax near ')'" when I run it. It runs fine in SQL Server Management Studio.

I thought maybe the SLX provider was choking on the Left command if there was nothing in the field, so I changed it to the following:

select distinct
u.userid,
u.username,
us.defaultseccodeid,
Convert(Varchar(3), CASE IsNull(u.FirstName, '') WHEN '' THEN '' ELSE Left(IsNull(u.FirstName, ''), 1) END +
CASE IsNull(u.MiddleName, '') WHEN '' THEN '' ELSE Left(IsNull(u.MiddleName, ''), 1) END +
CASE IsNull(u.LastName, '') WHEN '' THEN '' ELSE Left(IsNull(u.LastName, ''), 1) END) AS Initials
from seccode s
inner join secrights sr on sr.seccodeid = s.seccodeid
inner join userinfo u on u.userid = sr.accessid
inner join usersecurity us on u.userid = us.userid
where s.seccodetype = 'G'
and s.seccodeid = 'F6UJ9A00000H'
AND us.Type <> 'R' ORDER BY u.username

This results in the error "Incorrect syntax near the keyword 'WHEN'". Again, it runs fine in SQL Server Management Studio.

This error has just come up since we upgraded from SLX 7.2 to 7.5.2. It was running fine before.

Any ideas?

Leon
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Incorrect Syntax ErrorYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 19 May 10 12:17 AM
Based on the fact that the error message is Incorrect Syntax, that means that the code is being parsed but fails on Execution.

So, since I ran SLX Profiler and capture what the Parser is doing for you:
select distinct
u.userid,
u.username,
us.defaultseccodeid,
CONVERT(Varchar(3),Left(IsNull(u.FirstName, ''), 1) + Left(IsNull(u.MiddleName, ''), 1) + Left) AS Initials
from seccode s
inner join secrights sr on sr.seccodeid = s.seccodeid
inner join userinfo u on u.userid = sr.accessid
inner join usersecurity us on u.userid = us.userid
where s.seccodetype = 'G'
and s.seccodeid = 'F6UJ9A00000H'
AND us.Type <> 'R' ORDER BY u.username


So, I decided to replace the Convert with a Cast, and guess what, that works.

I don't know why you would want to cast it as varchar(3), never the less it works better with CAST as shown below:

CAST(Left(IsNull(u.FirstName, ''), 1) + Left(IsNull(u.MiddleName, ''), 1) + Left(IsNull(u.LastName, ''), 1) AS VARCHAR(3)) AS Initials

[Reply][Quote]
Leon
Posts: 5
 
Re: Incorrect Syntax ErrorYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 19 May 10 9:17 AM
Thanks Raul. That worked.

I needed to cast to a varchar because without it, just concatenating the fields, .Net wasn't recognizing the data type of the returned value.
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/25/2024 7:16:05 PM