Hi,
I'm wanting to create my own simple function. I believe I can use CTL to do it, and don't need Java. Basically I'm hoping to wrap some CTL code into a function, so we can use it in many jobs easily.
Example :
function handle_null(record)
is record a string?
return '-'
is record a number?
return 0
is record a date?
return 1900-01-01
end
The documentation talks about extending Java, but that feels like overkill for what I need.
I was hoping I could just create a .ctl file, that I could import into transforms/reformats. Is this no longer recommended or possible in newer versions? (> 4.3)
If it is possible, does someone have an example of a .ctl function, that takes in parameters, and returns a value?
Thanks!
I'm wanting to create my own simple function. I believe I can use CTL to do it, and don't need Java. Basically I'm hoping to wrap some CTL code into a function, so we can use it in many jobs easily.
Example :
function handle_null(record)
is record a string?
return '-'
is record a number?
return 0
is record a date?
return 1900-01-01
end
The documentation talks about extending Java, but that feels like overkill for what I need.
I was hoping I could just create a .ctl file, that I could import into transforms/reformats. Is this no longer recommended or possible in newer versions? (> 4.3)
If it is possible, does someone have an example of a .ctl function, that takes in parameters, and returns a value?
Thanks!
-
Hi hewills,
Creating a .ctl file and importing into transforms/reformats is still possible in newer versions of CloverETL Designer. That being said I have created a simple .ctl function that takes parameters and returns a value:
//#CTL2
function string handle_null(string data)
{
return data==null ? "-":data;
}
function integer handle_null(integer data)
{
return data==null ? 0:data;
}
function date handle_null(date data)
{
return data==null ? createDate(1990,01,01):data;
}
Regards, -
That makes sense. This is working just as I needed it, thanks!
Please sign in to leave a comment.
Comments 2