Hi,
I would like to use a variable that has a date stored in it as my table name, but I keep getting the error: Unknown Statement 01-Feb-2015.
First I load my date:
Date:
Load
Date(Timestamp#(Date,'DD-MMM-YYYY hh.mm.ss TT'),'DD-MMM-YYYY') as Date (this works the dates look normal)
From
File;
MaxDate:
Date(Max(Date)) as MaxDate (if I only do Max(Date) as MaxDate I get the number 40125 instead of a date)
Resident
Date;
Let vMaxDate = peek('MaxDate',0,'vMaxDate'); (this also works it stores 01-Feb-2015)
Drop table Date;
Drop table MaxDate;
Set table = $(vMaxDate);
$(table):
Load
x
x
x
From
File;
and then I get the Unknown Statement: 01-Feb-2015 error message:
What am I doing wrong?
Try using
Date(Max(Date), 'DDMMYYYY') as MaxDate
to remove the dashes from the date so you use 01FEB2015 rather than 01-FEB-2015
The dash is not an acceptable character in a tablename.
I am not sure why you would want a table name that changes though.
Try using [...] around your variable expansion:
[$(table)]:
Load
x
x
x
From
File;
the dash(-) cant be used as part of table name.
Try this:
[$(table)]:
Load
x
x
x
From
File;
Try using
Date(Max(Date), 'DDMMYYYY') as MaxDate
to remove the dashes from the date so you use 01FEB2015 rather than 01-FEB-2015
The dash is not an acceptable character in a tablename.
I am not sure why you would want a table name that changes though.
You will still need to enclose the variable in square braces or single quotes.
Either of the options below will work.
'$(table)':
Load
x
x
x
From
File;
[$(table)]:
Load
x
x
x
From
File;