Fixed: couldn't launch linked files nor launch files under a linked folder when local...
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / adapters / OracleAdapter.java
index 78d2cce..9ecaa16 100644 (file)
@@ -1,5 +1,8 @@
 package com.quantum.adapters;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import com.quantum.Messages;
 import com.quantum.util.QuantumUtil;
 
@@ -13,7 +16,7 @@ public class OracleAdapter extends DatabaseAdapter {
         return "SELECT SEQUENCE_OWNER, SEQUENCE_NAME FROM ALL_SEQUENCES WHERE SEQUENCE_OWNER = '" + qualifier + "'"; //$NON-NLS-1$
        }
        public String getPrevValue(String sequence, String owner) {
-       return "SELECT LAST_NUMBER FROM ALL_SEQUENCES WHERE SEQUENCE_OWNER = '" + owner + "' AND SEQUENCE_NAME = '" + sequence + "'"; //$NON-NLS-1$ //$NON-NLS-2$
+       return "SELECT " + getQualifiedName(owner, sequence) + ".CURRVAL FROM DUAL";
        }
        public String getNextValue(String sequence, String owner) {
                return "SELECT " + getQualifiedName(owner, sequence) + ".NEXTVAL FROM DUAL";
@@ -34,9 +37,13 @@ public class OracleAdapter extends DatabaseAdapter {
        public String quote(String string, int type, String typeString) {
                if (type == java.sql.Types.DATE || type == java.sql.Types.TIMESTAMP) {
                        string = string.trim();
-                       String sub = string.substring(string.length()-2, string.length()-1);
-                       if (string.length() > 1 &&  sub.equals(Messages.getString("OracleAdapter.._3"))) //$NON-NLS-1$
-                               string = string.substring(0,string.length()-2);
+                       // Eliminate the fractions of seconds, if present
+                       if (string.length() > 1) {
+                               // If the third character from the end is a dot, it means it has fractions
+                               String sub = string.substring(string.length()-2, string.length()-1);
+                               if ( sub.equals(Messages.getString("."))) //$NON-NLS-1$
+                                       string = string.substring(0,string.length()-2);
+                       }
                        return "TO_DATE('" + string + "','yyyy-mm-dd hh24:mi:ss')"; //$NON-NLS-1$ //$NON-NLS-2$
                }
                // use the default (upper type)
@@ -64,6 +71,24 @@ public class OracleAdapter extends DatabaseAdapter {
     public String getDefaultSchema(String userid) {
         return super.getDefaultSchema(userid).toUpperCase();
     }
-  
+    
+    public Map getDefaultConnectionParameters() {
+       Map map = new HashMap();
+       map.put("port", "1521");
+       map.put("hostname", "localhost");
+       return map;
+    }
+    
 
+       /* (non-Javadoc)
+        * @see com.quantum.adapters.DatabaseAdapter#getShowSynonymsQuery(java.lang.String, java.lang.String)
+        */
+       public String getShowSynonymsQuery(String schema, String type) {
+               // The type string is the same as the one needed by Oracle. If it changes a switch would be needed.
+               return "select SYNONYM_NAME from ALL_SYNONYMS, ALL_OBJECTS where " +
+                               " ALL_SYNONYMS.OWNER = '" + schema + "'" +
+                               " and ALL_SYNONYMS.TABLE_OWNER = ALL_OBJECTS.OWNER" +
+                               " and ALL_SYNONYMS.TABLE_NAME = ALL_OBJECTS.OBJECT_NAME" + 
+                               " and ALL_OBJECTS.OBJECT_TYPE = '" + type + "'" ;
+               }
 }
\ No newline at end of file