admin管理员组文章数量:1391969
I have a SAS dataset which holds todays date and datetime. My requirement here is to create SAS macro variables which hold the DATE and DATETIME values. And then Update those values in Oracle table. Could you please help me what formats I need to use to update date/timestamp values into Oracle table.
data customer;
input cust_id cust_login_dt cust_login_ts;
cust_id=100;
cust_login_dt=today(); /* Storing date values in SAS Format /
cust_login_ts=datetime(); / Storing datetime values in SAS Format */
run;
proc sql;
select cust_id,cust_login_dt ,cust_login_ts i
Into :custid,:custlgndt,:custlgnts
from customer;
quit;
/* Now I need to update above values in Oracle table using SQL Passthrough */
proc sql;
connect to oracle(user=xxx password=xxxx path=custora1);
execute (
upate cust_fact
set lgn_dt=&custlgndt,lgn_ts=&cuslgnts
where cust_id=&custid.
) by oracle;
execute(commit);
quit;
If I execute above query, Update query is failing with Invalid values to the input columns error.
Could you please help me to update SAS date and SAS Datetime values into Oracle table using SAS macro variables.
I have a SAS dataset which holds todays date and datetime. My requirement here is to create SAS macro variables which hold the DATE and DATETIME values. And then Update those values in Oracle table. Could you please help me what formats I need to use to update date/timestamp values into Oracle table.
data customer;
input cust_id cust_login_dt cust_login_ts;
cust_id=100;
cust_login_dt=today(); /* Storing date values in SAS Format /
cust_login_ts=datetime(); / Storing datetime values in SAS Format */
run;
proc sql;
select cust_id,cust_login_dt ,cust_login_ts i
Into :custid,:custlgndt,:custlgnts
from customer;
quit;
/* Now I need to update above values in Oracle table using SQL Passthrough */
proc sql;
connect to oracle(user=xxx password=xxxx path=custora1);
execute (
upate cust_fact
set lgn_dt=&custlgndt,lgn_ts=&cuslgnts
where cust_id=&custid.
) by oracle;
execute(commit);
quit;
If I execute above query, Update query is failing with Invalid values to the input columns error.
Could you please help me to update SAS date and SAS Datetime values into Oracle table using SAS macro variables.
Share Improve this question edited Mar 15 at 20:25 Tom 51.8k2 gold badges18 silver badges34 bronze badges asked Mar 15 at 19:29 Sudhakar NelapatiSudhakar Nelapati 33 bronze badges 5 |1 Answer
Reset to default 0When the macro pre-processor replaces the macro variable references with the text strings they contain the result needs to be valid Oracle code. So your goal should be to create something like:
upate cust_fact
set lgn_dt=DATE '2025-03-15'
, lgn_ts=TIMESTAMP '205-03-15 09:10:15'
where cust_id=100
Which means you want the macro variables to contain text that looks like this:
%let custlgndt=DATE '2025-03-15';
%let cuslgnts=TIMESTAMP '2025-03-15 09:10:15';
%let cust_id=100;
Which you can achieve by running a query like this:
select cust_id
, 'DATE ' || quote(put(cust_login_dt,yymmdd10.),"'")
, 'TIMESTAMP '|| quote(translate(put(cust_login_ts,e8601dt19.),' ','T'),"'")
into :custid trimmed
, :custlgndt
, :custlgnts
from customer;
本文标签: Insert DATETIMESTAMP values into Oracle table using SAS Macro VariablesStack Overflow
版权声明:本文标题:Insert DATETIMESTAMP values into Oracle table using SAS Macro Variables - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744605524a2615329.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
&custlgndt
a string, a number, or some proprietary date datatype? If a string, what format is it in (can you show a sample value)? What exactly is being will determine what you need to do to update a date column in Oracle. – Paul W Commented Mar 16 at 0:14