SnowConvert AI - Function References for Oracle¶
DATEDIFF_UDF(TIMESTAMP, NUMBER)¶
Definition¶
This user-defined function (UDF) is used to subtract a number (which is a number of days) from a timestamp.
Parameters¶
FIRST_PARAM TIMESTAMP
The timestamp that represents the minuend.
SECOND_PARAM NUMBER
The number of days that represents the subtrahend.
Returns¶
Returns a timestamp with the difference between the timestamp and the number.
Usage example¶
Input:
Output:
DATEDIFF_UDF(TIMESTAMP, DATE)¶
Definition¶
This user-defined function (UDF) is used to subtract a date from a timestamp.
Parameters¶
FIRST_PARAM TIMESTAMP
The timestamp that represents the minuend.
SECOND_PARAM DATE
The date that represents the subtrahend.
Returns¶
Returns an integer with the difference between the timestamp and the date.
Usage example¶
Input:
Output:
DATE_TO_JULIAN_DAYS_UDF¶
Definition¶
This user-defined function (UDF) transforms from Gregorian date to Julian date (The number of days since January 1, 4712 BC.).
Parameters¶
INPUT_DATE DATE
The Gregorian date to transform.
Returns¶
Returns the date representation of the Julian date.
Migration example¶
Input:
Output:
Usage example¶
Input:
Output:
UTL_FILE.PUT_LINE_UDF¶
Definition¶
This user-defined function (UDF) is used to replicate the functionality of the Oracle UTL_FILE_PUT_LINE procedure.
Parameters¶
FILE VARCHAR
The file to open and save the new buffer.
BUFFER VARCHAR
The buffer to be saved on the defined file.
Returns¶
Returns a varchar with the result.
Usage example¶
Warning
To review the lines in the file, there are two ways: Downloading the file from the Snowflake CLI or briefly review the information with SELECT * FROM UTL_FILE.FOPEN_TABLES_LINES; but only if the file has not been closed.
Input:
Output:
UTL_FILE.FOPEN_UDF (VARCHAR,VARCHAR)¶
Definition¶
This user-defined function (UDF) is used to replicate the functionality of the Oracle UTL_FILE_FOPEN procedure.
Parameters¶
FILENAME VARCHAR
The file to be opened.
OPEN_MODE VARCHAR
Indicates the mode on which the file will be available.
Returns¶
Returns a varchar with the result.
Usage example¶
Warning
The UTL_FILE.FOPEN_UDF allows to open a .csv file. To access the file it is required to create a stage for the file and use the Snowflake CLI to upload it.
Input:
Output:
JSON_VALUE_UDF¶
Definition¶
This user-defined function (UDF) reproduces the JSON_VALUE function to extract a single result out of a JSON variable.
Parameters¶
JSON_OBJECT VARIANT
The JSON variable from which to extract the values.
JSON_PATH STRING
The JSON path that indicates where the values are located inside the JSON_OBJECT.
RETURNING_TYPE STRING
The type to return.
ON_ERROR_MESSAGE VARIANT
The error message to add if needed.
ON_EMPTY_MESSAGE VARIANT
The error message to add in case of empty message.
Returns¶
Returns a single value specified by the JSON_PATH inside the JSON_OBJECT. If the result is not a single value, returns a default error message or an error message defined in the input parameters.
Usage example¶
Input:
Output:
DATEADD_UDF (FLOAT, TIMESTAMP)¶
Definition¶
This user-defined function (UDF) is used in cases when there is an addition between a float number and a timestamp.
Parameters¶
FIRST_PARAM FLOAT
The timestamp number that is going to be added with the second float parameter.
SECOND_PARAM DATE
The float number to be added with the timestamp in the first parameter.
Returns¶
Returns a timestamp with the addition between the timestamp and the float number specified.
Usage example¶
Input:
Output:
FETCH_BULK_COLLECTIONS_UDF (OBJECT)¶
Definition¶
This user-defined function (UDF) is used to replicate the functionality of fetching bulk for collections in Oracle. This function version receives the cursor only.
Parameters¶
CURSOR OBJECT
The cursor that is processed and filled with the data in the fetch bulk collection.
Returns¶
Returns an object with information related to the logic of fetching bulk collections.
Usage example¶
Input:
Output:
DATEADD_UDF (DATE, FLOAT)¶
Definition¶
This user-defined function (UDF) is used in cases when there is an addition between a date and a type as float or timestamp.
Parameters¶
FIRST_PARAM DATE
The date to be added with the number in the second parameter.
SECOND_PARAM FLOAT
The float number that is going to be added with the first date parameter.
Returns¶
Returns the addition between the date and the float number specified.
Migration example¶
Input:
Output:
Usage example¶
Input:
Output:
DATEDIFF_UDF(DATE, TIMESTAMP)¶
Definition¶
This user-defined function (UDF) is used to subtract a timestamp from a date.
Parameters¶
FIRST_PARAM DATE
The date over the subtraction is done.
SECOND_PARAM TIMESTAMP
The timestamp to subtract from the first parameter.
Returns¶
Returns an integer with the days between the first and the second parameter.
Usage example¶
Input:
Output:
DBMS_RANDOM.VALUE_UDF¶
Definition¶
This user-defined function (UDF) is to replicate the functionality of the Oracle DBMS_RANDOM.VALUE function.
Parameters¶
No input parameters.
Returns¶
Returns a double number with a random number.
Usage example¶
Input:
Output:
DBMS_RANDOM.VALUE_UDF (DOUBLE, DOUBLE)¶
Definition¶
This user-defined function (UDF) is to replicate the functionality of the Oracle DBMS_RANDOM.VALUE function.
Parameters¶
low DOUBLE
The initial limit to be considered.
high DOUBLE
The delimiting limit that coordinates with the first parameter.
Returns¶
Returns a double number with a random number between the limits specified.
Usage example¶
Input:
Output:
FETCH_BULK_RECORD_COLLECTIONS_UDF (OBJECT, ARRAY)¶
Definition¶
This user-defined function (UDF) is used to cover the functionality of fetch bulk records with different input parameters that determine the information added or the behavior of the cursor.
Parameters¶
CURSOR OBJECT
The cursor that is being processed.
COLUMN_NAMES ARRAY
The column names that are associated with the cursor.
Returns¶
Returns an object with the processed information.
Usage example¶
Input:
Output:
FETCH_BULK_COLLECTION_RECORDS_UDF (OBJECT, ARRAY)¶
Definition¶
This user-defined function (UDF) is used to replicate the functionality of FETCH in Oracle. This is the variation where it receives the cursor and the column names.
Parameters¶
CURSOR OBJECT
The cursor that is processed and filled with the data in the fetch bulk.
COLUMN_NAMES ARRAY
The name associated with the column is not the initial name.
Returns¶
Returns an object with the records from the fetch bulk.
Usage example¶
Input:
Output:
JULIAN_TO_GREGORIAN_DATE_UDF¶
Definition¶
This user-defined function (UDF) is used to transform a Julian date into the formats: JD Edwards, YYYYDDD (astronomical), and YYYYDDD (ordinal).
Parameters¶
JULIAN_DATE CHAR
The Julian date to transform.
FORMAT_SELECTED CHAR
The format required for the logic. E.g. 'E', 'J', 'R'. Astronomy standardized or 'J' is the default format.
Returns¶
Returns a variant with the date representation of the Julian date.
Usage example¶
Input:
Output:
TIMESTAMP_DIFF_UDF¶
Definition¶
This user-defined function (UDF) is used for the timestamps arithmetic operations and the equivalence functionality in Snowflake.
Parameters¶
LEFT_TS TIMESTAMP
The minuend value.
RIGHT_TS TIMESTAMP
The subtrahend value.
Returns¶
Returns a varchar with the resulting difference between timestamps.
Usage example¶
Input:
Output:
REGEXP_LIKE_UDF (STRING, STRING, STRING)¶
Definition¶
This user-defined function (UDF) is
Parameters¶
COL STRING
The string to be evaluated with the pattern.
PATTERN STRING
The pattern to be checked.
MATCHPARAM STRING
The match parameter that will determine whether the case-sensitive or not.
Returns¶
Returns
Usage example¶
Input:
Output:
FETCH_BULK_COLLECTIONS_UDF (OBJECT, FLOAT)¶
Definition¶
This user-defined function (UDF) is used to replicate the functionality of fetching bulk for collections in Oracle. This function version receives the cursor and the limit value for the row count.
Parameters¶
CURSOR OBJECT
The cursor that is processed and filled with the data in the fetch bulk collection.
LIMIT FLOAT
The limit for the records to call.
Returns¶
Returns an object with information related to the logic of fetching bulk collections.
Usage example¶
Input:
Output:
INIT_CURSOR_UDF¶
Definition¶
This user-defined function (UDF) is to initialize a cursor object with the equivalent functionality.
Parameters¶
NAME VARCHAR
The name of the cursor.
QUERY VARCHAR
The query that is associated with the cursor.
Returns¶
Returns an object with the cursor information.
Usage example¶
Input:
Output:
UPDATE_PACKAGE_VARIABLE_STATE_UDF¶
Definition¶
This user-defined function (UDF) updates the given package variable values. It is a wrapper for the Snowflake SETVARIABLE() function.
Parameters¶
VARIABLE VARCHAR
The variable name to set the value.
NEW_VALUE VARCHAR
The value that will be stored.
Returns¶
Returns a varchar with the information of the updated variable.
Usage example¶
Warning
Please, review the existence of the variable.
Input:
Output:
OPEN_BULK_CURSOR_UDF (OBJECT)¶
Definition¶
This user-defined function (UDF) is used to pen a cursor without bindings.
Parameters¶
CURSOR OBJECT
The cursor to process as open.
Returns¶
Returns an object with the current information of the cursor.
Usage example¶
Input:
Output:
DATEADD_UDF (TIMESTAMP, FLOAT)¶
Definition¶
This user-defined function (UDF) is used in cases when there is an addition between a timestamp and a float number.
Parameters¶
FIRST_PARAM TIMESTAMP
The timestamp number that is going to be added with the second float parameter.
SECOND_PARAM FLOAT
The float number to be added with the timestamp in the first parameter.
Returns¶
Returns a timestamp with the addition between the timestamp and the float number specified.
Usage example¶
Input:
Output:
DATEDIFF_UDF(TIMESTAMP, TIMESTAMP)¶
Definition¶
This user-defined function (UDF) subtracts a timestamp from another timestamp.
Parameters¶
FIRST_PARAM TIMESTAMP
The timestamp that represents the minuend.
SECOND_PARAM TIMESTAMP
The timestamp that represents the subtrahend.
Returns¶
Returns an integer with the difference of days between the first and the second timestamps.
Usage example¶
Input:
Output:
UTL_FILE.FCLOSE_UDF¶
Definition¶
This user-defined function (UDF) is used to replicate the functionality of the Oracle UTL_FILE_FCLOSE procedure.
Parameters¶
FILE VARCHAR
The file to process and close.
Returns¶
Returns a varchar with the result.
Usage example¶
Warning
The UTL_FILE.FCLOSE_UDF closes the file that is being processed. To review the result or handle files, it is required to use the Snowflake CLI console. The Snowflake CLI console allows the upload or download of a file.
Input:
Output:
FETCH_BULK_RECORD_COLLECTIONS_UDF (OBJECT)¶
Definition¶
This user-defined function (UDF) is used to cover the functionality of fetch bulk records with different input parameters that determine the information added or the behavior of the cursor.
Parameters¶
CURSOR OBJECT
The cursor that is being processed.
Returns¶
Returns an object with the processed information.
Usage example¶
Input:
Output:
CAST_DATE_UDF¶
Definition¶
The function processes a timestamp in string format to a date. It returns a date with the specified format.
Parameters¶
DATESTR STRING
The date as a string to be formatted. The format should be ‘YYYY-MM-DD"T"HH24:MI:SS.FF' e.g. '2024-01-25T23:25:11.120'.
Please review the following information about formatting here.
Returns¶
Returns a date with the new format applied.
Usage example¶
Input:
Output:
FETCH_BULK_COLLECTION_RECORDS_UDF (OBJECT, FLOAT, ARRAY)¶
Definition¶
This user-defined function (UDF) is used to replicate the functionality of FETCH in Oracle. This is the variation where it receives the cursor, the limit, and the column names.
Parameters¶
CURSOR OBJECT
The cursor that is processed and filled with the data in the fetch bulk.
LIMIT FLOAT
The limit for the records to call.
COLUMN_NAMES ARRAY
The name associated with the column is not the initial name.
Returns¶
Returns an object with the records from the fetch bulk.
Usage example¶
Input:
Output:
DATEDIFF_UDF(DATE, INTEGER)¶
Definition¶
This user-defined function (UDF) applies a subtraction of days over a date.
Parameters¶
FIRST_PARAM DATE
The initial date to apply the subtraction.
SECOND_PARAM INTEGER
The number of days to be subtracted from the first date parameter.
Returns¶
Returns the date after subtracting the indicated number of days.
Usage example¶
Input:
Output:
DATE_TO_RR_FORMAT_UDF¶
Definition¶
This user-defined function (UDF) transforms from date to oracle RR datetime format date
Parameters¶
INPUT_DATE DATE
The date to transform.
Returns¶
The input date with years adjusted to RR format.
Migration example¶
Input:
Output:
Usage example¶
Input:
Output:
FETCH_BULK_RECORD_COLLECTIONS_UDF (OBJECT, INTEGER)¶
Definition¶
This user-defined function (UDF) is used to cover the functionality of fetch bulk records with different input parameters that determine the information added or the behavior of the cursor.
Parameters¶
CURSOR OBJECT
The cursor that is being processed.
LIMIT INTEGER
The limit of the row count.
Returns¶
Returns an object with the processed information.
Usage example¶
Input:
Output:
DBMS_OUTPUT.PUT_LINE_UDF¶
Definition¶
This user-defined function (UDF) is used to replicate the functionality of the Oracle DBMS_OUTPUT_PUT_LINE function.
Warning
Notice that performance may be affected by using this UDF. To start logging information uncomment the implementation inside the function.
Parameters¶
LOG VARCHAR
The information to be shown in the command line.
Returns¶
Returns a varchar with the information logged.
Usage example¶
Input:
Output:
DATEDIFF_UDF(DATE, DATE)¶
Definition¶
This user-defined function (UDF) is used when there is a subtraction between two dates.
Parameters¶
FIRST_PARAM DATE
The date that represents the minuend in the subtraction.
SECOND_PARAM DATE
The date that represents the subtrahen in the subtraction.
Returns¶
Returns an integer with the number of days between the dates.
Usage example¶
Input:
Output:
OPEN_BULK_CURSOR_UDF (OBJECT, ARRAY)¶
Definition¶
This user-defined function (UDF) is used to open a cursor with bindings.
Parameters¶
CURSOR OBJECT
The cursor to process as open.
BINDINGS ARRAY
The binding that is related to the cursor.
Returns¶
Returns an object with the current information of the cursor.
Usage example¶
Input:
Output:
CLOSE_BULK_CURSOR_UDF¶
Definition¶
This user-defined function (UDF) deletes the temporary table that stores the result set of the cursor and resets the cursor properties to their initial state.
Parameters¶
CURSOR OBJECT
The cursor that is checked and closed.
Returns¶
Returns an object with the cursor properties reset.
Migration example¶
Input:
Output:
Usage example¶
Input:
Output:
DATEADD_UDF (FLOAT, DATE)¶
Definition¶
This user-defined function (UDF) is used in cases when there is an addition between a type as float or timestamp and a date.
Parameters¶
FIRST_PARAM FLOAT
The float number that is going to be added with the second date parameter.
SECOND_PARAM DATE
The date to be added with the number in the first parameter.
Returns¶
Returns the addition between the float number and the date specified.
Usage example¶
Input:
Output:
BFILENAME_UDF¶
Definition¶
The function takes the directory name and the filename parameter as a string. Then, it returns a concatenation using the '\'.
Warning
The character '\' must be changed to match the Operating System file concatenation character.
Parameters¶
DIRECTORYNAME STRING
The directory name to be processed as a string.
FILENAME STRING
The filename to be concatenated.
Returns¶
Returns a string that contains the directory name and filename concatenated by a '\'.
Migration example¶
Input:
Output:
Usage example¶
Input:
Output:
REGEXP_LIKE_UDF (STRING, STRING)¶
Definition¶
This user-defined function (UDF) is used to support the Oracle REGEXP_LIKE functionality.
Parameters¶
COL STRING
The string to be evaluated with the pattern.
PATTERN STRING
The pattern to be checked.
Returns¶
Returns a boolean expression. True if the pattern matches the string; otherwise, false.
Usage example¶
Input:
Output:
UTL_FILE.FOPEN_UDF (VARCHAR, VARCHAR, VARCHAR)¶
Definition¶
This user-defined function (UDF) is used to replicate the functionality of the Oracle UTL_FILE_FOPEN procedure.
Parameters¶
PACKAGE_VARIABLE VARCHAR
The variable related to the file opening.
FILENAME VARCHAR
The file to be opened.
OPEN_MODE VARCHAR
Indicates the mode on which the file will be available.
Returns¶
Returns a varchar with the result.
Usage example¶
Warning
The UTL_FILE.FOPEN_UDF allows to open a .csv file. To access the file it is required to create a stage for the file and use the Snowflake CLI to upload it.
Input:
Output:
FETCH_BULK_COLLECTION_RECORDS_UDF (OBJECT)¶
Definition¶
This user-defined function (UDF) is used to replicate the functionality of FETCH in Oracle. This is the variation where it receives the cursor only.
Parameters¶
CURSOR OBJECT
The cursor that is processed and filled with the data in the fetch bulk.
Returns¶
Returns an object with the records from the fetch bulk.
Usage example¶
Input:
Output:
FETCH_BULK_RECORD_COLLECTIONS_UDF (OBJECT, FLOAT, ARRAY)¶
Definition¶
This user-defined function (UDF) is used to cover the functionality of fetch bulk records with different input parameters that determine the information added or the behavior of the cursor.
Parameters¶
CURSOR OBJECT
The cursor that is being processed.
LIMIT FLOAT
The limit of the row count.
COLUMN_NAMES ARRAY
The column names that are associated with the cursor.
Returns¶
Returns an object with the processed information.
Usage example¶
Input:
Output:
FETCH_BULK_COLLECTION_RECORDS_UDF (OBJECT, INTEGER)¶
Definition¶
This user-defined function (UDF) is used to replicate the functionality of FETCH in Oracle. This is the variation where it receives the cursor and the limit.
Parameters¶
CURSOR OBJECT
The cursor that is processed and filled with the data in the fetch bulk.
LIMIT FLOAT
The limit for the records to call.
Returns¶
Returns an object with the records from the fetch bulk.
Usage example¶
Input:
Output: