1 package com.quantum.adapters;
3 import com.quantum.Messages;
4 import com.quantum.util.QuantumUtil;
8 public class OracleAdapter extends DatabaseAdapter {
9 protected OracleAdapter() {
10 super(AdapterFactory.ORACLE);
12 public String getShowSequenceQuery(String qualifier) {
13 return "SELECT SEQUENCE_OWNER, SEQUENCE_NAME FROM ALL_SEQUENCES WHERE SEQUENCE_OWNER = '" + qualifier + "'"; //$NON-NLS-1$
15 public String getPrevValue(String sequence, String owner) {
16 return "SELECT LAST_NUMBER FROM ALL_SEQUENCES WHERE SEQUENCE_OWNER = '" + owner + "' AND SEQUENCE_NAME = '" + sequence + "'"; //$NON-NLS-1$ //$NON-NLS-2$
18 public String getNextValue(String sequence, String owner) {
19 return "SELECT " + getQualifiedName(owner, sequence) + ".NEXTVAL FROM DUAL";
21 public String getCommentsQuery(String tableName, String column) {
22 String query = "SELECT COMMENTS FROM ALL_COL_COMMENTS WHERE TABLE_NAME = '";
23 query += QuantumUtil.getTableName(tableName) + "' AND COLUMN_NAME = '" + column + "'" ;
24 if (!(QuantumUtil.getSchemaName(tableName).equals("")))
25 query += " AND OWNER = '" + QuantumUtil.getSchemaName(tableName) + "'";
29 * Quotes a string according to the type of the column
30 * @param string to be quoted
31 * @param type according to java.sql.Types
34 public String quote(String string, int type, String typeString) {
35 if (type == java.sql.Types.DATE || type == java.sql.Types.TIMESTAMP) {
36 string = string.trim();
37 String sub = string.substring(string.length()-2, string.length()-1);
38 if (string.length() > 1 && sub.equals(Messages.getString("OracleAdapter.._3"))) //$NON-NLS-1$
39 string = string.substring(0,string.length()-2);
40 return "TO_DATE('" + string + "','yyyy-mm-dd hh24:mi:ss')"; //$NON-NLS-1$ //$NON-NLS-2$
42 // use the default (upper type)
43 return super.quote(string, type, typeString);
47 * @see com.quantum.adapters.DatabaseAdapter#filterTableName(java.lang.String)
49 public String filterTableName(String tableName) {
50 // If there is no mixed case, better not quote, it's prettier on display
51 if (tableName.equals(tableName.toUpperCase())) return tableName;
52 // We quote the table name (and only the table name) because it has mixed case
53 if (QuantumUtil.getSchemaName(tableName).equals(""))
54 return "\"" + tableName +"\""; //$NON-NLS-1$
56 return QuantumUtil.getSchemaName(tableName) + ".\"" +
57 QuantumUtil.getTableName(tableName) + "\"";
61 * The default schema for Oracle is the upper-case userid.
62 * @see com.quantum.adapters.DatabaseAdapter#getDefaultSchema(java.lang.String)
64 public String getDefaultSchema(String userid) {
65 return super.getDefaultSchema(userid).toUpperCase();