Replace a SQL function call
ProprietaryReplaces calls to a SQL function with a template filled in with the source of their arguments, for when the replacement is more than a rename. For example, Oracle's NVL2(a, b, c) can be replaced with CASE WHEN a IS NOT NULL THEN b ELSE c END. An argument that is not a single term is parenthesized, so it keeps its meaning wherever the template places it. A call is left as it is when the template would repeat or drop an argument holding a ? parameter.
org. openrewrite. sql. ReplaceFunctionCallRequired
The name of the function to replace, case insensitive.
Only replace calls with exactly this many arguments.
The replacement, in which $1, $2, and so on stand for the source of the call's arguments. Outside of quotes, it takes the case of the function name it replaces when that is all one case.
mod run . --recipe= org. openrewrite. sql. ReplaceFunctionCall \
-P functionName= NVL2 \
-P argumentCount=3 \
-P template= 'CASE WHEN $1 IS NOT NULL THEN $2 ELSE $3 END'Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.