Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
As you could see below, I am trying to store a variable's value in a table when its length is greater than 0. Once the values are stored in a field, each value has to be passed to the SQL statement using a FOR loop.
The variable 'vMonthName' doesnt seem to be showing anything. it shows NULL. Could you please help?
SET vTranMonth = '2023-01-31', '2023-03-31';
If Len(trim('$(vTranMonth)'))>0 then
TmpTable:
Load '$(vTranMonth)' as TranMonth;
For i = 1 to FieldValueCount('TranMonth')
Let vMonthName = Date(FieldValue('TranMonth', $(i)), 'YYYY-MM-DD');
SLDataLoad:
LOAD col1, col2;
SQL SELECT 'col1', 'col2' from tablename where dateval=$(vMonthName);
Next i
Else
End If
Hi,
You can try a script like this :
SET vTranMonth = 2023-01-31, 2023-03-31;
If Len(trim('$(vTranMonth)'))>0 then
TmpTable:
Load
Date#(Trim(SubField('$(vTranMonth)', ',')), 'YYYY-MM-DD') as TranMonth
AutoGenerate(1)
;
For Each vMonthName in FieldValueList('TranMonth')
// Let vMonthName = Date(FieldValue('TranMonth', $(i)), 'YYYY-MM-DD');
Trace SELECT 'col1', 'col2' from tablename where dateval=$(vMonthName);
Next vMonthName
Else
End If