Fixed #1721079 - Can not set breakpoint in different files on the same line
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.sql / src / net / sourceforge / phpdt / sql / adapters / OracleAdapter.java
1 package net.sourceforge.phpdt.sql.adapters;
2
3 import net.sourceforge.phpdt.sql.Messages;
4 import net.sourceforge.phpdt.sql.sql.SQLHelper;
5
6
7
8 public class OracleAdapter extends DatabaseAdapter {
9         public String getShowTableQuery(DatabaseInfo info) {
10                                 return "SELECT TABLE_NAME FROM USER_TABLES"; //$NON-NLS-1$
11         }
12         public String getShowViewQuery(DatabaseInfo info) {
13                 return "SELECT VIEW_NAME FROM USER_VIEWS"; //$NON-NLS-1$
14         }
15         public String getShowSequenceQuery(DatabaseInfo info) {
16                 return "SELECT SEQUENCE_NAME FROM USER_SEQUENCES"; //$NON-NLS-1$
17         }
18         public String getNextValue(String sequence) {
19                 return "SELECT LAST_NUMBER FROM USER_SEQUENCES WHERE SEQUENCE_NAME = '" + sequence + "'"; //$NON-NLS-1$ //$NON-NLS-2$
20         }
21         /**
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
25          * @return
26          */
27         public String quote(String string, int type) {
28                 if (SQLHelper.isText(type)) {
29                         if (string.indexOf('\'') >= 0)
30                                 return '"' + string + '"';
31                         else
32                                 return "'" + string + "'"; //$NON-NLS-1$ //$NON-NLS-2$
33
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$
40                 }
41                 return string;
42         }
43 }