Choose Language Hide Translation Bar
Highlighted
J_Bonnouvrier1
Level II

Loop on datatable join

Hi everybody,

 

I face an issue in one of my scripts: I basically would like to loop on database Join, the column being renames at each loop.

I supect the problem to come from following statement: "By Matching Columns( Column("Component_" || char(i-1)) = :Material_JOIN ),"

 

Do you have any idea how to write the script differently?

Many thanks!

 

Jerome

 

Script:

 

While(i < 8,

Column( dt2, 2 ) << Set Name( "Component_" || char(i) );
Column( dt2, 3 ) << Set Name( "Quantity_" || char(i) );


Data Table( dt_i ) << Join(
 With( Data Table( dt2 ) ),
 Update,
 By Matching Columns( Column("Component_" || char(i-1)) = :Material_JOIN ),
 Drop multiples( 0, 0 ),
 Include Nonmatches( 1, 0 ),
 Preserve main table order( 1 )
);

dt_i = Current Data Table();

N_R_m1 = N Rows( dt );

i = i + 1;
); // End while

2 REPLIES 2
Highlighted
txnelson
Super User

Re: Loop on datatable join

If you use the

     Merge same name colums

option it will not rename the columns

 

You may also want to look at using the Update

       Tables=>Update

It handles columns by Merging Same Name Columns automatically

Jim
Highlighted
J_Bonnouvrier1
Level II

Re: Loop on datatable join

Hi Jim,

 

Actually, you are right, using the merge is a good idea and I will do it.

Concerning the "same name", it is not an option as the loop is used to build a hierarchy: therefore, using an index is key then to analyze the new datatable. That's the reason why I need to merge on a name that will change at each iteration.

 

Thanks,

 

Jerome

 

Article Labels

    There are no labels assigned to this post.