Below are samples of creating, populating and accessing volatile Teradata tables.
With SAS® 8.2, the following PROC SQL Pass-Through example will allow you to create and populate a volatile Teradata table:
proc sql;
connect to teradata(user=userid pw=password server=server_name);
execute
(CREATE VOLATILE TABLE temp1 (col1 INT ) ON COMMIT PRESERVE ROWS)
by teradata;
execute (COMMIT WORK ) by teradata;
execute (INSERT INTO temp1 VALUES(1) ) by teradata;
execute ( COMMIT WORK ) by teradata;
select * from connection to teradata ( select * from temp1 );
quit;
With SAS® 9.1, the following example will allow you to create and populate a volatile Teradata table using the LIBNAME ACCESS engine.
/*Volatile tables:*/
/* Global connection for all tables */
libname x teradata user=userid pw=password server=server_name
connection=global;
/* Create a volatile table */
proc sql;
connect to teradata(user=userid pw=password server=server_name
connection=global);
execute
(CREATE VOLATILE TABLE temp1 (col1 INT ) ON COMMIT PRESERVE ROWS )
by teradata;
execute ( COMMIT WORK ) by teradata;
quit;
/* Insert one row into the volatile table */
proc sql;
connect to teradata(user=prboni pw=prboni server=boom
connection=global);
execute ( INSERT INTO temp1 VALUES(1) ) by teradata;
execute ( COMMIT WORK ) by teradata;
quit;
/* Get at the temp table through the global libname. */
data null;
set x.temp1;
put all;
run;
/* Get to the volatile table through the global connect.*/
proc sql;
connect to teradata (user=userid pw=password server=server_name
connection=global);
select * from connection to teradata
( select * from temp1 );
quit;
/* drop the connection; the volatile table is automatically dropped */
libname x clear ;
/* to convince yourself it's gone, try to access it */
libname x teradata user=userid pw=password server=server_name
connection=global;
/* it's not there! */
proc print data=x.temp1 ;
run ;
/* it's not there! */ proc print data=x.temp1 ; run ;