Supported SQL Statements and Extensions (Salesforce Driver) : SQL Expressions : Functions

Functions
The Salesforce driver supports a number of functions that you may use in expressions, as listed and described in the tables in this section.
ATAN2(a,b)
Returns a and b.
BITOR(a,b)
Returns a or b.
MOD(a,b)
POWER(a,b)
Returns a random number x bigger or equal to 0.0 and smaller than 1.0.
ROUND(a,b)
Rounds a to b digits after the decimal point.
Returns -1 if d is smaller than 0, 0 if d==0 and 1 if d is bigger than 0.
 
CONCAT(str1,str2)
INSERT(s,start,len,s2)
Returns a string where len number of characters beginning at start has been replaced by s2.
LEFT(s,count)
Returns the leftmost count of characters of s. If s requires double quoting, use SUBSTRING( ) instead.
LOCATE(search,s,[start])
Returns the first index (1=left, 0=not found) where search is found in s, starting at start.
REPEAT(s,count)
REPLACE(s,replace,s2)
Returns s with all occurrences of replace replaced with s2.
RIGHT(s,count)
SPACE(count)
SUBSTR(s,start[,len])
SUBSTRING(s,start[,len])
Returns the substring starting at start (1=left) with length len.
Converts s to uppercase.
Converts s to lowercase.
Converts s to uppercase.
 
 
DATEDIFF(string, datetime1, datetime2)
Returns the count of units of time elapsed from datetime1 to datetime2. The string indicates the unit of time and can have the following values:
HOUR(time)
MINUTE(time)
MONTH(date)
SECOND(time)
WEEK(date)
YEAR(date)
 
 
 
 
 
IFNULL(expr,value)
If expr is NULL, then value is returned; otherwise the result of expr is returned. See COALESCE(expr1, expr2, ...) in this table for evaluating multiple expressions.
CONVERT(term,type)
Converts term to another data type.
CAST(term AS type)
Converts term to another data type.
COALESCE(expr1,expr2, ...)
If expr1 is not Null, then it is returned; otherwise, expr2 is evaluated and, if not Null, it is returned, and so on. This is an ANSISQL standard system function.
NULLIF(value1,value2)
If value1 equals value2, then Null is returned; otherwise, value1 is returned.
CASE value1 WHEN value2 THEN value3 [ELSE value4] END
When value1 equals value2, then value3 is returned; otherwise, value4 or Null is returned in the absence of ELSE.
CASE WHEN expr1 THEN value1 [WHEN expr2 THEN value2] [ELSE value4] END
When expr1 is true, then value1 is returned (optionally repeated for more cases); otherwise value4 or Null is returned in the absence of ELSE.
EXTRACT ({YEAR | MONTH | DAY | HOUR | MINUTE| SECOND} FROM datetime_value)
POSITION(string_expression1 IN string_expression2)
If string_expression1 is a sub-string of string_expression2, then the position of the sub-string, counting from one, is returned; otherwise, 0 is returned.
SUBSTRING(string_expression FROM numeric_expression1 [FOR numeric_expression2])
string_expression is returned from the numeric_expression1 starting location. Optionally, numeric_expression2 specifies the length of the substring.

© 2012 Progress Software Corporation and/or its subsidiaries or affiliates.