这不是纯粹的Teradata问题。我不是要求在Teradata中创建一个易失性表。对于使用来自SAS的Teradata的OLEDB
连接的人来说,这是一个问题。我知道可以使用Volatile tables
甚至SQL assistant
在心跳中创建Teradata Interface to SAS
。但是,如果有用户不在SAS网格上并且他们没有安装SAS i / f到teradata,他们使用OLEDB连接SAS和Teradata。
以下是使用OLEDB运行良好的代码片段,它让我们知道我们在谈论什么。
下面的代码运行良好:
proc sql;
connect to OLEDB(Provider='MSDASQL' Extended_Properties='DRIVER={Teradata};DBCNAME=UDWPROD;AUTHENTICATION=ldap' UID="&DMID" PWD="&DMPWD");
create table out.TB as
select a.*, b.C7
from connection to OLEDB
(select
DB.C1,
DB.C2,
from
DB
) as a inner join mytb as b
on DB.C9=b.C9
and (intnx('year',b.C7,-1,'same') le a.fst_srvc_dt lt intnx('year',b.C7,1,'same'));
%put &sqlxmsg ;
disconnect from OLEDB ;
quit;
沿着同样的路线,我们尝试运行它,但要么存在语法错误(希望如此),要么它不喜欢它(对此有点太糟糕了......)
proc sql;
connect to OLEDB(Provider='MSDASQL' Extended_Properties='DRIVER={Teradata};DBCNAME=SITEPRD;AUTHENTICATION=ldap' UID="&DMID" PWD="&DMPWD");
execute (create multiset volatile table idlist (my_id integer, mydate date)
ON COMMIT PRESERVE ROWS) by teradata;
execute (COMMIT WORK) by teradata;
insert into idlist
select distinct MyId_sas, mydate
from mysource;
quit; 3:52 PM
And got this output: 3:52 PM
proc sql;
28 connect to OLEDB(Provider='MSDASQL' Extended_Properties='DRIVER={Teradata};
28 ! DBCNAME=SITEPRD;AUTHENTICATION=ldap' UID="&DMID" PWD="&DMPWD");
SYMBOLGEN: Macro variable DMID resolves to ConfusedUser
SYMBOLGEN: Macro variable DMPWD resolves to Youbetcha!
29 execute (create multiset volatile table idlist (my_id integer, mydate date)
30 ON COMMIT PRESERVE ROWS) by teradata;
ERROR: The TERADATA engine cannot be found.
ERROR: A Connection to the teradata DBMS is not currently supported, or is not installed at
your site.
31 execute (COMMIT WORK) by teradata;
ERROR: The TERADATA engine cannot be found.
ERROR: A Connection to the teradata DBMS is not currently supported, or is not installed at
your site.
32 insert into idlist
33 select distinct MyId_sas, mydate
34 from mysource;
ERROR: File WORK.idlist.DATA does not exist.
NOTE: SGIO processing active for file WORK.mysource.DATA.
35 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 9.19 seconds
cpu time 1.75 seconds
这是目前为SAS安装的AFAIK
NOTE: PROCEDURE SETINIT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Operating System: WX64_SV .
Product expiration dates:
---Base SAS Software
30DEC2016
---SAS/STAT
30DEC2016
---SAS/GRAPH
30DEC2016
---SAS/Secure 168-bit
30DEC2016
---SAS/Secure Windows
30DEC2016
---SAS/ACCESS Interface to PC Files
30DEC2016
---SAS/ACCESS Interface to ODBC
30DEC2016
---SAS/ACCESS Interface to OLE DB
30DEC2016
---SAS Workspace Server for Local Access
30DEC2016
---High Performance Suite
30DEC2016
你如何让它发挥作用?
答案 0 :(得分:1)
我没有要引用的teradata实例,但我认为您的问题是您没有使用引用名称创建oledb连接,那么您尝试将其引用为“teradata”。
试试这个:
connect to OLEDB as teradata (Provider='MSDASQL' Extended_Properties='DRIVER={Teradata};DBCNAME=SITEPRD;AUTHENTICATION=ldap' UID="&DMID" PWD="&DMPWD");
答案 1 :(得分:1)
你有两个错误。首先,您定义了与OLEDB
的连接,然后尝试在未定义的名为TERADATA
的连接上执行命令。将AS TERADATA
添加到CONNECT
语句,以便建立连接或更改EXECUTE
语句以使用OLEDB
连接名称。
最后,您的插入语句将在SAS WORK库中创建一个表。您是否期望它能够插入或读取OLEDB连接?如果要将数据从SAS插入Teradata表,则需要创建指向Teradata的libref。没有必要"创建"该表首先。 SAS很乐意为您创建表格。
libname TERADATA OLEDB ... connection details ... ;
proc sort data=mysource(keep=myid_sas mydate) nodupkey out=TERADATA.idlist;
by _all_;
run;