Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
Hi All,
I want to concatenate the 2nd table to 1st table, only when 1st table is already loaded, otherwise don't concatenate.
Script-->
IF vFlag = 1 then
Table1:
load...;
ENDIF
If NoOfRows('Table1') > 0
Set vConcatenate = CONCATENATE(Table1);
ELSE
Set vConcatenate = ;
ENDIF
$(vConcatenate)
Table2:
load...;
The issue is the dollar expansion $(vConcatenate) is enabling red lines in the below load script. How to avoid this and write a clean code.
That is a cosmetic bug in the syntax checker, so you will just have to live with it.
That is a cosmetic bug in the syntax checker, so you will just have to live with it.
I don't think there is a way to avoid those red lines when you are using a variable. May be you can do something like this:
IF vFlag = 1 then
Table1:
load...;
Concatenate(Table1)
load...;
ELSE
Table2:
load....;
ENDIF
try
IF vFlag = 1 then
Table1:
load..
From Table1;
ENDIF
IF NoOfRows('Table1') > 0 then
concatenate(Table1)
load...
From Table2;
ENDIF
Hi Bharath,
the only time i had to do that it wasnt a complex loading load sentence so i solved it with no variables, the bad thing about it is that the load sentence must be added twice and its not a good practice.
Hope it helps!
Kidenst regards,
LOAD * INLINE [
Col1,Col2
345,dfg
456,fgh ];
If (NoOfRows('Table1') > 0) THEN
CONCATENATE(Table1)
Table2:
LOAD * INLINE [
Col1,Col2
123,asd
234,sdf ];
ELSE
NOCONCATENATE
Table2:
LOAD * INLINE [
Col1,Col2
654,eqweq ];
ENDIF
If you use the code as shown in your OP, you will get run-time errors as well; the CONCATENATE (...) keyword should go after the table name, not before.
Or you can omit the Table2: label before the last LOAD and change the IF-THEN-ENDIF into:
If NoOfRows('Table1') > 0
Set vConcatenate = CONCATENATE(Table1);
ELSE
Set vConcatenate = Table2:;
ENDIF
Peter I think I have seen Join/concatenate/keep to work before the table name as well. So something like this is what I have seen before:
Join(TableName)
Table1
LOAD ....
Concatenate(TableName)
Table2
LOAD ....
@Sunny, you are right. The concatenate keyword works either above or below the table name.
Thanks Peter. Your solution is nice, however the syntax red lines seems cannot be avoided.