protected boolean doesTriggerExistOnPlatform(String catalogName, String schema, String tableName, String triggerName) { return platform.getSqlTemplate().queryForInt( "select count(*) from sqlite_master where type='trigger' and name=? and tbl_name=?", triggerName, tableName) > 0; }
public boolean isUnsentDataOnChannelForNode(String channelId, String nodeId) { int unsentCount = sqlTemplate.queryForInt(getSql("unsentBatchesForNodeIdChannelIdSql"), new Object[] { nodeId, channelId }); if (unsentCount > 0) { return true; } // Do we need to check for unbatched data? return false; }
protected boolean isTriggerNameInUse(String triggerId, String triggerName) { return sqlTemplate.queryForInt(getSql("selectTriggerNameInUseSql"), triggerName, triggerName, triggerName, triggerId) > 0; }
private boolean isColumnInteger(String tableName, String columnName) { return (platform.getSqlTemplate().queryForInt( "select case when data_precision is null and data_scale=0 then 1 else 0 end " + "from all_tab_columns where table_name=? and column_name=?", tableName, columnName) == 1); }
public boolean isChannelInUse(String channelId) { return sqlTemplate.queryForInt(getSql("isChannelInUseSql"), channelId) > 0; }
public boolean isExternalIdRegistered(String nodeGroupId, String externalId) { return sqlTemplate.queryForInt(getSql("isNodeRegisteredSql"), new Object[] { nodeGroupId, externalId }) > 0; }
public int countDataInRange(long firstDataId, long secondDataId) { return sqlTemplate.queryForInt(getSql("countDataInRangeSql"), firstDataId, secondDataId); }
public int countOutgoingBatchesUnsent() { return sqlTemplate.queryForInt(getSql("countOutgoingBatchesUnsentSql")); }
public boolean isTriggerBeingUsed(String triggerId) { return sqlTemplate.queryForInt(getSql("countTriggerRoutersByTriggerIdSql"), triggerId) > 0; }
public int countOutgoingBatchesInError(String channelId) { return sqlTemplate.queryForInt(getSql("countOutgoingBatchesErrorsOnChannelSql"), channelId); }
public int countIncomingBatchesInError() { return sqlTemplate.queryForInt(getSql("countIncomingBatchesErrorsSql")); }
public int countIncomingBatchesInError(String channelId) { return sqlTemplate.queryForInt(getSql("countIncomingBatchesErrorsOnChannelSql"), channelId); }
public boolean doesTriggerExistForTable(String tableName) { return sqlTemplate.queryForInt(getSql("countTriggerByTableNameSql"), tableName) > 0; }
public boolean isRouterBeingUsed(String routerId) { return sqlTemplate.queryForInt(getSql("countTriggerRoutersByRouterIdSql"), routerId) > 0; }
public int countOutgoingBatchesInError() { return sqlTemplate.queryForInt(getSql("countOutgoingBatchesErrorsSql")); }
public int countOutgoingBatchesUnsent(String channelId) { return sqlTemplate.queryForInt(getSql("countOutgoingBatchesUnsentOnChannelSql"), channelId); }
public int countOutgoingBatches(List<String> nodeIds, List<String> channels, List<OutgoingBatch.Status> statuses) { Map<String, Object> params = new HashMap<String, Object>(); params.put("NODES", nodeIds); params.put("CHANNELS", channels); params.put("STATUSES", toStringList(statuses)); return sqlTemplate .queryForInt( getSql("selectCountBatchesPrefixSql", buildBatchWhere(nodeIds, channels, statuses)), params); }
protected boolean installed(String sql, String objectName) { return platform.getSqlTemplate().queryForInt(replaceTokens(sql, objectName)) > 0; }
public void insertNodeGroup(String groupId, String description) { if (sqlTemplate.queryForInt(getSql("doesNodeGroupExistSql"), groupId) == 0) { sqlTemplate.update(getSql("insertNodeGroupSql"), description, groupId); } }
protected void buildBulkDataType(int typeCode) { String typeName = getTypeName(typeCode); if (platform.getSqlTemplate().queryForInt( "select count(*) from user_types where type_name=?", typeName) == 0) { final String DDL = "create or replace type %s is table of %s"; platform.getSqlTemplate().update( String.format(DDL, getTypeName(typeCode), getMappedType(typeCode))); } }