Examples - Analytics Database - Teradata Vantage

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2023-07-11
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
B035-1147
lifecycle
latest
Product Category
Teradata Vantage™

Example: Establishing a Default Connection to Vantage

public class region {

   public static void getRegion(String[] data) throws SQLException
   {
      String sql = "SELECT Region FROM Sales WHERE ID = ";
      try {
         /* Establish default connection. */
         Connection con = 
            DriverManager.getConnection( "jdbc:default:connection " ); 
         /* Execute the statement */
         Statement stmt = con.createStatement();
         ResultSet rs = stmt.executeQuery( sql + data[0] );
         rs.next();
         data[0] = rs.getString("Region");
         stmt.close();
      }
      catch (Exception e) {
         throw new SQLException(e.getMessage(),"38U01");
      }
   }

   ...

}

Example: External Stored Procedure That Reads SQL Data

The following statement specifies the READS SQL DATA data access clause because the getRegion() method that implements the GetRegion external stored procedure executes a SELECT statement.

CREATE PROCEDURE GetRegion(INOUT Str VARCHAR(120))
   LANGUAGE JAVA
   READS SQL DATA
   PARAMETER STYLE JAVA
   EXTERNAL NAME 'JarXSP:region.getRegion';