public class ViewSourceTab extends BaseSourceTab { /** SQL that retrieves the source of a stored procedure. */ private static String SQL = "select v.VIEWDEFINITION " + "from sys.SYSVIEWS v, sys.SYSTABLES t, sys.SYSSCHEMAS s " + "where v.TABLEID = t.TABLEID " + "and s.SCHEMAID = t.SCHEMAID " + "and t.TABLENAME = ? " + "and s.SCHEMANAME = ? "; /** Logger for this class. */ private final static ILogger s_log = LoggerController.createLogger(ViewSourceTab.class); public ViewSourceTab(String hint) { super(hint); } 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 View Source SQL: "+SQL); s_log.debug("View Name="+doi.getSimpleName()); s_log.debug("Schema Name="+doi.getSchemaName()); } PreparedStatement pstmt = conn.prepareStatement(SQL); pstmt.setString(1, doi.getSimpleName()); // view name pstmt.setString(2, doi.getSchemaName()); // schema name return pstmt;
public class ProcedureSourceTab extends FormattedSourceTab { /** SQL that retrieves the source of a stored procedure. */ private static String SQL = "SELECT p.prosrc FROM pg_proc p, pg_namespace n " + "where p.pronamespace = n.oid " + "and n.nspname = ? " + "and p.proname = ? "; /** Logger for this class. */ private final static ILogger s_log = LoggerController.createLogger(ProcedureSourceTab.class); public ProcedureSourceTab(String hint) { super(hint); super.setCompressWhitespace(false); } protected PreparedStatement createStatement() throws SQLException { final ISession session = getSession(); final IDatabaseObjectInfo doi = getDatabaseObjectInfo(); if (s_log.isDebugEnabled()) { s_log.debug("Running SQL for procedure source: "+SQL); s_log.debug("schema="+doi.getSchemaName()); s_log.debug("procedure name="+doi.getSimpleName()); } ISQLConnection conn = session.getSQLConnection(); PreparedStatement pstmt = conn.prepareStatement(SQL); // Postgres pg_proc table doesn't appear to have schema. I couldn't // locate another table to join with to get this info either. pstmt.setString(1, doi.getSchemaName()); pstmt.setString(2, doi.getSimpleName()); return pstmt;
Clone fragments detected by clone detection tool
File path: /sql12/plugins/derby/src/net/sourceforge/squirrel_sql/plugins/derby/tab/ViewSourceTab.java File path: /sql12/plugins/postgres/src/net/sourceforge/squirrel_sql/plugins/postgres/tab/ProcedureSourceTab.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class ViewSourceTab extends BaseSourceTab
1
public class ProcedureSourceTab extends FormattedSourceTab
2
{
2
{
3
	/** SQL that retrieves the source of a stored procedure. */
3
	/** SQL that retrieves the source of a stored procedure. */
4
	private static String SQL =
4
	private static String SQL =
5
        "select v.VIEWDEFINITION " +
5
        "
6
        "from sys.SYSVIEWS v, sys.SYSTABLES t, sys.SYSSCHEMAS s " +
7
        "where v.TABLEID = t.TABLEID " +
8
        "and s.SCHEMAID = t.SCHEMAID
6
SELECT p.prosrc FROM pg_proc p, pg_namespace n " +
9
 " +
7
        "where p.pronamespace = n.oid " +
10
        "and t.TABLENAME = ? " +
8
        "and n.nspname = ? " +
11
        "and s.SCHEMANAME = ? ";
9
        "and p.proname = ? ";
12
    
10
    
13
	/** Logger for this class. */
11
	/** Logger for this class. */
14
	private final static ILogger s_log =
12
	private final static ILogger s_log =
15
		LoggerController.createLogger(ViewSourceTab.class);
13
		LoggerController.createLogger(ProcedureSourceTab.class);
16
	public ViewSourceTab(String hint)
14
	public ProcedureSourceTab(String hint)
17
	{
15
	{
18
		super(hint);
16
		super(hint);
19
	
17
		super.setCompressWhitespace(false);
20
}
18
	}
21
	protected PreparedStatement createStatement() throws SQLException
19
	protected PreparedStatement createStatement() throws SQLException
22
	{
20
	{
23
		final ISession session = getSession();
21
		final ISession session = getSession();
24
		final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
22
		final IDatabaseObjectInfo doi = getDatabaseObjectInfo();
25
		ISQLConnection conn = session.getSQLConnection();
26
        if (s_log.isDebugEnabled()) {
23
        if (s_log.isDebugEnabled()) {
27
            s_log.debug("Running View Source SQL: "+SQL);
24
            s_log.debug("Running SQL for procedure source: "+SQL);
28
            s_log.debug("View Name="+doi.getSimpleName());
25
            s_log.debug("schema="+doi.getSchemaName());
29
            s_log.debug("Schema Name="+doi.getSchemaName());
26
            s_log.debug("procedure name="+doi.getSimpleName());
30
        }
27
        }
31
        
28
        
32
		
29
		ISQLConnection conn = session.getSQLConnection();
33
PreparedStatement pstmt = conn.prepareStatement(SQL);
30
		PreparedStatement pstmt = conn.prepareStatement(SQL);
34
		pstmt.setString(1, doi.getSimpleName()); // view name
31
        // Postgres pg_proc table doesn't appear to have schema.  I couldn't
32
        // locate another table to join with to get this info either.
35
        pstmt.setString(2, doi.getSchemaName()); // schema name
33
        pstmt.setString(1, doi.getSchemaName());
34
		pstmt.setString(2, doi.getSimpleName());
36
		return pstmt;
35
		return pstmt;
37
	
36
	
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