SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Migrate Records in Related Tables Using Stored Procedure

Using a stored procedure to migrate records in related tables as a single transaction.

Overview

🎓 beginner 15 min. SAP HANA Dynamic TieringBeginnerSAP HANASAP HANA StudioBig DataSql

You will learn

  • โœ”Creating a stored procedure to migrate records in related tables as a single transaction.
  • โœ”Calling a stored procedure.
Unknown U Unknown November 1, 2022
Created by November 3, 2016
Contributors

Prerequisites

Prerequisites

Steps

Step 1 Prepare Data
โ€”

In order to ensure that the migration script runs correctly, we will start by refreshing the data in the tables that will be used in this tutorial section. Run the script below to restore data. Replace “<SID>” with your system’s System Id.

SQL
TRUNCATE TABLE "TPCH"."LINEITEM_DT";
TRUNCATE TABLE "TPCH"."ORDERS_DT";
TRUNCATE TABLE "TPCH"."LINEITEM_CS";
DELETE FROM "TPCH"."ORDERS_CS";

IMPORT FROM CSV FILE '/hana/shared/<SID>/HDB00/work/TPCH_DATA/Orders.csv'
INTO TPCH.ORDERS_CS
  WITH THREADS 8 BATCH 10000;

IMPORT FROM CSV FILE '/hana/shared/<SID>/HDB00/work/TPCH_DATA/LineItem.csv'
INTO TPCH.LINEITEM_CS
  WITH THREADS 8 BATCH 10000;

ORDERS_CS cannot be truncated unlike the other tables due to foreign key constraints. Therefore a “DELETE” statement is used instead.

Restore Data
Restore Data

Verify everything executed correctly.

Restore Success
Restore Success

Step 2 Create Migration Stored Procedure
+
Step 3 Call Migration Store Procedure
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 3
1. Prepare Data 2. Create Migration Stored Procedure 3. Call Migration Store Procedure

Learn more →