public class MysqlTriggerSourceTab extends FormattedSourceTab { /** SQL that retrieves the source of a view. */ private static String SQL = "SELECT ACTION_STATEMENT " + "FROM INFORMATION_SCHEMA.TRIGGERS " + "WHERE TRIGGER_SCHEMA = ? " + "AND TRIGGER_NAME = ? "; /** Logger for this class. */ private final static ILogger s_log = LoggerController.createLogger(MysqlTriggerSourceTab.class); public MysqlTriggerSourceTab(String hint, String stmtSep) { super(hint); super.setupFormatter(stmtSep, null); super.setCompressWhitespace(true); } protected PreparedStatement createStatement() throws SQLException { final ISession session = getSession(); final IDatabaseObjectInfo doi = getDatabaseObjectInfo(); ISQLConnection conn = session.getSQLConnection(); if (s_log.isDebugEnabled()) { s_log.debug("Running SQL for View source tab: "+SQL); s_log.debug("Binding catalog name "+doi.getCatalogName()+ " as first bind value"); s_log.debug("Binding table name "+doi.getSimpleName()+ " as second bind value"); } PreparedStatement pstmt = conn.prepareStatement(SQL); pstmt.setString(1, doi.getCatalogName()); pstmt.setString(2, doi.getSimpleName()); return pstmt
public class TriggerSourceTab extends FormattedSourceTab { /** Logger for this class. */ private final static ILogger s_log = LoggerController.createLogger(TriggerSourceTab.class); /** SQL that retrieves the source of a stored procedure. */ private static String SQL = "SELECT trigger_defs.text " + "FROM sysobjects tables , sysobjects triggers, syscomments trigger_defs " + "where triggers.type = 'TR' " + "and triggers.id = trigger_defs.id " + "and triggers.deltrig = tables.id " + "and tables.loginame = ? " + // TODO: figure out how to get then name of the table that the trigger // is on. //"and tables.name = ? " + "and triggers.name = ? "; public TriggerSourceTab(String hint, String stmtSep) { super(hint); super.setCompressWhitespace(true); super.setupFormatter(stmtSep, null); } protected PreparedStatement createStatement() throws SQLException { final ISession session = getSession(); final IDatabaseObjectInfo doi = getDatabaseObjectInfo(); if (s_log.isDebugEnabled()) { s_log.debug("Running SQL for View source tab: "+SQL); s_log.debug("Binding for param 1: "+doi.getCatalogName()); s_log.debug("Binding for param 2: "+doi.getSimpleName()); } ISQLConnection conn = session.getSQLConnection(); PreparedStatement pstmt = conn.prepareStatement(SQL); pstmt.setString(1, doi.getCatalogName()); pstmt.setString(2, doi.getSimpleName()); return pstmt
Clone fragments detected by clone detection tool
File path: /sql12/plugins/mysql/src/net/sourceforge/squirrel_sql/plugins/mysql/tab/MysqlTriggerSourceTab.java File path: /sql12/plugins/sybase/src/net/sourceforge/squirrel_sql/plugins/SybaseASE/tab/TriggerSourceTab.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class MysqlTriggerSourceTab extends FormattedSourceTab
1
public class TriggerSourceTab extends FormattedSourceTab
2
{
2
{
3
    /** Logger for this class. */
4
    private final static ILogger s_log =
5
        LoggerController.createLogger(TriggerSourceTab.class);
6
                
3
	/** SQL that retrieves the source of a view. */
7
	/** SQL that retrieves the source of a stored procedure. */
4
	private static String SQL =
8
	private static String SQL =
5
        "SELECT ACTION_STATEMENT " +
9
        "SELECT trigger_defs.text " +
6
        "FROM INFORMATION_SCHEMA.TRIGGERS " +
10
        "FROM 
7
        "WHERE TRIGGER_SCHEMA = ? " +
8
        "AND TRIGGER_NAME
11
sysobjects tables , sysobjects triggers, syscomments trigger_defs " +
12
        "where triggers.type = 'TR' " +
13
        "and triggers.id = trigger_defs.id " +
14
        "and triggers.deltrig = tables.id " +
9
 = ? ";
15
        "and tables.loginame = ? " +
10
    
16
    
11
	/** Logger for this class. */
12
	private final static ILogger s_log =
13
		LoggerController.createLogger(MysqlTriggerSourceTab.class);
17
    // TODO: figure out how to get then name of the table that the trigger 
18
        //       is on. 
19
        //"and tables.name = ? " +
20
        "and triggers.name = ? ";
21
        
14
	public MysqlTriggerSourceTab(String hint, String stmtSep)
22
	public TriggerSourceTab(String hint, String stmtSep)
15
	{
23
	{
16
		super(hint);
24
		super(hint);
17
        super.setupFormatter(stmtSep, null);
25
        super.set
18
        super.setCompressWhitespace(true
26
CompressWhitespace(true);
19
);
27
        super.setupFormatter(stmtSep, null);
20
	}
28
	}
21
	protected PreparedStatement createStatement() throws SQLException
29
	protected PreparedStatement createStatement() throws SQLException
22
	{
30
	{
23
		final ISession session = getSession();
31
		final ISession session = getSession();
24
		final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
32
		final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
25
		ISQLConnection conn = session.getSQLConnection();
26
        if (s_log.isDebugEnabled()) {
33
        if (s_log.isDebugEnabled()) {
27
            s_log.debug("Running SQL for View source tab: "+SQL);
34
            s_log.debug("Running SQL for View source tab: "+SQL);
28
            s_log.debug("Binding catalog name "+doi.getCatalogName()+
35
            s_log.debug("Binding for param 1: "+doi.getCatalogName()
29
                        " as first bind value");
36
);
30
            s_log.debug("Binding table name "+doi.getSimpleName()+
37
            s_log.debug("Binding for param 2: "+doi.getSimpleName());
31
        
38
        }
32
                " as second bind value");                        
39
        
33
        }
40
		ISQLConnection conn = session.getSQLConnection();
34
		PreparedStatement pstmt = conn.prepareStatement(SQL);
41
		PreparedStatement pstmt = conn.prepareStatement(SQL);
35
        
36
        pstmt.setString(1, doi.getCatalogName());
42
		pstmt.setString(1, doi.getCatalogName());
37
		pstmt.setString(2, doi.getSimpleName());
43
		pstmt.setString(2, doi.getSimpleName());
38
		return pstmt
44
		return pstmt
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0