Substring expressions
Handle substrings expressions with different database engines.
SELECT * FROM item WHERE item_code[1,4] = "XBFG"
This syntax is specific to Informix SQL. Other database server types provide a function that extracts substrings from a character string.
Database Server Type | Substring function | col[x,y] support |
---|---|---|
IBM DB2® LUW |
|
Emulated, see details |
IBM Informix |
|
Yes, native SQL feature |
IBM Netezza |
|
Emulated, see details |
Microsoft™ SQL Server |
|
Emulated, see details |
Oracle® MySQL / MariadDB |
|
Emulated, see details |
Oracle Database Server |
|
Emulated, see details |
PostgreSQL |
|
Emulated, see details |
SAP HANA® |
|
Emulated, see details |
SQLite |
|
Emulated, see details |
Informix allows you
to update some parts of a CHAR and VARCHAR column by using
the substring specification ( UPDATE tab SET col[1,2]
='ab'
). This is not possible with other databases.
Review the SQL statements using substring expressions and use the database specific substring function.
You can also create your own SUBSTRING() user function in all databases that do not support this function, to have a common way to extract substrings. In Microsoft SQL Server, when you create a user function, you must specify the owner as prefix when using the function. Therefore, it is recommended that you create a SUBSTRING() user function instead of SUBSTR().