Index: trunk/zoo-project/zoo-services/ogr/ogr2ogr/service.c
===================================================================
--- trunk/zoo-project/zoo-services/ogr/ogr2ogr/service.c	(revision 790)
+++ trunk/zoo-project/zoo-services/ogr/ogr2ogr/service.c	(revision 917)
@@ -96,4 +96,5 @@
 #endif
 {
+    char  *pszDialect = NULL;
     const char  *pszFormat = "ESRI Shapefile";
     const char  *pszDataSource = NULL;
@@ -155,5 +156,5 @@
       sprintf(serverAddress,"%s",tmpMap->value);
     }
-    
+
     tmpMap=NULL;
     char tmpurl[1024];
@@ -223,4 +224,9 @@
     if(tmpMap!=NULL && strncasecmp(tmpMap->value,"NULL",4)!=0){
       pszSQLStatement = tmpMap->value;
+    }
+
+    tmpMap=getMapFromMaps(inputs,"dialect","value");
+    if(tmpMap!=NULL){
+      pszDialect=strdup(tmpMap->value);
     }
 
@@ -360,11 +366,5 @@
 	  dfMaxSegmentLength = atof(tmpMap->value);
     }
-
-    /*tmpMap=NULL;
-    tmpMap=getMapFromMaps(inputs,"segmentize","value");
-    if(tmpMap!=NULL){
-	  dfMaxSegmentLength = atof(tmpMap->value);
-    }*/
-
+   
     tmpMap=NULL;
     tmpMap=getMapFromMaps(inputs,"InputDSN","value");
@@ -825,5 +825,5 @@
         
         poResultSet = poDS->ExecuteSQL( pszSQLStatement, poSpatialFilter, 
-                                        NULL );
+                                        pszDialect );
 
         if( poResultSet != NULL )
@@ -841,6 +841,13 @@
             }
             poDS->ReleaseResultSet( poResultSet );
-        }
-    }
+        }else{
+	  setMapInMaps(conf,"lenv","message","There was an error when running yoru SQL query.");
+	  if(pszDialect!=NULL)
+	    free(pszDialect);
+	  return SERVICE_FAILED;
+	}
+    }
+    if(pszDialect!=NULL)
+      free(pszDialect);
 
 /* -------------------------------------------------------------------- */
@@ -901,5 +908,6 @@
 
 #ifdef ZOO_SERVICE
-    outputs->content=createMap("value",(char*)pszwebDestData);
+    setMapInMaps(outputs,"OutputedDataSourceName","value",(char*)pszwebDestData);
+    //outputs->content=createMap("value",(char*)pszwebDestData);
 #endif
 
@@ -930,5 +938,5 @@
     fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
 
-    OGRCleanupAll();
+    //OGRCleanupAll();
     fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
 
@@ -939,4 +947,5 @@
     
 #ifdef ZOO_SERVICE
+    //sleep(10);
     return SERVICE_SUCCEEDED;
 #else
