Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

datanibbler
Esteemed Contributor

Avoid errors due to duplicate field_names

Hi,

I have the following problem:

In a big loop, a table is created, let's say the name is [error_table] - then, within the loop (under certain circumstances) I create a second version of that, going

>>>>>>>>>>><<<<<<<<<<<<<<<

error_table_v2: LOAD *,  ... RESIDENT error_table;

DROP TABLE error_table;

RENAME TABLE error_table_v2 TO error_table;

>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<

=> So after that I have a table identical to the original [error_table], only with a few fields more - but that is just in the first iteration of the loop!

In the second iteration, of course the same code is executed again and due to that >> * <<, I get the error message that field_names must not be duplicated in a table.

<=> Explicitly naming only the fields from the original table in the LOAD would probably not be a solution because that way I'd lose the information I have generated in the first iteration?

Can anyone give me a hint on how to deal with this? Generating a new fieldname for every iteration of the loop would be quite cumbersome because I'd have to mix them all into one afterwards. Is there an easier way?

Thanks a lot!

Best regards,

DataNibbler

1 Solution

Accepted Solutions
datanibbler
Esteemed Contributor

Re: Avoid errors due to duplicate field_names

Hi Vineeth,

I don't yet quite understand you.

Anyway, for starters I'll try to structure my code a bit more - it is very  complex as there are several IF_THEN_clauses within the loop. And I'll build an info into the messagebox as to how many iterations there are going to be.

Know what, I'll just leave it - the entire thing is about correcting some errors in the underlying Excel_file, but the error is only in a handful of records and it's a lot more complicated to automatically fix those in QV than to just display the facts and quickly fix the errors in the base_file.

With the thought in mind that any successor of mine should be able to understand and maintain the code, I'll try to avoid that enormous unnecessary complexity and just have a messagebox telling >>whoever is running the script<< to fix those errors in the base_file and, if possible, tell him how to do it.

Thanks a lot anyway!

Best regards,

DataNibbler

2 Replies
vinieme12
Esteemed Contributor II

Re: Avoid errors due to duplicate field_names

using Qualify() maybe?

datanibbler
Esteemed Contributor

Re: Avoid errors due to duplicate field_names

Hi Vineeth,

I don't yet quite understand you.

Anyway, for starters I'll try to structure my code a bit more - it is very  complex as there are several IF_THEN_clauses within the loop. And I'll build an info into the messagebox as to how many iterations there are going to be.

Know what, I'll just leave it - the entire thing is about correcting some errors in the underlying Excel_file, but the error is only in a handful of records and it's a lot more complicated to automatically fix those in QV than to just display the facts and quickly fix the errors in the base_file.

With the thought in mind that any successor of mine should be able to understand and maintain the code, I'll try to avoid that enormous unnecessary complexity and just have a messagebox telling >>whoever is running the script<< to fix those errors in the base_file and, if possible, tell him how to do it.

Thanks a lot anyway!

Best regards,

DataNibbler