13.07.2015 Views

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>SAS</strong>/<strong>ACCESS</strong> Interface to Teradata 4 Examples 791sensitive. This option is available when you use the LIBNAME statementand also with the SQL pass-through facility.CAUTION:Do not issue a Teradata DATABASE statement within the EXECUTE statement inPROC SQL. Add the SCHEMA= option to your CONNECT statement if you mustchange the default Teradata database. 4ExamplesIn this example, <strong>SAS</strong>/<strong>ACCESS</strong> 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, <strong>SAS</strong>/<strong>ACCESS</strong> connects to the Teradata DBMS using the teraalias, drops and then recreates the SALARY table, inserts two rows, and thendisconnects from the Teradata DBMS. Notice that COMMIT must follow each DDLstatement. DROP TABLE and CREATE TABLE are DDL statements. The COMMITstatement that follows the INSERT statement is also required. Otherwise, Teradatarolls 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, <strong>SAS</strong>/<strong>ACCESS</strong> connects to the Teradata DBMS using the teraalias, updates a row, and then disconnects from the Teradata DBMS. The COMMITstatement causes Teradata to commit the update request. Without the COMMITstatement, Teradata rolls back the update.proc sql;connect to teradata as tera ( user=testuser password=testpass );execute (update salary set current_salary=45000where (name=’Irma L.’)) by tera;execute (commit) by tera;disconnect from tera;quit;In this example, <strong>SAS</strong>/<strong>ACCESS</strong> uses the tera2 alias to connect to the Teradatadatabase, selects all rows in the SALARY table, displays them using PROC SQL, anddisconnects from the Teradata database. No COMMIT statement is needed in thisexample because the operations are only reading data. No changes are made to thedatabase.proc sql;connect to teradata as tera2 ( user=testuser password=testpass );select * from connection to tera2 (select * from salary);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!