1 package net.sourceforge.phpdt.sql.adapters;
3 import net.sourceforge.phpdt.sql.Messages;
4 import net.sourceforge.phpdt.sql.sql.SQLHelper;
8 public class OracleAdapter extends DatabaseAdapter {
9 public String getShowTableQuery(DatabaseInfo info) {
10 return "SELECT TABLE_NAME FROM USER_TABLES"; //$NON-NLS-1$
12 public String getShowViewQuery(DatabaseInfo info) {
13 return "SELECT VIEW_NAME FROM USER_VIEWS"; //$NON-NLS-1$
15 public String getShowSequenceQuery(DatabaseInfo info) {
16 return "SELECT SEQUENCE_NAME FROM USER_SEQUENCES"; //$NON-NLS-1$
18 public String getNextValue(String sequence) {
19 return "SELECT LAST_NUMBER FROM USER_SEQUENCES WHERE SEQUENCE_NAME = '" + sequence + "'"; //$NON-NLS-1$ //$NON-NLS-2$
22 * Quotes a string according to the type of the column
23 * @param string to be quoted
24 * @param type according to java.sql.Types
27 public String quote(String string, int type) {
28 if (SQLHelper.isText(type)) {
29 if (string.indexOf('\'') >= 0)
30 return '"' + string + '"';
32 return "'" + string + "'"; //$NON-NLS-1$ //$NON-NLS-2$
34 } else if (type == java.sql.Types.DATE || type == java.sql.Types.TIMESTAMP) {
35 string = string.trim();
36 String sub = string.substring(string.length()-2, string.length()-1);
37 if (string.length() > 1 && sub.equals(Messages.getString("OracleAdapter.._3"))) //$NON-NLS-1$
38 string = string.substring(0,string.length()-2);
39 return "TO_DATE('" + string + "','yyyy-mm-dd hh24:mi:ss')"; //$NON-NLS-1$ //$NON-NLS-2$