I am trying to create a volatile table in Teradata that I would like to join with a real teradata table on a common variable. I am able to create the volatile table, as below.
libname TDWORK teradata user="&user.@LDAP" password=&pword tdpid=bmg dbmstemp=yes connection=global;
/*proc sql; drop table TDWORK.FDR_TIN_jb; quit;*/
data TDWORK.FDR_TIN_jb ;
set one_per_good_ssn(obs=100);
run;
proc sql ;
connect to teradata (connection=global user="&user.@LDAP" password=&pword tdpid=bmg);
execute (
create volatile table test as (
select * from FDR_TIN_jb
) with data on commit preserve rows
) by teradata;
quit;
However, when I try to join this volatile table with a real table, it gives me an error.
ERROR: Teradata prepare: Object 'test' does not exist.
The code I am using is:
proc sql ;
connect to teradata(user="&user.@LDAP" password=&pword tdpid=bmg database=Bmgpcust mode=teradata);
create table Cust_Mstr_Wk_Curr_Cdb as select * from connection to teradata
( Select
/* a.* ,*/
b.Cust_Tin ,
b.Cust_Num ,
b.Cust_Co_Id ,
b.Cust_Tin_Cd
from test a ,
Bmgpcust.Cust_Mstr_Wk_Curr_Cdb b
where a.SSN = b.Cust_Tin
);
quit;
Any help would be much appreciated! Thanks.
Jit
Don't make a NEW connection for your SQL code. That will probably result in a new volatile table space.
Use the one you already have instead.
data TDWORK.FDR_TIN_jb ;
set one_per_good_ssn(obs=100);
run;
proc sql ;
connect using TDWORK ;
execute by tdwork
(create volatile table test as
(select * from FDR_TIN_jb
) with data on commit preserve rows
) ;
quit;
Hi Tom,
I tried this and your code works to create TEST, but it's still giving me the same error when I try to join.
ERROR: Teradata prepare: Object 'test' does not exist.
Please post your SAS log in that case. Are you doing it in the same SQL step and connection?
Yes, in the same session. Here is the log.
Why do you keep making NEW connections to Teradata?
* Make connection to teradata for volatile tables ;
libname tdwork teradata ... dbmstemp=yes ... ;
* Make volatile table using SAS code ;
data TDWORK.FDR_TIN_jb ;
set one_per_good_ssn(obs=100);
run;
* Make volatile table using Teradata code ;
proc sql ;
connect using TDWORK as teradata;
execute by teradata
(create volatile table test as
(select * from FDR_TIN_jb
) with data on commit preserve rows
);
quit;
* Reference volatile table and permanent table using Teradata code ;
proc sql ;
connect using TDWORK as teradata;
create table Cust_Mstr_Wk_Curr_Cdb as
select * from connection to teradata
( Select
a.SSN
, b.Cust_Tin
, b.Cust_Num
, b.Cust_Co_Id
from test a
, Bmgpcust.Cust_Mstr_Wk_Curr_Cdb b
where a.SSN = b.Cust_Tin
);
Have a look at the DBCOMMIT and INSERTBUFF settings for Teradata. In my experience the default settings are not optimal and usually need changing to get way better table loading performance. INSERTBUFF = 10000 is my usual starting point but it pays to experiment.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.