private String buildDeleteSQL() { StringBuffer resultSQL = new StringBuffer(); if (chkComment.getSelection()) resultSQL.append("/* Tadpole SQL Generator */"); // $NON-NLS-1$ int cnt = 0; resultSQL.append("DELETE FROM " + tableDAO.getSysName()); // $NON-NLS-1$ for (ExtendTableColumnDAO allDao : (List<ExtendTableColumnDAO>) tableViewer.getInput()) { if ("PK".equals(allDao.getKey())) { // $NON-NLS-1$ if (cnt == 0) resultSQL.append(" WHERE "); // $NON-NLS-1$ else resultSQL.append("\t AND "); // $NON-NLS-1$ resultSQL.append(allDao.getSysName()).append(" = ? "); // $NON-NLS-1$ if (chkComment.getSelection()) { resultSQL.append("/* " + allDao.getType() + " */"); // $NON-NLS-1$ //$NON-NLS-2$ } cnt++; } } return lastSQLGen(resultSQL.toString()); }
/** * Generate INSERT statement * * @return */ private String buildInsertSQL() { StringBuffer resultSQL = new StringBuffer(); if (chkComment.getSelection()) resultSQL.append("/* Tadpole SQL Generator */"); // $NON-NLS-1$ int cnt = 0; resultSQL.append("INSERT INTO " + tableDAO.getSysName() + " ( "); // $NON-NLS-1$ //$NON-NLS-2$ ExtendTableColumnDAO firstDao = (ExtendTableColumnDAO) tableViewer.getElementAt(0); if (firstDao.isCheck()) { for (ExtendTableColumnDAO allDao : (List<ExtendTableColumnDAO>) tableViewer.getInput()) { if ("*".equals(allDao.getField())) continue; // $NON-NLS-1$ if (cnt > 0) resultSQL.append(", "); // $NON-NLS-1$ resultSQL.append(allDao.getSysName()); cnt++; } } else { for (ExtendTableColumnDAO allDao : (List<ExtendTableColumnDAO>) tableViewer.getInput()) { if (allDao.isCheck()) { if (cnt > 0) resultSQL.append(", "); // $NON-NLS-1$ resultSQL.append(allDao.getSysName()); cnt++; } } } resultSQL.append( ")" + PublicTadpoleDefine.LINE_SEPARATOR + " VALUES ( "); // $NON-NLS-1$ //$NON-NLS-2$ cnt = 0; if (firstDao.isCheck()) { for (ExtendTableColumnDAO allDao : (List<ExtendTableColumnDAO>) tableViewer.getInput()) { if ("*".equals(allDao.getSysName())) continue; // $NON-NLS-1$ if (cnt > 0) resultSQL.append(", "); // $NON-NLS-1$ resultSQL.append("?"); // $NON-NLS-1$ if (chkComment.getSelection()) { resultSQL.append( "/* " + allDao.getField() + ":" + allDao.getType() + " */"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } cnt++; } } else { for (ExtendTableColumnDAO allDao : (List<ExtendTableColumnDAO>) tableViewer.getInput()) { if (allDao.isCheck()) { if (cnt > 0) resultSQL.append(", "); // $NON-NLS-1$ resultSQL.append("?"); // $NON-NLS-1$ if (chkComment.getSelection()) { resultSQL.append( "/* " + allDao.getField() + ":" + allDao.getType() + " */"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } cnt++; } } } resultSQL.append(")"); // $NON-NLS-1$ return lastSQLGen(resultSQL.toString()); }