Project

General

Profile

« Previous | Next » 

Revision 2728

Added by sgarg about 19 years ago

New function which returns the formatted left join query. This is required as Oracle and postgres have different left join syntax

View differences:

src/edu/ucsb/nceas/dbadapter/PostgresqlAdapter.java
101 101
  }
102 102
  
103 103
  /**
104
   * PostgreSQL's syntax for doing a left join
105
   * Add 'a.' in front of the fields for first table and
106
   * 'b.' in front of the fields for the second table
107
   * 
108
   * @param selectFields fields that you want to be selected
109
   * @param tableA first table in the join
110
   * @param tableB second table in the join
111
   * @param joinCriteria the criteria based on which the join will be made
112
   * @param nonJoinCriteria all other criterias
113
   * @return return the string for teh select query
114
   */
115
  public String getLeftJoinQuery(String selectFields, String tableA, 
116
		  String tableB, String joinCriteria, String nonJoinCriteria){
117

  
118
	  return "SELECT " + selectFields + " FROM " + tableA + " a LEFT JOIN " 
119
	         + tableB + " b ON " + joinCriteria + " WHERE (" 
120
	         + nonJoinCriteria +")";
121
  }
122

  
123
  /**
104 124
   * Return a hard code string to get xml_document list in timed replcation
105 125
   */
106 126
  public String getReplicationDocumentListSQL()
src/edu/ucsb/nceas/dbadapter/OracleAdapter.java
98 98

  
99 99
    return "'";
100 100
  }
101

  
102
  /**
103
   * The Oracles's syntax for doing a left join
104
   * Add 'a.' in front of the fields for first table and
105
   * 'b.' in front of the fields for the second table
106
   * 
107
   * @param selectFields fields that you want to be selected
108
   * @param tableA first table in the join
109
   * @param tableB second table in the join
110
   * @param joinCriteria the criteria based on which the join will be made
111
   * @param nonJoinCriteria all other criterias
112
   * @return return the string for teh select query
113
   */
114
  public String getLeftJoinQuery(String selectFields, String tableA, 
115
		  String tableB, String joinCriteria, String nonJoinCriteria){
116

  
117
	  return "SELECT " + selectFields + " FROM " + tableA + " a, " 
118
	         + tableB + " b WHERE " + joinCriteria + "(+) " + " AND (" 
119
	         + nonJoinCriteria +")";
120
  }
101 121
  
102 122
  
103 123
  /**
src/edu/ucsb/nceas/dbadapter/SqlserverAdapter.java
107 107
  }
108 108
  
109 109
  /**
110
   * MSSQL's syntax for doing a left join
111
   * Add 'a.' in front of the fields for first table and
112
   * 'b.' in front of the fields for the second table
113
   * 
114
   * @param selectFields fields that you want to be selected
115
   * @param tableA first table in the join
116
   * @param tableB second table in the join
117
   * @param joinCriteria the criteria based on which the join will be made
118
   * @param nonJoinCriteria all other criterias
119
   * @return return the string for teh select query
120
   */
121
  public String getLeftJoinQuery(String selectFields, String tableA, 
122
		  String tableB, String joinCriteria, String nonJoinCriteria){
123

  
124
	  return "SELECT " + selectFields + " FROM " + tableA + " a LEFT JOIN " 
125
	         + tableB + " b ON " + joinCriteria + " WHERE (" 
126
	         + nonJoinCriteria +")";
127
  }
128

  
129
/**
110 130
   * Return a hard code string to get xml_document list in timed replcation
111 131
   */
112 132
  public String getReplicationDocumentListSQL()
......
114 134
      String sql ="select a.docid, a.rev, a.doctype from ( xml_documents a left outer join  xml_revisions b on (a.docid=b.docid and  a.rev<=b.rev)) where b.docid is null ";
115 135
      return sql;
116 136
  }
117
  
118 137
}
119 138
    
src/edu/ucsb/nceas/dbadapter/AbstractDatabase.java
94 94
  
95 95
  
96 96
  /**
97
   * Syntax for doing a left join
98
   * Add 'a.' in front of the fields for first table and
99
   * 'b.' in front of the fields for the second table
100
   * 
101
   * @param selectFields fields that you want to be selected
102
   * @param tableA first table in the join
103
   * @param tableB second table in the join
104
   * @param joinCriteria the criteria based on which the join will be made
105
   * @param nonJoinCriteria all other criterias
106
   * @return return the string for teh select query
107
   */
108
  public abstract String getLeftJoinQuery(String selectFields, String tableA, 
109
		  String tableB, String joinCriteria, String nonJoinCriteria);
110
  
111
  /**
97 112
   * Instantiate a class using the name of the class at runtime
98 113
   *
99 114
   * @param className the fully qualified name of the class to instantiate

Also available in: Unified diff