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