Hands on exercise help - Exasol database development course

Padawan

Hi,

I am taking Exasol Database Development course and working on the exercise 2. 

Course >> Lua Scripts >> Hands-On Exercise 2: generate_import Function >> Exercise

I am getting the expected result with the below code.

--/
CREATE OR REPLACE SCRIPT helper() AS
function generate_import(table_name, connection, files)
if #files == 0 then error("The array of file names is empty") end
res1 = 'IMPORT INTO '..table_name..' FROM CSV AT '..connection
local res2 = ""
for i=1, #files do
res2 = res2.." FILE '"..files[i].."'"
end
print(res1..res2)
--output(tostring(res1..res2))
end
output(generate_import( 'article_new', 'my_connection', {'a1.csv', 'a2.csv'} ))
/

execute script helper() with output;

 

 

 

 output:

 

 

 

IMPORT INTO article_new FROM CSV AT my_connection FILE 'a1.csv' FILE 'a2.csv'

 

 

 

 

However when i submit the same in exercise, I am getting an error as 
Error 101: Your function does not return a string.


Could you please help me out on this.
@exa-Uwe 

Thanks,

Rajanand

1 ACCEPTED SOLUTION

Moderator
Moderator

Hi Rajanand,

in this case, the error message is quite to-the-point in my opinion: Your function has no return clause. That's a bit odd for a function.

So the parser gets this right and you may just correct your script. Please have a look at the FAQ https://community.exasol.com/t5/training-forum/training-faq/td-p/548 as well.

I'm thinking of modifying these coding hands-on exercises and going away from requiring a certain solution, so code samples can be shared here without issues. That's probably more helpful and benefits the whole community.

Thank you for your contribution 😃

View solution in original post

2 REPLIES 2

Moderator
Moderator

Hi Rajanand,

in this case, the error message is quite to-the-point in my opinion: Your function has no return clause. That's a bit odd for a function.

So the parser gets this right and you may just correct your script. Please have a look at the FAQ https://community.exasol.com/t5/training-forum/training-faq/td-p/548 as well.

I'm thinking of modifying these coding hands-on exercises and going away from requiring a certain solution, so code samples can be shared here without issues. That's probably more helpful and benefits the whole community.

Thank you for your contribution 😃

View solution in original post

Padawan

Hi @exa-Uwe 
I don't have an idea how to to share the code and get some tips. Please remove the code posted in this question when you can check. Thanks.