Previous Page | Next Page

SAS/ACCESS Interface to Teradata

SQL Pass-Through Facility Specifics for Teradata


Key Information

For general information about this feature, see Overview of the SQL Pass-Through Facility. Teradata examples are available.

Here are the SQL pass-through facility specifics for the Teradata interface.

CAUTION:

Do not issue a Teradata DATABASE statement within the EXECUTE statement in PROC SQL. Add the SCHEMA= option to your CONNECT statement if you must change the default Teradata database.  [cautionend]


Examples

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 then recreates the SALARY table, inserts two rows, and then disconnects from the Teradata DBMS. Notice 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 then 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 only reading 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;

Previous Page | Next Page | Top of Page