我有一个愚蠢的问题...... 出于某种原因,我无法让它发挥作用......
我想使用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
)
这是我得到的错误:
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.
我在这里想念的是什么......?
提前谢谢你, 加仑
答案 0 :(得分:2)
我猜VALUES列表不能包含函数,只能包含常量。
尝试创建宏var并使用它:
%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
)
编辑: 如果VALID_FROM_DTTM用于存储日期时间值,请使用如下常量:
%let today_dttm=%sysfunc(dhms(%sysfunc(today()), 0, 0, 0));