substring

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

substring [2015/09/23 20:27]
substring [2015/09/23 20:27] (current)
Line 1: Line 1:
 +====== SUBSTRING Function - PL/HQL Reference======
  
 +SUBSTRING function returns a substring from string. ​
 +
 +**Syntax**:
 +
 +<code language="​sql">​
 +SUBSTRING(string,​ start_pos [, substring_len])
 +|
 +SUBSTRING(string FROM start_pos [FOR substring_len])
 +</​code>​
 +
 +**Parameters:​**
 +
 +| **Parameter** | **Type** | **Value** | **Description** |
 +| string | String | Variable or expression | Original string |
 +| start_pos | Integer | Variable or expression | Start position of substring (starts from 1) |
 +| substring_len | Integer | Variable or expression | Length of substring |
 +
 +**Notes**:
 +
 +  * If start_pos is 0 then it is treated as 1
 +  * SUBSTRING and [[substr|SUBSTR]] functions are synonyms
 +
 +**Return Type:**
 +
 +String.
 +
 +**Example:​**
 +
 +<code language="​sql">​
 +SUBSTRING('​Remark',​ 3); 
 +</​code> ​
 +
 +Result: '​mark'​
 +
 +**Example:​**
 +
 +<code language="​sql">​
 +SUBSTRING('​Remark',​ 3, 3); 
 +</​code> ​
 +
 +Result: '​mar'​
 +
 +**Compatibility**:​ IBM DB2, Teradata and Microsoft SQL Server.
 +
 +**See also**:
 +  * [[substr|SUBSTR]]
 +
 +**Version**: ​
 +  * PL/HQL 0.3.11 SUBSTRING FROM FOR syntax added
 +  * PL/HQL 0.01 introduced