Reputation: 735
I have a silly question... for some reason I just can't get it work...
I want to insert a row into an empty table using the today(function).
This is what I do:
insert into gal_risk_factor (RISK_FACTOR_ID, VALID_FROM_DTTM,
RISK_FACTOR_NM, EFFECTIVE_FROM_DTTM, EFFECTIVE_TO_DTTM)
values ("1",today(),
"GGG",
"01JAN1901:00:00:00"dt, "01JAN2999:00:00:00"dt
)
This is the error I get:
today(),
_____
22
202
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant,
a missing value, ), +, ',', -, MISSING, NULL, USER.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
What am I missing here...?
Thank you in advance, Gal.
Upvotes: 1
Views: 688
Reputation: 4792
I guess the VALUES list cannot contain function, only constants.
Try creating a macro var and use it:
%let today=%sysfunc(today());
insert into gal_risk_factor (RISK_FACTOR_ID, VALID_FROM_DTTM,
RISK_FACTOR_NM, EFFECTIVE_FROM_DTTM, EFFECTIVE_TO_DTTM)
values ("1", &today,
"GGG",
"01JAN1901:00:00:00"dt, "01JAN2999:00:00:00"dt
)
Edit: In case VALID_FROM_DTTM is meant to store datetime values use a constant like this:
%let today_dttm=%sysfunc(dhms(%sysfunc(today()), 0, 0, 0));
Upvotes: 2