Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Tuesday, July 8, 2025 
 
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 - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: failed to parse sql
Andrew Grandin
Posts: 272
 
failed to parse sqlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Dec 09 8:31 AM
when it try to execute the following sql in script i get the error failed to parse sql.

However, if i run this sql statment in the server management studio it runs fine. Any ideas why SLX doesnt like it? Im guesiing its to do with the use of the
[sysdba].[udf_GetRecursiveChildren] function?

strSQL = "SELECT Z_ACCOUNT_NL.Z_REVYEAR as Year, Z_ACCOUNT_NL.Z_REVTYPE as Product, sum(Z_ACCOUNT_NL.Z_REVAMNT) as Spend " & _
"FROM ACCOUNT INNER JOIN Z_ACCOUNT_NL ON ACCOUNT.ACCOUNTID = Z_ACCOUNT_NL.ACCOUNTID " & _
"WHERE ACCOUNT.ACCOUNTID = '" & AccID & "' or ACCOUNT.ACCOUNTID " & _
"IN (select childid from [sysdba].[udf_GetRecursiveChildren]('" & AccID & "')) " & _
"GROUP BY Z_ACCOUNT_NL.Z_REVYEAR, Z_ACCOUNT_NL.Z_REVTYPE"
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: failed to parse sqlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Dec 09 8:33 AM
sorry forgot to include ive tried it with and without the [sysdba]. in front.
[Reply][Quote]
LeVar Berry
Posts: 47
 
Re: failed to parse sqlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Dec 09 10:52 AM
make sure AcctID doesn't return a NULL value. Print your SQL to the clipboard so you can paste EXACTLY what is being returned.

Clipboard works with Application.clipboard.AsText = "Whatever"
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: failed to parse sqlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Dec 09 4:04 AM
Hi LeVar, thanks for your reply. This is one of the first things i did (although i just msgbox'ed the sql out) and the syntax is perfect. Below is the sql that originally worked fine:

strSQL = "SELECT Z_ACCOUNT_NL.Z_REVYEAR as Year, Z_ACCOUNT_NL.Z_REVTYPE as Product, sum(Z_ACCOUNT_NL.Z_REVAMNT) as Spend " & _
"FROM ACCOUNT INNER JOIN Z_ACCOUNT_NL ON ACCOUNT.ACCOUNTID = Z_ACCOUNT_NL.ACCOUNTID " & _
"WHERE ACCOUNT.ACCOUNTID = '" & AccID & "' or ACCOUNT.PARENTID = '" & AccID & "'" & _
"GROUP BY Z_ACCOUNT_NL.Z_REVYEAR, Z_ACCOUNT_NL.Z_REVTYPE"

and all i have done is replace or ACCOUNT.PARENTID = '" & AccID & "'" with or ACCOUNT.ACCOUNTID IN (select childid from [sysdba].[udf_GetRecursiveChildren]('" & AccID & "'))"

this is why i was thinking it must be a problem calling the function from script as it works fine in server management studio.

so we were wondering if there may be an issue trying to do a call to the function in script
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: failed to parse sqlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Dec 09 8:38 AM
Keep in mind that the Parser will attempt to add Security to this query (unless you are running as Admin).

That being said, why don't you build a View with this statement, enable it on SLX and then just query your view?

E.G. SELECT * FROM MY_VIEW

That simplifies the statement for the Parser by hidding the complexity on the View.
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: failed to parse sqlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Dec 09 8:48 AM
Thanks raul, i also tried executing it in client as admin but it didnt work. Could you point me in the right direction as to how to build a view with the statement please.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: failed to parse sqlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Dec 09 9:08 AM
Looking at it closer, indeed this could be a big headache as well, and cause some performance issues.
Why don't you do the following:
- Create a Native Connection to the Database and query your UDF. (Ref: SalesLogix Stored Procedures - slx_GetNativeConnInfo)
- Create a Comma Separated list of ID from the UDF returned recordset into a String variable.
- Modify your SQL Statement and give it the list of ChildIDs.
- Execute your new Statement (do this on your regular SLX connection)
[Reply][Quote]
Phil Parkin
Posts: 819
Top 10 forum poster: 819 posts
 
Re: failed to parse sqlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Dec 09 6:31 AM
Quote:
Originally posted by Raul A. Chavez

Looking at it closer, indeed this could be a big headache as well, and cause some performance issues.
Why don't you do the following:
- Create a Native Connection to the Database and query your UDF. (Ref: SalesLogix Stored Procedures - slx_GetNativeConnInfo)
- Create a Comma Separated list of ID from the UDF returned recordset into a String variable.
- Modify your SQL Statement and give it the list of ChildIDs.
- Execute your new Statement (do this on your regular SLX connection)


Nice idea.
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: failed to parse sqlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Dec 09 2:22 AM
Sounds like a great idea Raul, could you give me a little help on how to start please this is a completely new area to me.
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: failed to parse sqlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Dec 09 6:18 AM
Never mind guys i found the following in another thread and have adapted it so my code now works. Thanks All!

Function

GetDirectConnection()
Dim strConn, theDirectConnection
Set gdcRS = Application.GetNewConnection.Execute("slx_getNativeConnInfo()")
strConn = "Provider=SQLOLEDB.1assword=(MyPassword)ersist Security Info=True;" & _
"User ID=(DBUserName);Initial Catalog=(DatabaseName);Data Source=(YourServerName)"
Set theDirectConnection = CreateObject("ADODB.Connection")
theDirectConnection.Open strConn
Set GetDirectConnection = theDirectConnection
End Function

[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: failed to parse sqlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Dec 09 1:09 PM
Quote:
Originally posted by Andrew Grandin

when it try to execute the following sql in script i get the error failed to parse sql.

However, if i run this sql statment in the server management studio it runs fine. Any ideas why SLX doesnt like it? Im guesiing its to do with the use of the
[sysdba].[udf_GetRecursiveChildren] function?

"IN (select childid from [sysdba].[udf_GetRecursiveChildren]('" & AccID & "')) " & _



Correct, UDF's don't get along with the SLX OLE DB Provider (or vice versa).....

[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 © 2025 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): 7/8/2025 5:42:00 PM