Copy SQL Stored Procedures | Teradata Data Mover - About Copying SQL Stored Procedures - Teradata Data Mover

Teradata® Data Mover User Guide - 20.01

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
Lake
VMware
Product
Teradata Data Mover
Release Number
20.01
Published
November 2023
Language
English (United States)
Last Update
2023-12-05
dita:mapPath
hlv1700545853003.ditamap
dita:ditavalPath
mpm1591127278842.ditaval
dita:id
don1467241476387
Product Category
Analytical Ecosystem
A SQL stored procedure is a set of SQL statements with an assigned name that is stored in the database in compiled form so that it can be shared by a number of programs. An example SQL stored procedure can be created with the following SQL statements:
CREATE PROCEDURE SP_deleteTestTable ()
BEGIN 
DELETE FROM test;
END;
After the stored procedure is created, its definition can be retrieved by executing a show procedure query:
SHOW PROCEDURE SP_deleteTestTable;

Copying SQL Stored Procedures Using Data Mover

Data Mover copies SQL stored procedures as follows:
  • Data Mover retrieves the SQL stored procedure creation DDL by executing a show procedure dbname.spname SQL statement.
  • Data Mover does not parse a create procedure DDL; it executes the exact same DDL on the target system. It does not relocate or rename stored procedure objects.
  • If the procedure name in the procedure definition is not fully qualified, the procedure is created in the database having the same name as the source procedure database.
  • If the table names in the procedure definition are not fully qualified, those tables must exist in the database having the same name as the source procedure database to avoid an error.
  • If the object being copied does not exist on the target database, it is created on the target database. If the object does exist on the target database, the object is overwritten – unless the overwrite_existing_objects property is set to false. In that case, a create time error is generated.
  • If a procedure is part of a full database copy, the procedure is copied with the database using DSA. It is not copied separately.
When copying a SQL stored procedure, the underlying table for the procedure must already exist on the target system, or be copied with the job. Depending on the stored procedure creation SQL, a JDBC error may occur when creating a stored procedure without the underlying table.

If you want to copy a SQL stored procedure without copying the underlying table, you can use DSA. See About Copying Views, Macros, and Stored Procedures Using DSA.