calculateSize()

When the return type of a user-defined function is defined as VARCHAR(ANY), NUMERIC(ANY), or NVARCHAR(ANY) the calculateSize method is called at runtime to dynamically determine the size of the result column.

nzLua passes a table as the single argument to the calculateSize method. The table contains one record for each argument as is shown in Table 1.
Table 1. calculate Size argument table
Name Description
args.count The number of arguments the UDF was invoked with.
args[i].type The argument type.
args[i].length The length of a char, varchar, nchar, or nvarchar argument.
args[i].precision The precision of a numeric argument.
args[i].scale The scale of a numeric argument.
Example
function calculateSize( args )
return args[1].length + args[2].length
end

function getResult()
return varchar(any)
end