SUBSTR Function
Translation reference for DBMS_RANDOM.SUBSTR.
Description
This function returns
amount
bytes or characters of a LOB, starting from an absoluteoffset
from the beginning of the LOB. (Oracle PL/SQL DBMS_LOB.SUBSTR)
This built-in function is replaced with Snowflake SUBSTR function. However, there are some differences.
Note: The amount and offset parameters are inverted in Snowflake
Syntax
Function overloads
DBMS_LOB.SUBSTR('string', amount, offset)
Usage example
Oracle
Snowflake
DBMS_LOB.SUBSTR(BLOB, amount, offset)
Usage example
Note: Result values in Oracle and Snowflake are being converted from bytes to strings for easier understanding of the function.
For Snowflake consider using:
hex_decode_string( to_varchar(SUBSTR(blob_column, 1, 6), 'HEX'));
and for Oracle consider using:
utl_raw.cast_to_varchar2(DBMS_LOB.SUBSTR(blob_column, 1, 6));
to obtain the result as a string.
Oracle
Snowflake
Note: UTL_RAW.CAST_TO_RAW()
is currently not being transformed to TO_BINARY()
. The function is used to show the functional equivalence of the example.
DBMS_LOB.SUBSTR(CLOB, amount, offset)
Usage example
Oracle
Snowflake
Note: UTL_RAW.CAST_TO_RAW()
is currently not being transformed to TO_BINARY()
. The function is used to show the functional equivalence of the example.
DBMS_LOB.SUBSTR(BFILE, amount, offset)
Usage example
Using DBMS_LOB.SUBSTR() on a BFILE column returns a substring of the file content.
Next example is not a current migration, but a functional example to show the differences of the SUBSTR function on BFILE types.
File Content (file.txt):
Oracle
Snowflake
BFILE columns are translated into VARCHAR columns, therefore applying a SUBSTR
function on the same column would return a substring of the file name, not the file content.
Known Issues
1. Using DBMS_LOB.SUBSTR with BFILE columns
The current transformation for BFILE datatypes in columns is VARCHAR, where the name of the file is stored as a string. Therefore applying the SUBSTR function on a BFILE column after transformation will return a substring of the file name, while Oracle would return a substring of the file content.
Related EWIs
SSC-EWI-OR0076: Built In Package Not Supported.
SSC-FDM-OR0035: DBMS_OUTPUT.PUTLINE check UDF implementation.
Last updated