Member Login

Username
Password
Forget Password
New Sign Up
Search Forum

Buy Support
Incidents

If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:

Click Here
If you can't login and post questions or you are having trouble viewing forum posts:
Click Here
Callback
Support

If you live in USA, UK, Canada, Australia or New Zealand, you can leave us details on your question and request us to call you back and discuss them with you personally  (charges apply).

Click Here
 
Buy Support
Incidents
If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:
Click Here

Forum : Combining built-in functions - Substring and LocateSearch Forum

Forum Home > QODBC - ODBC Driver for QuickBooks > QODBC SQL Support Forum

 New Topic 
 
 Post Reply 
[1]  
 Combining built-in functions - Substring and Locate 
 Author   Message 
  Fledd 
  
 Group: Members 
 Posts: 9 
 Joined: 2007-01-21 
 Profile
 Posted : 2007-04-04 11:50:28
 Is is possible to combine 2 built-in functions such as:
select * from openquery(qodbc,'SELECT {fn SUBSTRING("FullName",1,{fn LOCATE('':#'', "FullName")}-1} AS "Name" FROM Customer')

The Customer FullName has a :# and the PO number tacked on to the end of it and I want to strip it out of FullName.  The only way I could figure out how to do it was the combined function above, but when I use the LOCATE function to get the starting point, less one, in the FullName field it does not parse out correctly; it is expecting a lexical element.  I've tried putting the third parameter (the LOCATE) function in parenthesis but it still does not parse out correctly.

Is combining built-in functions the way I am doing it possible or is there another way to get the variable length substring from the field?

Thanks 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2007-04-04 15:17:36

Yes, you can combine the functions, but you can use the -1 you have without errors. For example, this works:

SELECT FullName, {fn SUBSTRING("FullName",1,{fn LOCATE(',', "FullName")})}
AS "Name" FROM Customer

However using -1 will display a "[QODBC] Invalid argument to scalar functions: SUBSTRING " error first:

SELECT FullName, {fn SUBSTRING("FullName",1, ({fn LOCATE(',', "FullName")} -1) )}
AS "Name" FROM Customer

because there's bound to be customers without a "," (comma) in their full name. Using a where clause to first check this, fixes the issue:

SELECT FullName, {fn SUBSTRING("FullName",1, ({fn LOCATE(',', "FullName")} -1) )}
AS "Name" FROM Customer Where {fn LOCATE(',', "FullName")} >0

 

  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to