The SQL statement is as follows:
Select sequence_name from user_sequences where sequence_name = 'parameter'
Note that the Oracle sequence parameter must be converted to uppercase/lowercase.
Example: (this is implemented using the simple framework)
// Determine whether the oracle sequence already exists
Public static boolean isSequenceExists (final DataSource dataSource, final String sequencename)
Throws SQLException {
Final JdbcTemplate jt = new JdbcTemplate (dataSource );
Return jt.exe cute (new ConnectionCallback <Boolean> (){
@ Override
Public Boolean doInConnection (final Connection con) throws SQLException {
String SQL = "select sequence_name from user_sequences where sequence_name = '" + sequencename. toUpperCase () + "'";
ResultSet rs = con.preparestatement(sqlcmd.exe cuteQuery ();
If (rs. next ()){
Return true;
} Else {
Return false;
}
}
});
}