You can run SQL function calls from external procedures using either of the following languages and APIs.
| External Routine Language | API to Run SQL |
|---|---|
| C or C++ | CLIv2 |
| Java | JDBC |
You cannot embed SQL statements in an external procedure, you can only use standard CLIv2 or JDBC function calls to the appropriate driver, which translates them into SQL requests and submits them to the Parser for processing.
See Teradata® Call-Level Interface Version 2 Reference for Workstation-Attached Systems, B035-2418 or Teradata JDBC Driver Reference, available at https://teradata-docs.s3.amazonaws.com/doc/connectivity/jdbc/reference/current/frameset.html, for information about the available SQL function calls.
Restrictions on Declaring an C++ External Procedure
If you specify CPP in the Language Clause, then you must declare the called C++ procedure as extern "C" to make sure that the procedure name is not converted to an overloaded C++ name, for example.
extern "C"
void my_cpp(long int *input_int, long int *result, char sqlstate[6])
{