I made organizing Stored Procedures into Chapters and Steps a principle. These points of separation are clearly marked by comments and by variables used in performance and result logging. A step is one specific technical or conceptual task that cannot be divided into further pieces without leaving the abstraction of Stored Procedures or the task

Read More

Characteristics of Static SQL The SQL statement code cannot be changed during the Stored Procedure execution Variables and parameters can be used to replace literals in the SQL statement Static SQL statements are executed as soon as code execution reaches the statement Many errors can be detected already during the compilation Characteristics of Dynamic SQL

Read More

Introduction to Teradata Stored Procedures & Error Handling Error handling in Teradata Stored Procedures is condition-based, having the same functionality as modern programming languages (C++, Java, etc.). Without the availability of state-based error handling, one would need to implement and invoke code for each error and at each code location where the error could occur.

Read More

What Is A Cursor In A Teradata SQL Stored Procedure? When we are talking about Cursors in Teradata SQL stored procedures, we refer to a pointer to a data record in the result set of an SQL query: SELECT * FROM table_name; Cursors are used to iterate over a result set from one row to

Read More

Variable declarations in a Teradata Stored Procedure are always local to the surrounding compound statement (BEGIN…END), and all the compound statements which are located within the surrounding BEGIN…END. See the example below. We declare an integer variable x in both, the outer and the inner compound statement. While the outer compound statement only has access

Read More

Teradata Partition Elimination – the Stored Procedure Approach Sometimes we need to select the rows from a table’s character column which are starting with a particular prefix, but we don’t know all existing names of this column in advance. For example, in the future, there could be new codes introduced. If we are lucky,  there might be a convention for this codes, such as:

Read More