Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findTablePkeys - wrong query #17

Open
ostrha1 opened this issue Oct 1, 2015 · 1 comment
Open

findTablePkeys - wrong query #17

ostrha1 opened this issue Oct 1, 2015 · 1 comment

Comments

@ostrha1
Copy link

ostrha1 commented Oct 1, 2015

public List<Db2LookInfo> findTablePkeys(UserObject userObject) {
    List<Db2LookInfo> list = getJdbcTemplate().query(
            "SELECT * " +
                    " FROM SYSTOOLS.DB2LOOK_INFO t " +
                    " WHERE OBJ_TYPE = 'PKEY' AND OP_TOKEN = ?  AND t.OBJ_SCHEMA = ? AND OBJ_NAME = ?" +
                    "      AND exists( " +
                    "    SELECT 1 " +
                    "    FROM SYSCAT.REFERENCES R " +
                    "    WHERE R.TABSCHEMA = t.OBJ_SCHEMA " +
                    "          AND R.TABNAME = t.OBJ_NAME)",
            new Object[]{userObject.getOpToken(), schemaName, userObject.getName()},

            new Db2LookInfoRowMapper());


    return list;
}
@ostrha1
Copy link
Author

ostrha1 commented Oct 2, 2015

Index: src/main/java/com/googlecode/scheme2ddl/db2/dao/UserObjectDaoDb2Impl.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/java/com/googlecode/scheme2ddl/db2/dao/UserObjectDaoDb2Impl.java   (date 1443768413000)
+++ src/main/java/com/googlecode/scheme2ddl/db2/dao/UserObjectDaoDb2Impl.java   (revision )
@@ -199,12 +199,7 @@
         List<Db2LookInfo> list = getJdbcTemplate().query(
                 "SELECT * " +
                         " FROM SYSTOOLS.DB2LOOK_INFO t " +
-                        " WHERE OBJ_TYPE = 'PKEY' AND OP_TOKEN = ?  AND t.OBJ_SCHEMA = ? AND OBJ_NAME = ?" +
-                        "      AND exists( " +
-                        "    SELECT 1 " +
-                        "    FROM SYSCAT.REFERENCES R " +
-                        "    WHERE R.TABSCHEMA = t.OBJ_SCHEMA " +
-                        "          AND R.TABNAME = t.OBJ_NAME)",
+                        " WHERE OBJ_TYPE = 'PKEY' AND OP_TOKEN = ?  AND t.OBJ_SCHEMA = ? AND OBJ_NAME = ?" ,
                 new Object[]{userObject.getOpToken(), schemaName, userObject.getName()},

                 new Db2LookInfoRowMapper());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant