Updated on 2024-04-25 GMT+08:00

Migrating Syntax

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

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    -- Generally, the HAVING clause must appear after the GROUP BY clause, but Oracle allows HAVING to appear before or after the GROUP BY clause. Therefore, you need to move the HAVING clause after the GROUP BY clause in the target database.
    SELECT
    id,
    count(*),
    sum(remain_users) 
    FROM LYC.APEX2_DYNAMIC_ADD_REMAIN_TEST 
    HAVING id <= 5
    GROUP BY id;
    
    UNIQUE keywords are migrated as DISTINCT keywords.
    SELECT UNIQUE add_users FROM LYC.APEX2_DYNAMIC_ADD_REMAIN_TEST;
    
    -- In NVL2(expression,value1,value2), if the expression is not Null, NVL2 returns Value1. If the expression is Null, NVL2 returns Value2.
    SELECT NVL2(add_users, 1, 2) FROM LYC.APEX2_DYNAMIC_ADD_REMAIN_TEST SHERE rownum <= 2;
    

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

  3. In the directory of runDSC.bat, press Shift and right-click. Choose 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.