2019-02-20 06:27:43 +07:00
{
"name": "try",
"type": "function",
2020-07-02 01:46:48 +01:00
"groups": ["Conditionals"],
2020-07-29 08:51:06 +02:00
"description": "Tries an expression and returns its value if error-free. If the expression returns an error, an alternative value will be returned when provided otherwise the function will return NULL.",
2022-01-07 08:33:29 -05:00
"arguments": [{
"arg": "expression",
"description": "the expression which should be run"
}, {
"arg": "alternative",
"optional": true,
"description": "the result which will be returned if the expression returns an error."
}],
"examples": [{
"expression": "try( to_int( '1' ), 0 )",
"returns": "1"
}, {
"expression": "try( to_int( 'a' ), 0 )",
"returns": "0"
}, {
"expression": "try( to_date( 'invalid_date' ) )",
"returns": "NULL"
}],
2022-01-12 10:26:38 -05:00
"tags": ["return", "tries", "error", "alternative", "provided", "exception"]
2019-02-20 06:27:43 +07:00
}