Hands on exercise 2 Issue - Exasol database development course

Padawan

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

3 REPLIES 3

Contributor

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 🙂

SQL-Fighter

Moderator
Moderator

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.