26-06-2020 12:20 PM
Hi Team,
I started development course and in Hands on exercise no1 i am facing some discrepency. The lua script what i answered is providing correct result in my exasol DB but its is showing incorrect in exasol hands on exercise. Please find the script below let me know incase i am missing something.
CREATE OR REPLACE SCRIPT helper() AS
function add_prefix(arr, prefix)
local s = ""
for k, v in pairs(arr) do
s = s .. ", " ..prefix.. v
end
return(string.sub(s,3))
end
output(add_prefix( {'firstname', 'lastname', 'city'}, 'person.'))
/
execute script helper() with output;
Thanks
Saurav
01-07-2020 09:48 AM
Instead of
return(string.sub(s,3))
put string.sub(s,3) in a variable so that you can test it in an IF statement.
Using more variables often make life easier 🙂
29-06-2020 10:46 AM
This post may help point you in the right direction @saurav2191
https://community.exasol.com/t5/training-forum/lua-string-prefix/m-p/740#M10
26-06-2020 12:29 PM
Hi Saurav,
thank you for your contribution! Your script is fine but it doesn't address this request from the task:
When the array of file names is empty, your function should raise the error message "The array of file names is empty".
Instead your script just shows a NULL output in that case.
Then it's time to become part of a unique family! Discover helpful tips and support other Community members with your knowledge.
Sign In