In this example,
SAS/ACCESS
connects to the Teradata DBMS using the
dbcon
alias.
proc sql;
connect to teradata as dbcon (user=testuser pass=testpass);
quit;
In the next example,
SAS/ACCESS connects to the Teradata DBMS using the
tera
alias,
drops and re-creates the SALARY table, inserts two rows, and disconnects
from the Teradata DBMS. Note that COMMIT must follow each DDL statement.
DROP TABLE and CREATE TABLE are DDL statements. The COMMIT statement
that follows the INSERT statement is also required. Otherwise, Teradata
rolls back the inserted rows.
proc sql;
connect to teradata as tera ( user=testuser password=testpass );
execute (drop table salary) by tera;
execute (commit) by tera;
execute (create table salary (current_salary float, name char(10)))
by tera;
execute (commit) by tera;
execute (insert into salary values (35335.00, 'Dan J.')) by tera;
execute (insert into salary values (40300.00, 'Irma L.')) by tera;
execute (commit) by tera;
disconnect from tera;
quit;
For this example,
SAS/ACCESS
connects to the Teradata DBMS using the
tera
alias,
updates a row, and disconnects from the Teradata DBMS. The COMMIT
statement causes Teradata to commit the update request. Without the
COMMIT statement, Teradata rolls back the update.
proc sql;
connect to teradata as tera ( user=testuser password=testpass );
execute (update salary set current_salary=45000
where (name='Irma L.')) by tera;
execute (commit) by tera;
disconnect from tera;
quit;
In this example,
SAS/ACCESS
uses the
tera2
alias to connect to the Teradata
database, selects all rows in the SALARY table, displays them using
PROC SQL, and disconnects from the Teradata database. No COMMIT statement
is needed in this example because the operations are reading only
data. No changes are made to the database.
proc sql;
connect to teradata as tera2 ( user=testuser password=testpass );
select * from connection to tera2 (select * from salary);
disconnect from tera2;
quit;
In this next example,
MODE=TERADATA is specified to avoid case-insensitive behavior. Because
Teradata Mode is used, SQL COMMIT statements are not required.
/* Create & populate the table in Teradata mode (case insensitive). */
proc sql;
connect to teradata (user=testuser pass=testpass mode=teradata);
execute(create table casetest(x char(28)) ) by teradata;
execute(insert into casetest values('Case Insensitivity Desired') )
by teradata;
quit;
/* Query the table in Teradata mode (for case-insensitive match). */
proc sql;
connect to teradata (user=testuser pass=testpass mode=teradata);
select * from connection to teradata (select * from
casetest where x='case insensitivity desired');
quit;