dmtolpeko / sqlines

SQLines Open Source Database Migration Tools
http://www.sqlines.com
Apache License 2.0
392 stars 175 forks source link

IN Conversion (Oracle -> SQL Server) #50

Open kfordaccela opened 5 years ago

kfordaccela commented 5 years ago

For “Oracle” to “SQL Server” the “IN” is getting replaced with “dbo.IN” which isn’t going to work, trying to do many conversions and would like to use the command line tool instead of the online version.

Test version SQLines 3.1.113 - Windows 32-bit, 5.3 MB, July 02, 2018 (^^ is there a newer build for windows?)

Online converter works without issue without creating correct output.

Input

WITH George AS (SELECT B.*
FROM TABLE1 B
    INNER JOIN TABLE2 T2 ON
        1=1
        AND T2.AGENCY = B.AGENCY
        AND T2.REC_GROUP = B.REC_GROUP
        AND T2.REC_TYPE = B.REC_TYPE
        AND T2.REC_SUB_TYPE = B.REC_SUB_TYPE
        AND T2.REC_CATEGORY = B.REC_CATEGORY
        AND T2.REC_GROUP IN ('1','2','3','4')
        AND T2.REC_TYPE IN ('1','2','3','4')
        AND
        (
            (
                T2.REC_GROUP       ||
                '/'                  ||
                    T2.REC_TYPE    ||
                '/'                  ||
                    T2.REC_SUB_TYPE||
                '/'                  ||
                    T2.REC_CATEGORY IN ( '1','2','3','4' )
            )
            OR
            (
                T2.REC_GROUP||
                '/'           ||
                    T2.REC_TYPE = 'GEORGE'
            )
        )
WHERE
    1=1
    AND B.AGENCY = (SELECT AGENCY FROM PARAMS)
    AND UPPER(B.B1_ALT_ID) = (SELECT capid FROM PARAMS)
)
SELECT * FROM GEORGE

Output:

WITH George AS (SELECT B.*
FROM TABLE1 B
    INNER JOIN TABLE2 T2 ON
        1=1
        AND T2.AGENCY = B.AGENCY
        AND T2.REC_GROUP = B.REC_GROUP
        AND T2.REC_TYPE = B.REC_TYPE
        AND T2.REC_SUB_TYPE = B.REC_SUB_TYPE
        AND T2.REC_CATEGORY = B.REC_CATEGORY
        AND T2.REC_GROUP dbo.IN ('1','2','3','4')
        AND T2.REC_TYPE dbo.IN ('1','2','3','4')
        AND
        (
            (
                ISNULL(T2.REC_GROUP, '')       +
                '/'                  +
                    ISNULL(T2.REC_TYPE, '')    +
                '/'                  +
                    ISNULL(T2.REC_SUB_TYPE, '')+
                '/'                  +
                    ISNULL(T2.REC_CATEGORY, '') dbo.IN ( '1','2','3','4' )
            )
            OR
            (
                ISNULL(T2.REC_GROUP, '')+
                '/'           +
                    ISNULL(T2.REC_TYPE, '') = 'GEORGE'
            )
        )
WHERE
    1=1
    AND B.AGENCY = (SELECT AGENCY FROM PARAMS)
    AND UPPER(B.B1_ALT_ID) = (SELECT capid FROM PARAMS)
)
SELECT * FROM GEORGE
kfordaccela commented 5 years ago

Unable to compile newer version since the build script is broken.