Updated on 2026-10-12 GMT+08:00

Migrating Service SQL

Service Syntax Conversion Migration

  1. Save the following SQL statements in an Oracle database as a query.sql file.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    -- The HAVING clause must be placed after the GROUP BY clause, while Oracle allows HAVING to be placed before or after the GROUP BY clause. In the target database, the HAVING clause is moved after the GROUP BY clause.
    SELECT
    id,
    count(*),
    sum(remain_users) 
    FROM LYC.APEX2_DYNAMIC_ADD_REMAIN_TEST 
    HAVING id <= 5
    GROUP BY id;
    
    -- The UNIQUE keyword is migrated to the DISTINCT keyword.
    SELECT UNIQUE add_users FROM LYC.APEX2_DYNAMIC_ADD_REMAIN_TEST;
    
    -- The NVL2(expression, value 1, value 2) function determines the value returned by the query based on whether the specified expression is null. If the expression is not null, then NVL2 returns value 1. If the expression is null, then NVL2 returns value 2.
    SELECT NVL2(add_users, 1, 2) FROM LYC.APEX2_DYNAMIC_ADD_REMAIN_TEST WHERE rownum <= 2;
    

  2. Place the query.sql file from 1 in the input directory of the decompressed DSC folder.

  3. In the current directory of runDSC.bat, press Shift and right-click, select Open PowerShell window here, and perform the conversion.

    Replace D:\DSC\DSC\input, D:\DSC\DSC\output, and D:\DSC\DSC\log with the actual DSC paths.
    1
    .\runDSC.bat --source-db Oracle --input-folder D:\DSC\DSC\input --output-folder D:\DSC\DSC\output --log-folder D:\DSC\DSC\log --application-lang SQL --conversion-type bulk --target-db gaussdbA
    

  4. After the conversion is complete, a DML file is generated in the output directory.

Migration Verification

  1. Execute the SQL statements in the Oracle database before migration.
  2. Execute the migrated SQL statements in the SQL window.
  3. Compare the execution results. If they are the same, the SQL migration is complete.