/* Set global connection for all tables. */
libname x teradata user=test pw=test server=boom connection=global;
/* Create global temporary table & store in the current database schema. */
proc sql;
connect to teradata(user=test pw=test server=boom connection=global);
execute (CREATE GLOBAL TEMPORARY TABLE temp1 (col1 INT )
ON COMMIT PRESERVE ROWS) by teradata;
execute (COMMIT WORK) by teradata;
quit;
/* Insert 1 row into the temporary table to specify the table. */
proc sql;
connect to teradata(user=test pw=test server=boom connection=global);
execute (INSERT INTO temp1 VALUES(1)) by teradata;
execute (COMMIT WORK) by teradata;
quit;
/* Access the temporary table through the global libref. */
data work.new_temp1;
set x.temp1;
run;
/* Access the temporary table through the global connection. */
proc sql;
connect to teradata (user=test pw=test server=boom connection=global);
select * from connection to teradata (select * from temp1);
quit;
/* Drop the temporary table. */
proc sql;
connect to teradata(user=prboni pw=prboni server=boom connection=global);
execute (DROP TABLE temp1) by teradata;
execute (COMMIT WORK) by teradata;
quit;/* Set global connection for all tables. */
libname x teradata user=test pw=test server=boom connection=global;
/* Create a volatile table. */
proc sql;
connect to teradata(user=test pw=test server=boom connection=global);
execute (CREATE VOLATILE TABLE temp1 (col1 INT)
ON COMMIT PRESERVE ROWS) by teradata;
execute (COMMIT WORK) by teradata;
quit;
/* Insert 1 row into the volatile table. */
proc sql;
connect to teradata(user=test pw=test server=boom connection=global);
execute (INSERT INTO temp1 VALUES(1)) by teradata;
execute (COMMIT WORK) by teradata;
quit;
/* Access the temporary table through the global libref. */
data _null_;
set x.temp1;
put _all_;
run;
/* Access the volatile table through the global connection. */
proc sql;
connect to teradata (user=test pw=test server=boom connection=global);
select * from connection to teradata (select * from temp1);
quit;
/* Drop the connection & the volatile table is automatically dropped. */
libname x clear;
/* To confirm that it is gone, try to access it. */
libname x teradata user=test pw=test server=boom connection=global;
/* It is not there. */
proc print data=x.temp1;
run;