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 Procedures

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

Overview

🎓 beginner 15 min. SAP HANA Dynamic TieringBeginnerSAP HANASAP Web Ide

You will learn

  • โœ”How to create a stored procedure to migrate records in related tables as a single transaction.
  • โœ”How to call a stored procedure.
Unknown U Unknown November 1, 2022
Created by June 27, 2018
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.

Running Script
Running Script

Verify everything executed correctly.

Verify Script
Verify Script

Step 2 Migrate data between tables
+
Step 3 Auto-Commit and isolation levels
+
Step 4 Create a simple migration stored procedure
+
Step 5 Call the migration stored procedure
+
Step 6 Create a more complex migration stored procedure
+
Step 7 Call the more complex migration stored 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 7
1. Prepare data 2. Migrate data between tables 3. Auto-Commit and isolation levels 4. Create a simple migration stored procedure 5. Call the migration stored procedure 6. Create a more complex migration stored procedure 7. Call the more complex migration stored procedure

Learn more →