[gnome-db] patch to fix sybase provider



Hey all,

Here's a patch to fix the sybase complilation problems. 

mike




Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/Makefile.am,v
retrieving revision 1.7
diff -u -u -r1.7 Makefile.am
--- Makefile.am	12 Mar 2003 17:27:16 -0000	1.7
+++ Makefile.am	28 Mar 2003 03:39:02 -0000
@@ -12,9 +12,9 @@
 	gda-sybase-provider.h \
 	gda-sybase-recordset.c \
 	gda-sybase-recordset.h \
-	gda-sybase-schemas.h \
 	gda-sybase-types.c \
 	gda-sybase-types.h \
+	gda-sybase-schemas.h \
 	gda-sybase.h \
 	libmain.c \
 	utils.c
Index: gda-sybase-provider.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/gda-sybase-provider.c,v
retrieving revision 1.16
diff -u -u -r1.16 gda-sybase-provider.c
--- gda-sybase-provider.c	3 Feb 2003 17:12:22 -0000	1.16
+++ gda-sybase-provider.c	28 Mar 2003 03:39:05 -0000
@@ -26,6 +26,7 @@
  */
 
 #if defined(HAVE_CONFIG_H)
+#  include <config.h>
 #endif
 #include <string.h>
 #include "gda-sybase.h"
@@ -40,12 +41,12 @@
 static void gda_sybase_provider_finalize (GObject *object);
 
 static gboolean gda_sybase_provider_open_connection (GdaServerProvider *provider,
-						     GdaConnection *cnc,
-						     GdaQuarkList *params,
-						     const gchar *username,
-						     const gchar *password);
+																										 GdaConnection *cnc,
+																										 GdaQuarkList *params,
+																										 const gchar *username,
+																										 const gchar *password);
 static gboolean gda_sybase_provider_close_connection (GdaServerProvider *provider,
-						      GdaConnection *cnc);
+																											GdaConnection *cnc);
 
 
 static gboolean gda_sybase_provider_begin_transaction (GdaServerProvider *provider,
@@ -74,7 +75,7 @@
                                                      GdaConnectionSchema schema,
                                                      GdaParameterList *params);
 static const gchar *gda_sybase_provider_get_server_version (GdaServerProvider *provider,
-                                        GdaConnection *cnc);
+																														GdaConnection *cnc);
 static const gchar *gda_sybase_provider_get_version (GdaServerProvider *provider);
 static gboolean gda_sybase_provider_rollback_transaction (GdaServerProvider *provider,
                                                           GdaConnection *cnc,
@@ -89,7 +90,6 @@
                                                const gchar *sql);
 static gboolean gda_sybase_execute_cmd (GdaConnection *cnc, const gchar *sql);
 
-
 static GObjectClass *parent_class = NULL;
 
 /*
@@ -126,7 +126,7 @@
 
 static void
 gda_sybase_provider_init (GdaSybaseProvider *myprv, 
-			  GdaSybaseProviderClass *klass)
+													GdaSybaseProviderClass *klass)
 {
 }
 
@@ -158,8 +158,8 @@
 			(GInstanceInitFunc) gda_sybase_provider_init
 		};
 		type = g_type_register_static (PARENT_TYPE,
-					       "GdaSybaseProvider",
-					       &info, 0);
+																	 "GdaSybaseProvider",
+																	 &info, 0);
 	}
 
 	return type;
@@ -172,6 +172,9 @@
 
 	provider = g_object_new (gda_sybase_provider_get_type (), NULL);
 
+
+	g_print("loading sybase provider!\n");
+
 	return GDA_SERVER_PROVIDER (provider);
 }
 
@@ -180,6 +183,16 @@
 {
 	GdaSybaseConnectionData *sconn = g_new0 (GdaSybaseConnectionData, 1);
 
+	if ( !sconn) 
+		return NULL;
+
+	sconn->server_version = NULL;
+	sconn->gda_cnc = NULL;
+	sconn->context = NULL;
+	sconn->cmd = NULL;
+	sconn->connection = NULL;
+	sconn->mempool = NULL;
+
 	return sconn;
 }
 
@@ -189,32 +202,31 @@
 gda_sybase_connection_data_free(GdaSybaseConnectionData *sconn)
 {
 	if (sconn) {
-		/* if a GdaConnection is associated with the data, */
-		/* clear the handle */
+		// if a GdaConnection is associated with the data,
+		// clear the handle
 		if (GDA_IS_CONNECTION (sconn->gda_cnc)) {
-			/* we do not check if the handle is the same,
-			 * because it must be identical (connection_open)
-			 */
+			// we do not check if the handle is the same,
+			// because it must be identical (connection_open)
 			g_object_set_data (G_OBJECT (sconn->gda_cnc), 
-			                   OBJECT_DATA_SYBASE_HANDLE, NULL);
-			/* is just a reference copy */
+												 OBJECT_DATA_SYBASE_HANDLE, NULL);
+			// is just a reference copy
 			sconn->gda_cnc = NULL;
 		}
 		if (sconn->server_version) {
 			g_free (sconn->server_version);
 			sconn->server_version = NULL;
 		}
-		/* drop command structure */
+		// drop command structure
 		if (sconn->cmd) {
 			sconn->ret = ct_cmd_drop (sconn->cmd);
 			sconn->cmd = NULL;
 		}
-		/* drop connection */
+		// drop connection
 		if (sconn->connection) {
 			sconn->ret = ct_con_drop (sconn->connection);
 			sconn->connection = NULL;
 		}
-		/* exit library and drop context */
+		// exit library and drop context
 		if (sconn->context) {
 			sconn->ret = ct_exit (sconn->context, CS_UNUSED);
 			sconn->ret = cs_ctx_drop (sconn->context);
@@ -229,10 +241,10 @@
 /* open_connection handler for the GdaSybaseProvider class */
 static gboolean
 gda_sybase_provider_open_connection (GdaServerProvider *provider,
-				     GdaConnection *cnc,
-				     GdaQuarkList *params,
-				     const gchar *username,
-				     const gchar *password)
+																		 GdaConnection *cnc,
+																		 GdaQuarkList *params,
+																		 const gchar *username,
+																		 const gchar *password)
 {
 		
 	GdaSybaseConnectionData *sconn = NULL;
@@ -248,12 +260,12 @@
 		
 	/* the logic to connect to the database */
 
-	sybase_debug_msg(_("about to open connection"));
+	//sybase_debug_msg(_("about to open connection"));
 	
 	if (username)
 		t_user = g_strdup(username);
 	else
-		t_user = gda_quark_list_find (params, "USER");
+		t_user = gda_quark_list_find (params, "USERNAME");
 
 		
 	if (password)
@@ -268,11 +280,13 @@
 
 	t_locale = gda_quark_list_find (params, "LOCALE");
 
-	sybase_debug_msg ("username: '%s', password '%s'",
-	                  (t_user != NULL) ? t_user : "(NULL)",
-	                  (t_password != NULL) ? "XXXXXXXX" : "(NULL)");
+	//sybase_debug_msg ("username: '%s', password '%s'",
+	//																	(t_user != NULL) ? t_user : "(NULL)",
+	//																		(t_password != NULL) ? "XXXXXXXX" : "(NULL)");
 	
-	sconn = g_new0 (GdaSybaseConnectionData, 1);
+	//		sconn = g_new0 (GdaSybaseConnectionData, 1);
+	sconn = gda_sybase_connection_data_new();
+
 	if (!sconn) {
 		sybase_debug_msg (_("Out of memory. Allocating connection structure failed."));
 		return FALSE;
@@ -286,14 +300,14 @@
 		sconn = NULL;
 		return FALSE;
 	}
-	sybase_debug_msg(_("Context allocated."));
+	//sybase_debug_msg(_("Context allocated."));
 	/* init client-lib */
 	sconn->ret = ct_init (sconn->context, CS_GDA_VERSION);
 	if (sconn->ret != CS_SUCCEED) {
 		gda_sybase_connection_data_free (sconn);
 		return FALSE;
 	}
-	sybase_debug_msg(_("Client library initialized."));
+	//sybase_debug_msg(_("Client library initialized."));
 
 	/* apply locale before connection */
 	if (t_locale) {
@@ -303,63 +317,63 @@
 		 * avoid nested if clauses because of same condition */
 		if (sconn->ret == CS_SUCCEED) {
 			sconn->ret = cs_locale (sconn->context,
-			                        CS_SET,
-			                        locale,
-			                        CS_LC_ALL,
-			                        (CS_CHAR *) t_locale,
-			                        CS_NULLTERM,
-			                        NULL);
+															CS_SET,
+															locale,
+															CS_LC_ALL,
+															(CS_CHAR *) t_locale,
+															CS_NULLTERM,
+															NULL);
 		}
 		if (sconn->ret == CS_SUCCEED) {
 			sconn->ret = cs_config (sconn->context,
-			                        CS_SET,
-			                        CS_LOC_PROP,
-			                        locale,
-			                        CS_UNUSED,
-			                        NULL);
+															CS_SET,
+															CS_LOC_PROP,
+															locale,
+															CS_UNUSED,
+															NULL);
 		}
 		if (sconn->ret == CS_SUCCEED) {
 			sybase_debug_msg (_("Locale set to '%s'."), t_locale);
 		}
 		if (locale) {
 			sconn->ret = cs_loc_drop (sconn->context,
-			                          locale);
+																locale);
 			locale = NULL;
 		}
 	}
 
 	/* Initialize callback handlers */
 	/*   cs */
-	sconn->ret = cs_config (sconn->context, CS_SET, CS_MESSAGE_CB,
-	                        (CS_VOID *) gda_sybase_csmsg_callback,
-	                         CS_UNUSED, NULL);
-	if (sconn->ret != CS_SUCCEED) {
-		sybase_debug_msg(_("Could not initialize cslib callback"));
-		gda_sybase_connection_data_free (sconn);
-		return FALSE;
-	}
-	sybase_debug_msg(_("CS-lib callback initialized."));
+	/*  	sconn->ret = cs_config (sconn->context, CS_SET, CS_MESSAGE_CB, */
+	/*  																									(CS_VOID *) gda_sybase_csmsg_callback, */
+	/*  																									CS_UNUSED, NULL); */
+	/*  	if (sconn->ret != CS_SUCCEED) { */
+	/*  		sybase_debug_msg(_("Could not initialize cslib callback")); */
+	/*  		gda_sybase_connection_data_free (sconn); */
+	/*  		return FALSE; */
+	/*  	} */
+	/*  	sybase_debug_msg(_("CS-lib callback initialized.")); */
 	/*   ct-cli */
-	sconn->ret = ct_callback (sconn->context, NULL, CS_SET,
-	                          CS_CLIENTMSG_CB,
-	                          (CS_VOID *) gda_sybase_clientmsg_callback);
-	if (sconn->ret != CS_SUCCEED) {
-		sybase_debug_msg(_("Could not initialize ct-client callback"));
-		gda_sybase_connection_data_free (sconn);
-		return FALSE;
-	}
-	sybase_debug_msg(_("CT-Client callback initialized."));
+	/*  	sconn->ret = ct_callback (sconn->context, NULL, CS_SET, */
+	/*  																											CS_CLIENTMSG_CB, */
+	/*  																											(CS_VOID *) gda_sybase_clientmsg_callback); */
+	/*  	if (sconn->ret != CS_SUCCEED) { */
+	/*  		sybase_debug_msg(_("Could not initialize ct-client callback")); */
+	/*  		gda_sybase_connection_data_free (sconn); */
+	/*  		return FALSE; */
+	/*  	} */
+	/*  	sybase_debug_msg(_("CT-Client callback initialized.")); */
 	
 	/*   ct-srv */
-	sconn->ret = ct_callback (sconn->context, NULL, CS_SET, 
-	                          CS_SERVERMSG_CB,
-	                          (CS_VOID *) gda_sybase_servermsg_callback);
-	if (sconn->ret != CS_SUCCEED) {
-		sybase_debug_msg(_("Could not initialize ct-server callback"));
-		gda_sybase_connection_data_free (sconn);
-		return FALSE;
-	}
-	sybase_debug_msg(_("CT-Server callback initialized."));
+	/*  	sconn->ret = ct_callback (sconn->context, NULL, CS_SET,  */
+	/*  																											CS_SERVERMSG_CB, */
+	/*  																											(CS_VOID *) gda_sybase_servermsg_callback); */
+	/*  	if (sconn->ret != CS_SUCCEED) { */
+	/*  		sybase_debug_msg(_("Could not initialize ct-server callback")); */
+	/*  		gda_sybase_connection_data_free (sconn); */
+	/*  		return FALSE; */
+	/*  	} */
+	/*  	sybase_debug_msg(_("CT-Server callback initialized.")); */
 
 	/* allocate the connection structure */
 	sconn->ret = ct_con_alloc(sconn->context, &sconn->connection);
@@ -367,114 +381,127 @@
 		gda_sybase_connection_data_free (sconn);
 		return FALSE;
 	}
-	sybase_debug_msg(_("Connection allocated."));
+	//sybase_debug_msg(_("Connection allocated."));
 	/* init inline error handling for cs-lib */
-/*	sconn->ret = cs_diag (sconn->context, 
-	                      CS_INIT, 
-	                      CS_UNUSED, 
-	                      CS_UNUSED,
-	                      NULL);		
+	sconn->ret = cs_diag (sconn->context, 
+												CS_INIT, 
+												CS_UNUSED, 
+												CS_UNUSED,
+												NULL);		
 	if (sconn->ret != CS_SUCCEED) {
 		gda_sybase_connection_data_free (sconn);
 		return FALSE;
 	}
-	sybase_debug_msg(_("Error handling for cs-lib initialized.")); */
+	//sybase_debug_msg(_("Error handling for cs-lib initialized.")); 
 	/* init inline error handling for ct-lib */
-/*	sconn->ret = ct_diag (sconn->connection, 
-	                      CS_INIT, 
-	                      CS_UNUSED, 
-	                      CS_UNUSED,
-	                      NULL);
+	sconn->ret = ct_diag (sconn->connection, 
+												CS_INIT, 
+												CS_UNUSED, 
+												CS_UNUSED,
+												NULL);
 	if (sconn->ret != CS_SUCCEED) {
 		gda_sybase_connection_data_free (sconn);
 		return FALSE;
 	}
-	sybase_debug_msg(_("Error handling for ct-lib initialized.")); */
+	//sybase_debug_msg(_("Error handling for ct-lib initialized.")); 
 
 	/* set object data for error handling routines */
 	sconn->gda_cnc = cnc; /* circular reference for freeing */
+
 	g_object_set_data (G_OBJECT (cnc), OBJECT_DATA_SYBASE_HANDLE, sconn);
+
 	/* now first check possible, do so */
 	
 	/* set appname */
 	sconn->ret = ct_con_props (sconn->connection, 
-	                           CS_SET, 
-	                           CS_APPNAME, 
-	                           (CS_CHAR *) "gda-sybase provider", 
-	                           CS_NULLTERM, 
-	                           NULL);
+														 CS_SET, 
+														 CS_APPNAME, 
+														 (CS_CHAR *) "gda-sybase provider", 
+														 CS_NULLTERM, 
+														 NULL);
 	if (sconn->ret != CS_SUCCEED) {
+		sybase_check_messages(cnc);
 		gda_sybase_connection_data_free (sconn);
 		return FALSE;
 	}
-	sybase_debug_msg(_("Appname set."));
+	//sybase_debug_msg(_("Appname set."));
 
 	/* set username */
 	sconn->ret = ct_con_props (sconn->connection, 
-	                           CS_SET, 
-	                           CS_USERNAME, 
-	                           (CS_CHAR *) t_user,
-	                           CS_NULLTERM, 
-	                           NULL);
+														 CS_SET, 
+														 CS_USERNAME, 
+														 (CS_CHAR *) t_user,
+														 CS_NULLTERM, 
+														 NULL);
 	if (sconn->ret != CS_SUCCEED) {
+		sybase_check_messages(cnc);
 		gda_sybase_connection_data_free (sconn);
 		return FALSE;
 	}
-	sybase_debug_msg(_("Username set."));
+	//sybase_debug_msg(_("Username set."));
 
 	/* assume null-length passwords as passwordless logins */
 	if ((t_password != NULL) && (strlen(t_password) > 0)) {
 		sconn->ret = ct_con_props (sconn->connection, 
-		                           CS_SET, 
-		                           CS_PASSWORD, 
-		                           (CS_CHAR *) t_password,
-		                           CS_NULLTERM, 
-		                           NULL);
+															 CS_SET, 
+															 CS_PASSWORD, 
+															 (CS_CHAR *) t_password,
+															 CS_NULLTERM, 
+															 NULL);
 		if (sconn->ret != CS_SUCCEED) {
+			sybase_check_messages(cnc);
 			gda_sybase_connection_data_free (sconn);
 			return FALSE;
 		}
-		sybase_debug_msg(_("Password set."));
+		//sybase_debug_msg(_("Password set."));
 	} else {
 		sconn->ret = ct_con_props (sconn->connection, 
-		                           CS_SET, 
-		                           CS_PASSWORD, 
-		                           (CS_CHAR *) "",
-		                           CS_NULLTERM, 
-		                           NULL);
+															 CS_SET, 
+															 CS_PASSWORD, 
+															 (CS_CHAR *) "",
+															 CS_NULLTERM, 
+															 NULL);
 		if (sconn->ret != CS_SUCCEED) {
+			sybase_check_messages(cnc);
 			gda_sybase_connection_data_free (sconn);
 			return FALSE;
 		}
-		sybase_debug_msg(_("Empty password set."));
+		//sybase_debug_msg(_("Empty password set."));
 	}
 	sconn->ret = ct_connect (sconn->connection, 
-	                         (t_host) ? ((CS_CHAR *) t_host)
-	                                  : ((CS_CHAR *) NULL), 
-	                         (t_host) ? strlen(t_host) : 0);
+													 (t_host) ? ((CS_CHAR *) t_host)
+													 : ((CS_CHAR *) NULL), 
+													 (t_host) ? strlen(t_host) : 0);
 	if (sconn->ret != CS_SUCCEED) {
+		sybase_check_messages(cnc);
 		gda_sybase_connection_data_free (sconn);
 		return FALSE;
 	}
-	sybase_debug_msg(_("Connected."));
+
+	//sybase_debug_msg(_("Connected."));
 
 	if (t_db) 
 		gda_sybase_provider_change_database (provider, cnc, t_db);
 	
 	/* get the hostname from SQL server as a test */
 	sconn->ret = ct_con_props (sconn->connection, 
-	                           CS_GET, 
-	                           CS_SERVERNAME, 
-	                           &buf,
-	                           CS_MAX_CHAR, 
-	                           NULL);
+														 CS_GET, 
+														 CS_SERVERNAME, 
+														 &buf,
+														 CS_MAX_CHAR, 
+														 NULL);
 	if (sconn->ret != CS_SUCCEED) {
+		sybase_check_messages(cnc);
 		gda_sybase_connection_data_free (sconn);
-		
 		return FALSE;
 	}
 
-	sybase_debug_msg (_("Finally connected."));
+	//sybase_debug_msg (_("Finally connected."));
+
+	// get rid of the initial change database context to... messages
+	sybase_check_messages(cnc);
+
+	//sybase_debug_msg (_("done emptying junk messages."));
 
 	return TRUE;
 }
@@ -482,7 +509,7 @@
 /* close_connection handler for the GdaSybaseProvider class */
 static gboolean
 gda_sybase_provider_close_connection (GdaServerProvider *provider, 
-				      GdaConnection *cnc)
+																			GdaConnection *cnc)
 {
 	GdaSybaseConnectionData *sconn;
 	g_return_val_if_fail (GDA_IS_SYBASE_PROVIDER (provider), FALSE);
@@ -490,7 +517,7 @@
 	sconn = g_object_get_data (G_OBJECT (cnc), OBJECT_DATA_SYBASE_HANDLE);
 	g_return_val_if_fail (sconn != NULL, FALSE);
 
-	/* close connection before freeing data */
+	// close connection before freeing data
 	if (sconn->connection != NULL) {
 		sconn->ret = ct_close(sconn->connection, CS_UNUSED);
 	}
@@ -505,7 +532,7 @@
                                       GdaConnection *cnc,
                                       GdaTransaction *xaction)
 {
-	return FALSE;
+	return ( gda_sybase_execute_cmd(cnc,"begin transaction") );
 }
 
 static gboolean
@@ -523,7 +550,7 @@
 	sql_cmd = g_strdup_printf("USE %s", name);
 	ret = gda_sybase_execute_cmd(cnc, sql_cmd);
 	g_free(sql_cmd);
-	
+
 	return ret;
 }
 
@@ -532,7 +559,7 @@
                                         GdaConnection *cnc,
                                         GdaTransaction *xaction)
 {
-	return FALSE;
+	return ( gda_sybase_execute_cmd(cnc,"commit transaction") );		
 }
 
 static gboolean 
@@ -567,27 +594,27 @@
 	g_return_val_if_fail (cmd != NULL, NULL);
 
 	switch (gda_command_get_command_type (cmd)) {
-		case GDA_COMMAND_TYPE_SQL:
-			reclist = gda_sybase_provider_process_sql_commands (reclist, cnc, gda_command_get_text (cmd));
-			break;
-		case GDA_COMMAND_TYPE_TABLE:
-			query = g_strdup_printf ("SELECT * FROM %s", gda_command_get_text (cmd));
-			reclist = gda_sybase_provider_process_sql_commands (reclist, cnc, query);
-			if (reclist && GDA_IS_DATA_MODEL (reclist->data)) {
-				gda_data_model_set_command_text (GDA_DATA_MODEL (reclist->data),
-				                                 gda_command_get_text (cmd));
-				gda_data_model_set_command_type (GDA_DATA_MODEL (reclist->data),
-				                                 GDA_COMMAND_TYPE_TABLE);
-			}
-			g_free(query);
-			query = NULL;
-			break;
-		case GDA_COMMAND_TYPE_XML:
-		case GDA_COMMAND_TYPE_PROCEDURE:
-		case GDA_COMMAND_TYPE_SCHEMA:
-		case GDA_COMMAND_TYPE_INVALID:
-			return reclist;
-			break;
+	case GDA_COMMAND_TYPE_SQL:
+		reclist = gda_sybase_provider_process_sql_commands (reclist, cnc, gda_command_get_text (cmd));
+		break;
+	case GDA_COMMAND_TYPE_TABLE:
+		query = g_strdup_printf ("SELECT * FROM %s", gda_command_get_text (cmd));
+		reclist = gda_sybase_provider_process_sql_commands (reclist, cnc, query);
+		if (reclist && GDA_IS_DATA_MODEL (reclist->data)) {
+			gda_data_model_set_command_text (GDA_DATA_MODEL (reclist->data),
+																			 gda_command_get_text (cmd));
+			gda_data_model_set_command_type (GDA_DATA_MODEL (reclist->data),
+																			 GDA_COMMAND_TYPE_TABLE);
+		}
+		g_free(query);
+		query = NULL;
+		break;
+	case GDA_COMMAND_TYPE_XML:
+	case GDA_COMMAND_TYPE_PROCEDURE:
+	case GDA_COMMAND_TYPE_SCHEMA:
+	case GDA_COMMAND_TYPE_INVALID:
+		return reclist;
+		break;
 	}
 
 	return reclist;
@@ -601,7 +628,11 @@
 	GdaSybaseConnectionData *scnc;
 	GdaError                *error;
 	gchar                   **arr;
-	
+	GdaSybaseRecordset      *srecset = NULL;	
+	CS_RETCODE              ret;
+	CS_INT                  msgcnt = 0;
+
+
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 	scnc = g_object_get_data (G_OBJECT (cnc), OBJECT_DATA_SYBASE_HANDLE);
 	g_return_val_if_fail (scnc != NULL, NULL);
@@ -612,9 +643,8 @@
 		return NULL;
 	}
 
-	/* FIXME: ; in values bug
-	 *        e.g. SELECT * from x where y LIKE '%foo; bar%'
-	 */
+	// FIXME: ; in values bug
+	//        e.g. SELECT * from x where y LIKE '%foo; bar%'
 	arr = g_strsplit (sql, ";", 0);
 	if (arr) {
 		gint n = 0;
@@ -624,110 +654,183 @@
 			scnc->ret = ct_cmd_alloc (scnc->connection, &scnc->cmd);
 			if (scnc->ret != CS_SUCCEED) {
 				sybase_debug_msg(_("Failed allocating a command structure in %s()"),
-				                 __FUNCTION__);
+												 __FUNCTION__);
+				sybase_check_messages(cnc);
 				return NULL;
 			}
 
-
-			/* execute _single_ sql query (one stmt) */
-			scnc->ret = ct_command (scnc->cmd, CS_LANG_CMD,
-			                        arr[n], CS_NULLTERM, CS_UNUSED);
+			// execute _single_ sql query (one stmt)
+			scnc->ret = ct_command (scnc->cmd, 
+															CS_LANG_CMD,
+															arr[n], 
+															CS_NULLTERM, 
+															CS_UNUSED);
 			if (scnc->ret != CS_SUCCEED) {
 				error = gda_sybase_make_error (scnc,
-					_("Could not prepare command structure."));
+																			 _("Could not prepare command structure."));
 				gda_connection_add_error (cnc, error);
 				ct_cmd_drop (scnc->cmd);
 				scnc->cmd = NULL;
+				sybase_check_messages(cnc);
 				return reclist;
 			}
 			scnc->ret = ct_send(scnc->cmd);
 			if (scnc->ret != CS_SUCCEED) {
 				error = gda_sybase_make_error (scnc,
-					_("Sending sql-command failed."));
+																			 _("Sending sql-command failed."));
 				gda_connection_add_error (cnc, error);
 				ct_cmd_drop (scnc->cmd);
 				scnc->cmd = NULL;
+				sybase_check_messages(cnc);
 				return reclist;
 			}
 
-			/* now comes the ugly part: 
-			 *   dealing with multiple resultsets
-			 */
-			
-			/* part 1: process results in while-loop */
-			while ((scnc->rret = ct_results (scnc->cmd,
-			                                 &scnc->res_type
-                                                        )
-			       ) == CS_SUCCEED) {
-				/* gda_sybase_recordset_new ()
-				 * just returns a datamodel, 
-				 * if we have a query with results...
-				 */
-				recset = gda_sybase_recordset_new (cnc, TRUE);
-				
-				if (GDA_IS_SYBASE_RECORDSET (recset)) {
-					gda_data_model_set_command_text (recset, arr[n]);
-					gda_data_model_set_command_type (recset, GDA_COMMAND_TYPE_SQL);
-					reclist = g_list_append (reclist, recset);
-	                        } else {
-				}
-
-				/* this is done within gda_sybase_recordset_new() */
-/*				switch (scnc->res_type) {
-					case CS_ROW_RESULT:
-						break;
-					case CS_CURSOR_RESULT:
-						break;
-					case CS_PARAM_RESULT:
-						break;
-					case CS_STATUS_RESULT:
-						break;
-					case CS_COMPUTE_RESULT:
-						break;
-					case CS_MSG_RESULT:
-						break;
-					case CS_DESCRIBE_RESULT:
-						break;
-					case CS_ROWFMT_RESULT:
-						break;
-					case CS_COMPUTEFMT_RESULT:
-						break;
-					case CS_CMD_DONE:
-						break;
-					case CS_CMD_SUCCEED:
-						break;
-					case CS_CMD_FAIL:
-						break;
-				}
-*/
-			}
-
-			/* part 2: have a look at the final returncode */
-			switch (scnc->rret) {
-				case CS_END_RESULTS:
+			// part 1: process results in while-loop
+			while ((scnc->rret = 
+							ct_results (scnc->cmd,&scnc->res_type)) == CS_SUCCEED){
+				switch (scnc->res_type) {
+				case CS_ROW_RESULT:
+					// the query returned a result set!
+					//sybase_debug_msg (_("CS_ROW_RESULT!"));
+
+					srecset = gda_sybase_process_row_result (cnc, 
+																									 scnc,
+																									 TRUE);
+					recset = GDA_DATA_MODEL(srecset);
+					if (GDA_IS_SYBASE_RECORDSET (recset)) {
+						gda_data_model_set_command_text (recset, arr[n]);
+						gda_data_model_set_command_type (recset, GDA_COMMAND_TYPE_SQL);
+						reclist = g_list_append (reclist, recset);
+					}
+					else
+						sybase_debug_msg (_("GDA_IS_SYBASE_RECORDSET != TRUE"));						
 					break;
-				case CS_CANCELED:
+				case CS_STATUS_RESULT:
+					// when you execute a stored procedure through openclient, this 
+					// part of the result set loop is where you fetch the return status
+					// of the executed stored procedure.  You fetch it like a CS_ROW_RESULT
+					sybase_debug_msg (_("CS_STATUS_RESULT!"));
+
+					srecset = gda_sybase_process_row_result (cnc, 
+																									 scnc,
+																									 TRUE);
+					recset = GDA_DATA_MODEL(srecset);
+					if (GDA_IS_SYBASE_RECORDSET (recset)) {
+						gda_data_model_set_command_text (recset, arr[n]);
+						gda_data_model_set_command_type (recset, GDA_COMMAND_TYPE_SQL);
+						reclist = g_list_append (reclist, recset);
+					}
+					else
+						sybase_debug_msg (_("GDA_IS_SYBASE_RECORDSET != TRUE"));						
+				case CS_COMPUTE_RESULT:
+					// FIXME - figure this out
 					break;
-				case CS_FAIL:
+					// you should not hit any of these.  If you do, cancel the result set.
+				case CS_CURSOR_RESULT:
+				case CS_PARAM_RESULT:
+				case CS_DESCRIBE_RESULT:
+				case CS_ROWFMT_RESULT:
+				case CS_COMPUTEFMT_RESULT:
+					sybase_debug_msg (_("Hit unsupported result type"));
+					
+					scnc->ret = ct_cancel (NULL, scnc->cmd,
+																 CS_CANCEL_CURRENT);
 					break;
-			}
+				case CS_CMD_DONE:
+					// the command executed successfully.  
+					//sybase_debug_msg (_("CS_CMD_DONE!"));
+					break;
+				case CS_CMD_SUCCEED:
+					// this case is when you execute a query, but no rows where returned.
+					//sybase_debug_msg (_("CS_CMD_SUCCEED!"));
+					
+					// wierd workaround...  when you use the transact sql statement
+					// 'print' in the console, it does not indicate any results where returned. 
+					// it used to go to CS_MSG_RESULT.  handle it here.
+					
+					// check the number of msgs...
+					// see if there is a message
+					ret = ct_diag (scnc->connection,
+												 CS_STATUS, 
+												 CS_ALLMSG_TYPE, 
+												 CS_UNUSED,
+												 &msgcnt);
+					
+					if ( ret != CS_SUCCEED ) {
+						error = gda_error_new();
+						g_return_val_if_fail (error != NULL, FALSE);
+						gda_error_set_description (error, _("an error occured when calling ct_diag attempting to test if there is a server message for resultset"));
+						gda_error_set_number (error, -1);
+						gda_error_set_source (error, "gda-sybase");
+						gda_error_set_sqlstate (error, _("Not available"));					
+						gda_connection_add_error (cnc, error);		
+						return NULL;
+					}			
+					// if there are no messages, then the command didn't return any results.
+					// create an empty resultset.
+					if ( msgcnt == 0 ) {
+						srecset = g_object_new (GDA_TYPE_SYBASE_RECORDSET, NULL);
+						if ((srecset != NULL) && (srecset->priv != NULL)
+								&& (srecset->priv->columns != NULL) 
+								&& (srecset->priv->rows != NULL)) {
+							srecset->priv->cnc = cnc;
+							srecset->priv->scnc = scnc;
+						}
+					}
+					else
+						srecset = gda_sybase_process_msg_result(cnc,scnc); 
+
+					recset = GDA_DATA_MODEL(srecset);
+					if (GDA_IS_SYBASE_RECORDSET (recset)) {
+						gda_data_model_set_command_text (recset, arr[n]);
+						gda_data_model_set_command_type (recset, GDA_COMMAND_TYPE_SQL);
+						reclist = g_list_append (reclist, recset);
+					}
+					else
+						sybase_debug_msg (_("GDA_IS_SYBASE_RECORDSET != TRUE"));						
+					break;
+				case CS_CMD_FAIL:
+					sybase_debug_msg (_("%s returned %s"),
+														"ct_results()", "CS_CMD_FAIL");
+					sybase_check_messages(cnc);
+					break;
+				case CS_MSG_RESULT:
+					// when you use the 'print' SQL statement in a stored procedure,
+					// you will hit this case. 
+					//sybase_debug_msg (_("CS_MSG_RESULT!"));
+		
+					srecset = gda_sybase_process_msg_result(cnc,scnc);
+
+					recset = GDA_DATA_MODEL(srecset);
+					if (GDA_IS_SYBASE_RECORDSET (recset)) {
+						gda_data_model_set_command_text (recset, arr[n]);
+						gda_data_model_set_command_type (recset, GDA_COMMAND_TYPE_SQL);
+						reclist = g_list_append (reclist, recset);
+					}
+					else
+						sybase_debug_msg (_("GDA_IS_SYBASE_RECORDSET != TRUE"));						
+					break;
+				default:
+					break;
+				} // switch
+			} // while ct_results()
 
 			scnc->ret = ct_cmd_drop (scnc->cmd);
 			if (scnc->ret != CS_SUCCEED) {
 				sybase_debug_msg(_("Failed dropping command structure."));
-			} else {
+				sybase_check_messages(cnc);
+			} 
+			else {
 				scnc->cmd = NULL;
 			}
-			
-                        n++;
-		}
+			n++;
+		} // while arr[n] != NULL
 		g_strfreev(arr);
 	}
-
 	return reclist;
 }
 
-/* Executes a resultless sql statement */
+// Executes a resultless sql statement
 static gboolean
 gda_sybase_execute_cmd (GdaConnection *cnc, const gchar *sql)
 {
@@ -745,7 +848,7 @@
 	
 	if (scnc->cmd != NULL) {
 		error = gda_sybase_make_error (scnc, _("Command structure already in use. %s failed."),
-		                               __FUNCTION__);
+																	 __FUNCTION__);
 		gda_connection_add_error (cnc, error);
 		return FALSE;
 	}
@@ -754,15 +857,17 @@
 	if (scnc->ret != CS_SUCCEED) {
 		error = gda_sybase_make_error (scnc, _("Could not allocate command structure."));
 		gda_connection_add_error (cnc, error);
+		sybase_check_messages(cnc);
 		return FALSE;
 	}
 
 	scnc->ret = ct_command (scnc->cmd, CS_LANG_CMD, (CS_CHAR *) sql, 
-	                        CS_NULLTERM, CS_UNUSED);
+													CS_NULLTERM, CS_UNUSED);
 	if (scnc->ret != CS_SUCCEED) {
 		error = gda_sybase_make_error (scnc, _("Could not prepare command structure with %s."), "ct_command()");
 		gda_connection_add_error (cnc, error);
 		ct_cmd_drop (scnc->cmd);
+		sybase_check_messages(cnc);
 		scnc->cmd = NULL;
 		return FALSE;
 	}
@@ -772,45 +877,48 @@
 		error = gda_sybase_make_error (scnc, _("Sending command failed."));
 		gda_connection_add_error (cnc, error);
 		ct_cmd_drop (scnc->cmd);
+		sybase_check_messages(cnc);
 		scnc->cmd = NULL;
 		return FALSE;
 	}
 
-	/* proceed result codes, ct_cancel unexpected resultsets */
+	// proceed result codes, ct_cancel unexpected resultsets
 	while ((scnc->ret = ct_results (scnc->cmd, &res_type)) == CS_SUCCEED) {
 		switch (res_type) {
-			case CS_CMD_SUCCEED:
-			case CS_CMD_DONE:
-				break;
-
-			case CS_CMD_FAIL:
-				ret = FALSE;
-				break;
+		case CS_CMD_SUCCEED:
+		case CS_CMD_DONE:
+			break;
 
-			case CS_STATUS_RESULT:
-				scnc->ret = ct_cancel (NULL, scnc->cmd,
-				                       CS_CANCEL_CURRENT);
-				if (scnc->ret != CS_SUCCEED) {
-					error = gda_sybase_make_error (
-						scnc,
-						_("%s: %s failed"), __FUNCTION__, "ct_cancel");
-					gda_connection_add_error (cnc, error);
-					ret = FALSE;
-				}
-				break;
+		case CS_CMD_FAIL:
+			ret = FALSE;
+			break;
 
-			default:
+		case CS_STATUS_RESULT:
+			scnc->ret = ct_cancel (NULL, scnc->cmd,
+														 CS_CANCEL_CURRENT);
+			if (scnc->ret != CS_SUCCEED) {
+				error = gda_sybase_make_error (
+																			 scnc,
+																			 _("%s: %s failed"), __FUNCTION__, "ct_cancel");
+				gda_connection_add_error (cnc, error);
+				sybase_check_messages(cnc);
 				ret = FALSE;
+			}
+			break;
+
+		default:
+			ret = FALSE;
 		}
-		/* cancel all result processing on failure */
+		// cancel all result processing on failure
 		if (!ret) {
 			scnc->ret = ct_cancel (NULL, scnc->cmd,
-			                       CS_CANCEL_ALL);
+														 CS_CANCEL_ALL);
 			if (scnc->ret != CS_SUCCEED) {
 				error = gda_sybase_make_error (
-					scnc,
-					_("%s: %s failed"), __FUNCTION__, "ct_cancel");
+																			 scnc,
+																			 _("%s: %s failed"), __FUNCTION__, "ct_cancel");
 				gda_connection_add_error (cnc, error);
+				sybase_check_messages(cnc);
 			}
 		}
 	}
@@ -819,9 +927,10 @@
 		scnc->ret = ct_cmd_drop (scnc->cmd);
 		if (scnc->ret != CS_SUCCEED) {
 			error = gda_sybase_make_error (scnc,
-			            _("%s: %s failed"),
-			            __FUNCTION__, "ct_cmd_drop()");
+																		 _("%s: %s failed"),
+																		 __FUNCTION__, "ct_cmd_drop()");
 			gda_connection_add_error (cnc, error);
+			sybase_check_messages(cnc);
 			ret = FALSE;
 		} else {
 			scnc->cmd = NULL;
@@ -840,42 +949,122 @@
                                   GdaConnection *cnc)
 {
 	GdaSybaseConnectionData *sconn = NULL;
-	CS_COMMAND *cmd = NULL;
+	CS_RETCODE ret,ret1,ret2,result_type;
+	CS_CHAR current_db[256];
+	CS_COMMAND     *cmd;
+	CS_DATAFMT column;
+	CS_INT datalen;
+	CS_SMALLINT indicator;
+	CS_INT count;
 
 	g_return_val_if_fail (provider != NULL, NULL);
 	g_return_val_if_fail (cnc != NULL, NULL);
 
-	sconn = (GdaSybaseConnectionData *) g_object_get_data (G_OBJECT (cnc),
-	                                                       OBJECT_DATA_SYBASE_HANDLE);
+	memset(current_db,'\0',256);
 
+	sconn = (GdaSybaseConnectionData *) g_object_get_data (G_OBJECT (cnc),
+																												 OBJECT_DATA_SYBASE_HANDLE);
 	g_return_val_if_fail (sconn != NULL, NULL);
-	g_return_val_if_fail (sconn-> connection != NULL, NULL);
+	g_return_val_if_fail (sconn->connection != NULL, NULL);
+	g_return_val_if_fail (sconn->context != NULL, NULL);
+
+	ret = ct_cmd_alloc(sconn->connection, &cmd);
 	
-	sconn->ret = ct_cmd_alloc (sconn->connection, &cmd);
-	if (sconn->ret != CS_SUCCEED) {
-		if (sconn->ret == CS_BUSY) {
-			sybase_debug_msg (_("Connection already in use. Could not allocate command structure in %s()."), __FUNCTION__);
-		} else {
-			sybase_debug_msg (_("Could not allocate command structure."));
-		}
+	if ( ret != CS_SUCCEED ) {
+		sybase_debug_msg (_("could not allocate cmd structure to find current database."));
+		return NULL;
+	}
+	
+	ret = ct_command(cmd, 
+									 CS_LANG_CMD,
+									 TDS_QUERY_CURRENT_DATABASE,
+									 CS_NULLTERM, 
+									 CS_UNUSED); 	
+
+	if ( ret != CS_SUCCEED ) {
+		sybase_debug_msg (_("could not execute command to get current database."));
+		sybase_check_messages(cnc);
+		return NULL;
+	}
+
+	ret = ct_send(cmd);
+	
+	if ( ret != CS_SUCCEED ) {
+		sybase_debug_msg (_("could not send command to get current database."));
+		sybase_check_messages(cnc);
 		return NULL;
 	}
 
+	while( (ret2 = ct_results(cmd, &result_type)) == CS_SUCCEED)
+		{
+			switch((int)result_type)
+				{
+				case CS_ROW_RESULT:
+					column.datatype = CS_CHAR_TYPE;
+					column.format = CS_FMT_NULLTERM;
+					column.maxlength = 255;
+					column.count = 1;
+					column.locale = NULL;
+					ret = ct_bind(cmd, 
+												1, 
+												&column,
+												current_db, 
+												&datalen,
+												&indicator);
+
+					if ( ret != CS_SUCCEED ) {
+						sybase_debug_msg (_("could not bind variable to get current database."));
+						sybase_check_messages(cnc);
+						return NULL;
+					}
+
+					ret1 = ct_fetch(cmd, 
+													CS_UNUSED, 
+													CS_UNUSED,
+													CS_UNUSED, 
+													&count);
+
+
+					if ( ret != CS_SUCCEED ) {
+						sybase_debug_msg (_("could not fetch data to find current database."));
+						sybase_check_messages(cnc);
+						return NULL;
+					}
+
+					while(ret1 == CS_SUCCEED)
+						{
+							ret1 = ct_fetch(cmd, 
+															CS_UNUSED, 
+															CS_UNUSED,
+															CS_UNUSED, 
+															&count);							
+						}
+
+					if ( ret != CS_SUCCEED ) {
+						sybase_debug_msg (_("could not fetch data to find current database."));
+						sybase_check_messages(cnc);
+						return NULL;
+					}
 
+					break;
+				default:
+					break;
+				}
+		}
 	
-/*	ret = ct_send(sconn->connection, cmd); */
+	ret = ct_cmd_drop(cmd);
 
-	sconn->ret = ct_cmd_drop (cmd);
-	if (sconn->ret != CS_SUCCEED) {
-		sybase_debug_msg (_("Failed dropping command structure in %s()."),
-		                  __FUNCTION__);
+	if ( ret != CS_SUCCEED ) {
+		sybase_debug_msg (_("could not drop cmd structure to find current database."));
+		sybase_check_messages(cnc);
 		return NULL;
 	}
-	cmd = NULL;
-	
-	return NULL;
+
+	return ( g_strdup(current_db) );
 }
 
+
+// FIXME : implement this
 static GdaDataModel *
 gda_sybase_get_fields (GdaConnection *cnc,
                        GdaParameterList *params)
@@ -883,7 +1072,7 @@
 	GdaSybaseConnectionData *scnc = NULL;
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 	scnc = (GdaSybaseConnectionData *) g_object_get_data (G_OBJECT (cnc),
-	                                      OBJECT_DATA_SYBASE_HANDLE);
+																												OBJECT_DATA_SYBASE_HANDLE);
 	g_return_val_if_fail (scnc != NULL, NULL);
 
 	return NULL;
@@ -899,38 +1088,38 @@
 	
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 	scnc = (GdaSybaseConnectionData *) g_object_get_data (G_OBJECT (cnc),
-	                                      OBJECT_DATA_SYBASE_HANDLE);
+																												OBJECT_DATA_SYBASE_HANDLE);
 	g_return_val_if_fail (scnc != NULL, NULL);
 
 	recset = (GdaDataModelArray *) gda_data_model_array_new (4);
 	gda_data_model_set_column_title (GDA_DATA_MODEL (recset),
-	                                 0, _("Type"));
+																	 0, _("Type"));
 	gda_data_model_set_column_title (GDA_DATA_MODEL (recset),
-	                                 1, _("Owner"));
+																	 1, _("Owner"));
 	gda_data_model_set_column_title (GDA_DATA_MODEL (recset),
-	                                 2, _("Comments"));
+																	 2, _("Comments"));
 	gda_data_model_set_column_title (GDA_DATA_MODEL (recset),
-	                                 3, _("GDA type"));
+																	 3, _("GDA type"));
 
 	for (i = 0; i < GDA_SYBASE_TYPE_CNT; i++) {
 		if (gda_sybase_type_list[i].name != NULL) {
 			GList *value_list = NULL;
 
 			value_list = g_list_append (value_list,
-			               gda_value_new_string (gda_sybase_type_list[i].name));
-			/* FIXME: owner */
-	                value_list = g_list_append (value_list,
-			               gda_value_new_string (""));
-	                value_list = g_list_append (value_list, 
-			               gda_value_new_string (""));
-	                value_list = g_list_append (value_list,
-			               gda_value_new_type (gda_sybase_type_list[i].gda_type));
-
-	                gda_data_model_append_row (GDA_DATA_MODEL (recset), value_list);
-	                g_list_foreach (value_list, (GFunc) gda_value_free, NULL);
-	                g_list_free (value_list);
+																	gda_value_new_string (gda_sybase_type_list[i].name));
+			// FIXME: owner
+			value_list = g_list_append (value_list,
+																	gda_value_new_string (""));
+			value_list = g_list_append (value_list, 
+																	gda_value_new_string (""));
+			value_list = g_list_append (value_list,
+																	gda_value_new_type (gda_sybase_type_list[i].gda_type));
+
+			gda_data_model_append_row (GDA_DATA_MODEL (recset), value_list);
+			g_list_foreach (value_list, (GFunc) gda_value_free, NULL);
+			g_list_free (value_list);
 		}
-        }
+	}
 	
 	return GDA_DATA_MODEL (recset);
 }
@@ -942,64 +1131,71 @@
                                 GdaParameterList *params)
 {
 	GdaSybaseProvider *syb_prov = (GdaSybaseProvider *) provider;
-	gchar        *query = NULL;
 	GdaDataModel *recset = NULL;
 	
 	g_return_val_if_fail (GDA_IS_SYBASE_PROVIDER (syb_prov), NULL);
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
 	switch (schema) {
-		case GDA_CONNECTION_SCHEMA_DATABASES:
-			recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_DATABASES);
-			TDS_FIXMODEL_SCHEMA_DATABASES (recset);
-
-			return recset;
-			break;
-		case GDA_CONNECTION_SCHEMA_FIELDS:
-			return gda_sybase_get_fields (cnc, params);
-			break;
-		case GDA_CONNECTION_SCHEMA_PROCEDURES:
-			recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_PROCEDURES);
-			TDS_FIXMODEL_SCHEMA_PROCEDURES (recset)
+	case GDA_CONNECTION_SCHEMA_DATABASES:
+		recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_DATABASES);
+		TDS_FIXMODEL_SCHEMA_DATABASES (recset);
+
+		return recset;
+		break;
+	case GDA_CONNECTION_SCHEMA_FIELDS:
+		return gda_sybase_get_fields (cnc, params);
+		break;
+	case GDA_CONNECTION_SCHEMA_PROCEDURES:
+		recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_PROCEDURES);
+		TDS_FIXMODEL_SCHEMA_PROCEDURES (recset)
 			
 			return recset;
-			break;
-		case GDA_CONNECTION_SCHEMA_TABLES:
-			recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_TABLES);
-			TDS_FIXMODEL_SCHEMA_TABLES (recset)
+		break;
+	case GDA_CONNECTION_SCHEMA_TABLES:
+		recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_TABLES);
+		TDS_FIXMODEL_SCHEMA_TABLES (recset)
 			
 			return recset;
-			break;
-		case GDA_CONNECTION_SCHEMA_TYPES:
-/*
-			recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_TYPES);
-			TDS_FIXMODEL_SCHEMA_TYPES (recset)
-*/
-			recset = gda_sybase_provider_get_types (cnc, params);
-	
-			return recset;
-			break;
-		case GDA_CONNECTION_SCHEMA_USERS:
-			recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_USERS);
-			TDS_FIXMODEL_SCHEMA_USERS (recset)
+		break;
+	case GDA_CONNECTION_SCHEMA_TYPES:
+		recset = gda_sybase_provider_get_types (cnc, params);
+
+		return recset;
+		break;
+	case GDA_CONNECTION_SCHEMA_USERS:
+		recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_USERS);
+		TDS_FIXMODEL_SCHEMA_USERS (recset)
 				
 			return recset;
-			break;
-		case GDA_CONNECTION_SCHEMA_VIEWS:
-			recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_VIEWS);
-			TDS_FIXMODEL_SCHEMA_VIEWS (recset)
+		break;
+	case GDA_CONNECTION_SCHEMA_VIEWS:
+		recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_VIEWS);
+		TDS_FIXMODEL_SCHEMA_VIEWS (recset)
 
 			return recset;
-			break;
+		break;
+	case GDA_CONNECTION_SCHEMA_INDEXES:
+		recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_INDEXES);
+		TDS_FIXMODEL_SCHEMA_INDEXES (recset);
+		
+		return recset;
+		break;				
+	case GDA_CONNECTION_SCHEMA_TRIGGERS:
+		recset = gda_sybase_execute_query (cnc, TDS_SCHEMA_TRIGGERS);
+		TDS_FIXMODEL_SCHEMA_TRIGGERS (recset);
+		
+		return recset;
+		break;				
 
-		/* FIXME: Implement aggregates, indexes, sequences and triggers */
-		case GDA_CONNECTION_SCHEMA_AGGREGATES:
-		case GDA_CONNECTION_SCHEMA_INDEXES:
-		case GDA_CONNECTION_SCHEMA_PARENT_TABLES:
-		case GDA_CONNECTION_SCHEMA_SEQUENCES:
-		case GDA_CONNECTION_SCHEMA_TRIGGERS:
-			return NULL;
-			break;
+		// FIXME: Implement aggregates, sequences 
+	case GDA_CONNECTION_SCHEMA_AGGREGATES:
+	case GDA_CONNECTION_SCHEMA_PARENT_TABLES:
+	case GDA_CONNECTION_SCHEMA_SEQUENCES:
+	case GDA_CONNECTION_SCHEMA_LANGUAGES:
+	case	GDA_CONNECTION_SCHEMA_NAMESPACES:
+		return NULL;
+		break;
 	}
 	
 	return NULL;
@@ -1017,7 +1213,7 @@
 	g_return_val_if_fail (sql != NULL, NULL);
 
 	scnc = (GdaSybaseConnectionData *) g_object_get_data (G_OBJECT (cnc),
-	                                       OBJECT_DATA_SYBASE_HANDLE);
+																												OBJECT_DATA_SYBASE_HANDLE);
 	g_return_val_if_fail (scnc != NULL, NULL);
 
 	model_list = gda_sybase_provider_process_sql_commands (NULL, cnc, sql);
@@ -1041,17 +1237,17 @@
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 	
 	scnc = (GdaSybaseConnectionData *) g_object_get_data (G_OBJECT (cnc),
-	                                       OBJECT_DATA_SYBASE_HANDLE);
+																												OBJECT_DATA_SYBASE_HANDLE);
 	g_return_val_if_fail (scnc != NULL, NULL);
 	if (!scnc->server_version) {
 		model = gda_sybase_execute_query (cnc, TDS_QUERY_SERVER_VERSION);
 		if (model) {
 			if ((gda_data_model_get_n_columns (model) == 1)
-			     && (gda_data_model_get_n_rows (model) == 1)) {
+					&& (gda_data_model_get_n_rows (model) == 1)) {
 				GdaValue *value;
 				
 				value = (GdaValue *) gda_data_model_get_value_at (model, 
-				                                                  0, 0);
+																													0, 0);
 				scnc->server_version = gda_value_stringify ((GdaValue *) value);
 			}
 			g_object_unref (model);
@@ -1077,7 +1273,7 @@
                                           GdaConnection *cnc,
                                           GdaTransaction *xaction)
 {
-	return FALSE;
+	return ( gda_sybase_execute_cmd(cnc,"rollback transaction") );		
 }
 
 static gboolean 
@@ -1090,23 +1286,23 @@
 	g_return_val_if_fail (GDA_IS_SYBASE_PROVIDER (syb_prov), FALSE);
 
 	switch (feature) {
-		case GDA_CONNECTION_FEATURE_PROCEDURES:
-		case GDA_CONNECTION_FEATURE_USERS:
-		case GDA_CONNECTION_FEATURE_VIEWS:
-		case GDA_CONNECTION_FEATURE_SQL:
-			return TRUE;
-
-	/* FIXME: Implement missing */
-		case GDA_CONNECTION_FEATURE_AGGREGATES:
-		case GDA_CONNECTION_FEATURE_INDEXES:
-		case GDA_CONNECTION_FEATURE_INHERITANCE:
-		case GDA_CONNECTION_FEATURE_SEQUENCES:
-		case GDA_CONNECTION_FEATURE_TRANSACTIONS:
-		case GDA_CONNECTION_FEATURE_TRIGGERS:
-		case GDA_CONNECTION_FEATURE_XML_QUERIES:
-			return FALSE;
+	case GDA_CONNECTION_FEATURE_PROCEDURES:
+	case GDA_CONNECTION_FEATURE_USERS:
+	case GDA_CONNECTION_FEATURE_VIEWS:
+	case GDA_CONNECTION_FEATURE_SQL:
+	case GDA_CONNECTION_FEATURE_TRANSACTIONS:
+	case GDA_CONNECTION_FEATURE_INDEXES:
+	case GDA_CONNECTION_FEATURE_TRIGGERS:
+		return TRUE;
+
+		//FIXME: Implement missing 
+	case GDA_CONNECTION_FEATURE_AGGREGATES:
+	case GDA_CONNECTION_FEATURE_INHERITANCE:
+	case GDA_CONNECTION_FEATURE_SEQUENCES:
+	case GDA_CONNECTION_FEATURE_XML_QUERIES:
+	case GDA_CONNECTION_FEATURE_NAMESPACES:
+		return FALSE;
 	}
 	
 	return FALSE;
 }
-
Index: gda-sybase-provider.h
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/gda-sybase-provider.h,v
retrieving revision 1.7
diff -u -u -r1.7 gda-sybase-provider.h
--- gda-sybase-provider.h	3 Feb 2003 17:12:22 -0000	1.7
+++ gda-sybase-provider.h	28 Mar 2003 03:39:05 -0000
@@ -29,6 +29,7 @@
 #  define __gda_sybase_provider_h__
 
 #if defined(HAVE_CONFIG_H)
+#  include <config.h>
 #endif
 
 #include <libgda/gda-server-provider.h>
@@ -70,7 +71,7 @@
 };
 
 typedef struct _GdaSybaseConnectionData {
-	GdaConnection  *gda_cnc; /* "parent" */
+	GdaConnection  *gda_cnc; // "parent"
 	gchar          *server_version;
 	
 	CS_CONTEXT     *context;
@@ -78,10 +79,10 @@
 	CS_CONNECTION  *connection;
 	CS_CHAR        *mempool;
 
-	CS_RETCODE     ret;      /* for client operations */
-	CS_RETCODE     rret;     /* for ct_result operations */
-	CS_RETCODE     mret;     /* for message operations(cs_diag/ct_diag) */
-	CS_INT         res_type; /* resulttype of query in progress */
+	CS_RETCODE     ret;      // for client operations
+	CS_RETCODE     rret;     // for ct_result operations
+	CS_RETCODE     mret;     // for message operations(cs_diag/ct_diag)
+	CS_INT         res_type; // resulttype of query in progress
 } GdaSybaseConnectionData;
 
 GType              gda_sybase_provider_get_type (void);
Index: gda-sybase-recordset.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/gda-sybase-recordset.c,v
retrieving revision 1.5
diff -u -u -r1.5 gda-sybase-recordset.c
--- gda-sybase-recordset.c	3 Feb 2003 17:12:22 -0000	1.5
+++ gda-sybase-recordset.c	28 Mar 2003 03:39:06 -0000
@@ -22,6 +22,7 @@
  */
 
 #if defined(HAVE_CONFIG_H)
+#  include <config.h>
 #endif
 
 #include <libgda/gda-intl.h>
@@ -85,7 +86,7 @@
 
 	memcpy (name, colinfo->name,
 	        colinfo->namelen);
-	/* name[colinfo->namelen + 1] = '\0'; */
+	//name[colinfo->namelen + 1] = '\0';
 
 	gda_field_attributes_set_name (attribs, name);
 	gda_field_attributes_set_scale (attribs, colinfo->scale);
@@ -93,12 +94,11 @@
 	         gda_sybase_get_value_type (colinfo->datatype));
 	gda_field_attributes_set_defined_size (attribs, colinfo->maxlength);
 
-	/* FIXME: */
+	// FIXME:
 	gda_field_attributes_set_references (attribs, "");
 	gda_field_attributes_set_primary_key (attribs, FALSE);
-	/* gda_field_attributes_set_primary_key (attribs,
-	 *         (colinfo->status & CS_KEY) == CS_KEY);
-	 */
+	//gda_field_attributes_set_primary_key (attribs,
+	//         (colinfo->status & CS_KEY) == CS_KEY);
 	gda_field_attributes_set_unique_key (attribs, FALSE);
 	
 	gda_field_attributes_set_allow_null (attribs,
@@ -241,7 +241,7 @@
 	g_return_val_if_fail (recset->priv != NULL, NULL);
 	g_return_val_if_fail (recset->priv != NULL, NULL);
 
-	row = gda_row_new (recset->priv->columns->len);
+	row = gda_row_new (GDA_DATA_MODEL(recset),recset->priv->columns->len);
 	g_return_val_if_fail (row != NULL, NULL);
 
 	for (i = 0; i < recset->priv->columns->len; i++) {
@@ -281,7 +281,7 @@
 	return type;
 }
 
-static GdaSybaseRecordset *
+GdaSybaseRecordset *
 gda_sybase_process_row_result (GdaConnection           *cnc,
                                GdaSybaseConnectionData *scnc,
                                gboolean                fetchall)
@@ -296,9 +296,8 @@
 	CS_INT             rows_read = 0;
 	gint               row_cnt = 0;
 
-	/* called within gda_sybase_recordset_new
-	 * scnc->cmd != NULL, cnc != NULL
-	 */
+	// called within gda_sybase_recordset_new
+	// scnc->cmd != NULL, cnc != NULL
 	
 	srecset = g_object_new (GDA_TYPE_SYBASE_RECORDSET, NULL);
 	if ((srecset != NULL) && (srecset->priv != NULL)
@@ -307,9 +306,8 @@
 		srecset->priv->cnc = cnc;
 		srecset->priv->scnc = scnc;
 	} else {
-		/* most probably a lack of ram failure,
-		 * so don't alloc e.g. an instance of GdaError
-		 */
+		// most probably a lack of ram failure, 
+		// so don't alloc e.g. an instance of GdaError
 		if (srecset) {
 			g_object_unref (srecset);
 			srecset = NULL;
@@ -318,13 +316,14 @@
 		scnc->ret = ct_cancel (NULL, scnc->cmd, CS_CANCEL_CURRENT);
 		if (scnc->ret != CS_SUCCEED) {
 			sybase_error_msg (_("ct_cancel() failed."));
+			sybase_check_messages(cnc);
 		}
 		return NULL;
 	}
 
-/*	g_object_unref (srecset); */
+//	g_object_unref (srecset);
 
-	/* step 1: determine count of columns */
+	// step 1: determine count of columns
 	scnc->ret = ct_res_info(scnc->cmd, CS_NUMDATA,
 	                        &srecset->priv->colcnt, CS_UNUSED, NULL);
 	if (scnc->ret != CS_SUCCEED) {
@@ -332,6 +331,7 @@
 		                               _("%s failed while processing a row result."),
 		                               "ct_res_info()");
 		gda_connection_add_error (cnc, error);
+		sybase_check_messages(cnc);
 		return NULL;
 	}
 	if (srecset->priv->colcnt <= 0) {
@@ -342,7 +342,7 @@
 		return NULL;
 	}
 
-	/* step 2: allocate memory for column metainfo */
+	// step 2: allocate memory for column metainfo
 	for (i = 0; i < srecset->priv->colcnt; i++) {
 		sfield = g_new0 (GdaSybaseField, 1);
 		if (sfield != NULL) {
@@ -352,7 +352,7 @@
 		}
 	}
 
-	/* out of memory? fatal, just log and cancel all */
+	// out of memory? fatal, just log and cancel all
 	if (!sfields_allocated) {
 		g_object_unref (srecset);
 		srecset = NULL;
@@ -362,18 +362,16 @@
 		if (scnc->ret != CS_SUCCEED) {
 			sybase_error_msg (_("Could not call %s while processing row resultset."),
 			                  "ct_cancel()");
+			sybase_check_messages(cnc);
 		}
 		return srecset;
 	}
 
-/*
-	sybase_debug_msg (_("Counted %d columns, allocated metainf for %d"),
-	                  srecset->priv->colcnt, srecset->priv->columns->len);
-*/
+//	sybase_debug_msg (_("Counted %d columns, allocated metainf for %d"),
+//	                  srecset->priv->colcnt, srecset->priv->columns->len);
 	
-	/* step 3: collect information for each column,
-	 *         allocate a buffer for data and ct_bind it
-	 */
+	// step 3: collect information for each column,
+	//         allocate a buffer for data and ct_bind it
 	for (i = 0; i < srecset->priv->colcnt; i++) {
 		sfield = (GdaSybaseField *) g_ptr_array_index (srecset->priv->columns, i);
 		memset (&sfield->fmt, 0, sizeof(sfield->fmt));
@@ -383,6 +381,7 @@
 			error = gda_sybase_make_error (scnc, 
 			                               _("Could not run %s on column %d"), "ct_describe()", i);
 			gda_connection_add_error (cnc, error);
+			sybase_check_messages(cnc);
 			break;
 		}
 
@@ -391,6 +390,7 @@
 			error = gda_sybase_make_error (scnc,
 			                               _("Could not allocate data placeholder for column %d"), i);
 			gda_connection_add_error (cnc, error);
+			sybase_check_messages(cnc);
 			break;
 		}
 
@@ -402,6 +402,7 @@
 			error = gda_sybase_make_error (scnc,
 			                               _("Could not run %s on column %d"), "ct_bind()", i);
 			gda_connection_add_error (cnc, error);
+			sybase_check_messages(cnc);
 			break;
 		}
 
@@ -411,7 +412,7 @@
 		}
 	}
 
-	/* catch error: ct_describe or g_new0 or ct_bind failed */
+	// catch error: ct_describe or g_new0 or ct_bind failed
 	if ((scnc->ret != CS_SUCCEED) || (sfield->data == NULL)) {
 		g_object_unref (srecset);
 		srecset = NULL;
@@ -420,13 +421,14 @@
 		if (scnc->ret != CS_SUCCEED) {
 			error = gda_sybase_make_error (scnc, _("Could not run %s to cancel processing row resultset."), "ct_cancel");
 			gda_connection_add_error (cnc, error);
+			sybase_check_messages(cnc);
 		}
 		
 		return srecset;
 	}
 	columns_set = TRUE;
 
-	/* step 4: now proceed with fetching the data */
+	// step 4: now proceed with fetching the data
 	while ((scnc->ret = ct_fetch (scnc->cmd, CS_UNUSED, CS_UNUSED,
 	                              CS_UNUSED, &rows_read) == CS_SUCCEED)
 	       || (scnc->ret == CS_ROW_FAIL)) {
@@ -435,11 +437,11 @@
 		if (scnc->ret == CS_ROW_FAIL) {
 			error = gda_sybase_make_error (scnc, _("%s failed on row %d"), "ct_fetch()", row_cnt);
 			gda_connection_add_error (cnc, error);
+			sybase_check_messages(cnc);
 		}
 		
-		/* srecset->columns contains the data;
-		 * make a row out of it
-		 */
+		// srecset->columns contains the data;
+		// make a row out of it
 		row = gda_sybase_create_current_row (srecset);
 		if (row) {
 			g_ptr_array_add(srecset->priv->rows, row);
@@ -447,103 +449,152 @@
 		}
 	}
 
-/*	sybase_debug_msg (_("Got %d of %d rows"), srecset->priv->rowcnt, row_cnt); */
-	/* step 5: verify ct_fetch's last return code */
+//	sybase_debug_msg (_("Got %d of %d rows"), srecset->priv->rowcnt, row_cnt);
+	// step 5: verify ct_fetch's last return code
 	switch (scnc->ret) {
 		case CS_END_DATA:
-/*			sybase_debug_msg (_("Row processing succeeded.")); */
+//			sybase_debug_msg (_("Row processing succeeded."));
 			break;
 		case CS_CANCELED:
-/*			sybase_debug_msg (_("Row processing canceled.")); */
+//			sybase_debug_msg (_("Row processing canceled."));
 			break;
 		case CS_FAIL:
-/*			sybase_debug_msg (_("%s returned CS_FAIL. Probably o.k."), "ct_fetch()"); */
+//			sybase_debug_msg (_("%s returned CS_FAIL. Probably o.k."), "ct_fetch()");
 			break;
 		default:
 			error = gda_sybase_make_error (scnc, _("%s terminated with unexpected return code."), "ct_fetch()");
 			gda_connection_add_error (cnc, error);
+			sybase_check_messages(cnc);
 	}
 	
 	return srecset;
 }
 
-/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- * gda_sybase_recordset_new is a general result-processing routine
- * for processing a single ct_results() step.
- * 
- * Therefore it may also return no result, e.g. if the resulttype is
- * CS_CMD_DONE, i.e. we finished processing a command.
- * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- */
-GdaDataModel *
-gda_sybase_recordset_new (GdaConnection *cnc,
-                          gboolean fetchall)
-{
-	GdaSybaseConnectionData *scnc = NULL;
-	GdaSybaseRecordset      *srecset = NULL;
-/*	GdaSybaseField          *sfield = NULL; */
-/*	GdaRow                  *row = NULL; */
-	GdaError                *error = NULL;
-/*	gboolean                columns_set = FALSE; */
-/*	gint                    i = 0; */
-
-	g_return_val_if_fail (GDA_IS_CONNECTION(cnc), NULL);
-	scnc = (GdaSybaseConnectionData *) g_object_get_data (G_OBJECT (cnc),
-	                                           OBJECT_DATA_SYBASE_HANDLE);
-	g_return_val_if_fail (scnc != NULL, NULL);
-	g_return_val_if_fail (scnc->cmd != NULL, NULL);
-
-	/* now nothing may fail;
-	 * a result not processed may block the entire connection
-	 * each process_* routine must check if recset is valid,
-	 * otherwise alt. a) too process the results (eventually discard)
-	 *           alt. b) call ct_cancel, dropping _all_ results of
-	 *                   the entire query
-	 */
+
+GdaSybaseRecordset *
+gda_sybase_process_msg_result(GdaConnection *cnc,
+															GdaSybaseConnectionData *scnc)
+{
 	
+	// in ASE when a stored procedure uses the print statement, it 
+	// generates a CS_MSG_RESULT result code, treat it like another result set.
+
+	GdaSybaseRecordset *srecset = NULL;
+	GdaSybaseField *sfield = NULL;
+	//	gboolean sfields_allocated = TRUE;
+	GdaRow *row = NULL;
+	GdaValue *val = NULL;
+	gchar *message;
+	CS_INT msgcnt = 0;
+	GdaError *error;
+	CS_SERVERMSG msg; 
+	CS_RETCODE ret;
+
+	// called within gda_sybase_recordset_new
+	srecset = g_object_new (GDA_TYPE_SYBASE_RECORDSET, NULL);
+
+	srecset->priv->cnc = cnc;
+	srecset->priv->scnc = scnc;
+
+	// see if there is a message
+	ret = ct_diag (scnc->connection,
+								 CS_STATUS, 
+								 CS_ALLMSG_TYPE, 
+								 CS_UNUSED,
+								 &msgcnt);
 	
-	/* we are within the resultset processing loop,
-	 * ct_results (scnc->cmd, &scnc->res_type) = CS_SUCCEED
-	 */
-
-	switch (scnc->res_type) {
-		case CS_ROW_RESULT:
-			srecset = gda_sybase_process_row_result (cnc, scnc,
-			                                         TRUE);
-			break;
-	/* FIXME: implement CS_CURSOR_RESULT .. CS_COMPUTEFMT_RESULT */
-		case CS_CURSOR_RESULT:
-		case CS_PARAM_RESULT:
-		case CS_STATUS_RESULT:
-		case CS_COMPUTE_RESULT:
-		case CS_MSG_RESULT:
-		case CS_DESCRIBE_RESULT:
-		case CS_ROWFMT_RESULT:
-		case CS_COMPUTEFMT_RESULT:
-			scnc->ret = ct_cancel (NULL, scnc->cmd,
-			                       CS_CANCEL_CURRENT);
-			break;
-		case CS_CMD_DONE:
-/*			sybase_debug_msg (_("Done with resultset.")); */
-			break;
-		case CS_CMD_SUCCEED:
-/*			sybase_debug_msg (_("Command returned no rows.")); */
-			srecset = g_object_new (GDA_TYPE_SYBASE_RECORDSET, NULL);
-			if ((srecset != NULL) && (srecset->priv != NULL)
-			    && (srecset->priv->columns != NULL) 
-			    && (srecset->priv->rows != NULL)) {
-				srecset->priv->cnc = cnc;
-				srecset->priv->scnc = scnc;
-			}
-			break;
-		case CS_CMD_FAIL:
-			sybase_debug_msg (_("%s returned %s"),
-			                  "ct_results()", "CS_CMD_FAIL");
-			break;
+	if ( ret != CS_SUCCEED ) {
+		error = gda_error_new();
+		g_return_val_if_fail (error != NULL, FALSE);
+		gda_error_set_description (error, _("an error occured when calling ct_diag attempting to retrieve a server message count for resultset"));
+		gda_error_set_number (error, -1);
+		gda_error_set_source (error, "gda-sybase");
+		gda_error_set_sqlstate (error, _("Not available"));					
+		gda_connection_add_error (cnc, error);		
+		return NULL;
 	}
 
-	if (srecset) 
-		return GDA_DATA_MODEL (srecset);
-	else
-		return NULL;
+	if ( msgcnt < 1 ){
+			sybase_debug_msg (_("attempting to make recordset and msg count != 1 !"));
+			return NULL;
+	}
+
+	ret = ct_diag (scnc->connection, 
+																CS_GET, 
+																CS_SERVERMSG_TYPE, 
+																1, 
+																&msg); 
+	if ( ret != CS_SUCCEED ) { 
+		error = gda_error_new();
+		g_return_val_if_fail (error != NULL, FALSE);
+		gda_error_set_description (error,
+															 _("an error occured when calling ct_diag attempting to retrieve a server message for recordset"));
+		gda_error_set_number (error, -1);
+		gda_error_set_source (error, "gda-sybase");
+		gda_error_set_sqlstate (error, _("Not available"));					
+		gda_connection_add_error (cnc, error);
+		return NULL;					
+	} 	
+
+	srecset->priv->colcnt = 1;
+
+	sfield = g_new0 (GdaSybaseField, 1);
+
+	if (sfield != NULL) {
+		g_ptr_array_add (srecset->priv->columns, sfield);
+	} 
+	else {
+		g_object_unref (srecset);
+		srecset = NULL;
+		sybase_error_msg (_("Could not allocate structure for column metainformation."));
+		
+		scnc->ret = ct_cancel (NULL, scnc->cmd, CS_CANCEL_ALL);
+		if (scnc->ret != CS_SUCCEED) {
+			sybase_error_msg (_("Could not call %s while processing row resultset."),
+			                  "ct_cancel()");
+			sybase_check_messages(cnc);
+		}
+		return srecset;
+	}		
+
+	memset (&sfield->fmt, 0, sizeof(sfield->fmt));
+	sfield->fmt.namelen = 0;
+	sfield->fmt.datatype = CS_CHAR_TYPE;
+	sfield->fmt.scale = 0;
+	sfield->fmt.precision = 0;
+	sfield->fmt.status = CS_CANBENULL;
+	sfield->fmt.count = 1;
+	sfield->fmt.locale = NULL;
+
+	row = gda_row_new(GDA_DATA_MODEL(srecset), 1);
+	val = gda_row_get_value(row,0);
+
+	message = g_strdup_printf("%s",
+																											(msg.text) ? msg.text : "");
+
+	sfield->fmt.maxlength = strlen(message);
+
+	srecset->priv->rowcnt = 1;	
+ gda_value_set_string(val,(gchar *)message);
+	g_ptr_array_add(srecset->priv->rows, row);
+
+	// clear the message so we don't get bugged by it later
+	ret = ct_diag (scnc->connection, 
+																CS_CLEAR, 
+																CS_SERVERMSG_TYPE, 
+																CS_UNUSED, 
+																NULL);   
+	if ( ret != CS_SUCCEED ) { 
+			error = gda_error_new();
+			g_return_val_if_fail (error != NULL, FALSE);
+			gda_error_set_description (error, _("call to ct_diag failed when attempting to clear the server messages"));
+			gda_error_set_number (error, -1);
+			gda_error_set_source (error, "gda-sybase");
+			gda_error_set_sqlstate (error, _("Not available"));					
+			gda_connection_add_error (cnc, error);
+			return NULL;
+		} 	
+
+	return srecset;
 }
+																														
Index: gda-sybase-recordset.h
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/gda-sybase-recordset.h,v
retrieving revision 1.1
diff -u -u -r1.1 gda-sybase-recordset.h
--- gda-sybase-recordset.h	9 Dec 2002 05:45:01 -0000	1.1
+++ gda-sybase-recordset.h	28 Mar 2003 03:39:06 -0000
@@ -74,8 +74,17 @@
 };
 
 GType           gda_sybase_recordset_get_type (void);
-GdaDataModel   *gda_sybase_recordset_new (GdaConnection *cnc,
-                                          gboolean fetchall);
+
+GdaSybaseRecordset *
+gda_sybase_process_row_result (GdaConnection           *cnc,
+                               GdaSybaseConnectionData *scnc,
+                               gboolean                fetchall);
+
+
+GdaSybaseRecordset *
+gda_sybase_process_msg_result(GdaConnection *cnc,
+																														GdaSybaseConnectionData *scnc);
+
 
 G_END_DECLS
 
Index: gda-sybase-schemas.h
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/gda-sybase-schemas.h,v
retrieving revision 1.2
diff -u -u -r1.2 gda-sybase-schemas.h
--- gda-sybase-schemas.h	16 Jan 2003 00:13:29 -0000	1.2
+++ gda-sybase-schemas.h	28 Mar 2003 03:39:07 -0000
@@ -22,6 +22,7 @@
 #  define __gda_sybase_schemas_h__
 
 #if defined(HAVE_CONFIG_H)
+#  include <config.h>
 #endif
 
 #include <libgda/gda-data-model-array.h>
@@ -30,7 +31,7 @@
 G_BEGIN_DECLS
 
 #define TDS_QUERY_CURRENT_DATABASE \
-	"SELECT db_name() AS database"
+	"SELECT db_name()"
 #define TDS_QUERY_SERVER_VERSION \
 	"SELECT (@@version) AS version"
 
@@ -206,6 +207,32 @@
 	" ORDER BY name"
 
 G_END_DECLS
+
+
+#define TDS_SCHEMA_INDEXES \
+ "SELECT name from sysindexes " \
+ "order by name"
+
+
+#define TDS_FIXMODEL_SCHEMA_INDEXES(model) \
+	if (model) { \
+		gda_data_model_set_column_title (GDA_DATA_MODEL (model),  0, \
+		                                 _("Indexes")); \
+	}
+
+#define TDS_SCHEMA_TRIGGERS \
+ "SELECT name " \
+ "from sysobjects " \
+ "where type = 'TR' "\
+ "order by name"
+
+#define TDS_FIXMODEL_SCHEMA_TRIGGERS(model) \
+	if (model) { \
+		gda_data_model_set_column_title (GDA_DATA_MODEL (model),  0, \
+		                                 _("Triggers")); \
+	}
+
+
 
 #endif
 
Index: gda-sybase-types.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/gda-sybase-types.c,v
retrieving revision 1.3
diff -u -u -r1.3 gda-sybase-types.c
--- gda-sybase-types.c	3 Feb 2003 17:12:22 -0000	1.3
+++ gda-sybase-types.c	28 Mar 2003 03:39:08 -0000
@@ -26,55 +26,53 @@
  */
 
 #if defined(HAVE_CONFIG_H)
+#  include <config.h>
 #endif
 #include <string.h>
 #include "gda-sybase.h"
 #include "gda-sybase-types.h"
 
-/* NULL means we have no corresponding server type name */
-/* illegal type should always be last type */
+// NULL means we have no corresponding server type name
+// illegal type should always be last type
 const sybase_Types gda_sybase_type_list[GDA_SYBASE_TYPE_CNT] = {
-  /* Binary types */
-  { "binary",        CS_BINARY_TYPE,      GDA_VALUE_TYPE_BINARY },    /*   1 */
-  { NULL,            CS_LONGBINARY_TYPE,  GDA_VALUE_TYPE_BINARY },    /*   2 */
-  { "varbinary",     CS_VARBINARY_TYPE,   GDA_VALUE_TYPE_BINARY },    /*   3 */
-  /* Boolean types */
-  { "boolean",       CS_BIT_TYPE,         GDA_VALUE_TYPE_BOOLEAN },   /*   4 */
-  /* Character types */
-  { "char",          CS_CHAR_TYPE,        GDA_VALUE_TYPE_STRING },    /*   5 */
-  { NULL,            CS_LONGCHAR_TYPE,    GDA_VALUE_TYPE_STRING },    /*   6 */
-  { "varchar",       CS_VARCHAR_TYPE,     GDA_VALUE_TYPE_STRING },    /*   7 */
-  /* Datetime types */
-  { "datetime",      CS_DATETIME_TYPE,    GDA_VALUE_TYPE_TIMESTAMP }, /*   8 */
-  { "smalldatetime", CS_DATETIME4_TYPE,   GDA_VALUE_TYPE_TIMESTAMP }, /*   9 */
-  /* Numeric types */
-  { "tinyint",       CS_TINYINT_TYPE,     GDA_VALUE_TYPE_TINYINT },   /*  10 */
-  { "smallint",      CS_SMALLINT_TYPE,    GDA_VALUE_TYPE_SMALLINT },  /*  11 */
-  { "int",           CS_INT_TYPE,         GDA_VALUE_TYPE_INTEGER },   /*  12 */
-  { "decimal",       CS_DECIMAL_TYPE,     GDA_VALUE_TYPE_NUMERIC },   /*  13 */
-  { "numeric",       CS_NUMERIC_TYPE,     GDA_VALUE_TYPE_NUMERIC },   /*  14 */
-  { "float",         CS_FLOAT_TYPE,       GDA_VALUE_TYPE_DOUBLE },    /*  15 */
-  { "real",          CS_REAL_TYPE,        GDA_VALUE_TYPE_SINGLE },    /*  16 */
-  { "text",          CS_TEXT_TYPE,        GDA_VALUE_TYPE_STRING },    /*  17 */
-  { "image",         CS_IMAGE_TYPE,       GDA_VALUE_TYPE_BINARY },    /*  18 */
-
-  /* Security types */
-  { "boundary",      CS_BOUNDARY_TYPE,    GDA_VALUE_TYPE_BINARY },    /*  19 */
-  { "sensitivity",   CS_SENSITIVITY_TYPE, GDA_VALUE_TYPE_BINARY },    /*  20 */
-
-/* Types unsupported by gda-srv are reported as varchar and at the end
- * of this list
- */
-	/* Money types */
-  { "money",         CS_MONEY_TYPE,       GDA_VALUE_TYPE_STRING },    /*  21 */
-  { "smallmoney",    CS_MONEY4_TYPE,      GDA_VALUE_TYPE_STRING },    /*  22 */
-#if 0
-  { "money",         CS_MONEY_TYPE,       GDA_VALUE_TYPE_MONEY },     /*  23 */
-  { "smallmoney",    CS_MONEY4_TYPE,      GDA_VALUE_TYPE_MONEY },     /*  22 */
-#endif
+  // Binary types
+  { "binary",        CS_BINARY_TYPE,      GDA_VALUE_TYPE_BINARY },    //   1
+  { NULL,            CS_LONGBINARY_TYPE,  GDA_VALUE_TYPE_BINARY },    //   2
+  { "varbinary",     CS_VARBINARY_TYPE,   GDA_VALUE_TYPE_BINARY },    //   3
+  // Boolean types
+  { "boolean",       CS_BIT_TYPE,         GDA_VALUE_TYPE_BOOLEAN },   //   4
+  // Character types
+  { "char",          CS_CHAR_TYPE,        GDA_VALUE_TYPE_STRING },    //   5
+  { NULL,            CS_LONGCHAR_TYPE,    GDA_VALUE_TYPE_STRING },    //   6
+  { "varchar",       CS_VARCHAR_TYPE,     GDA_VALUE_TYPE_STRING },    //   7
+  // Datetime types
+  { "datetime",      CS_DATETIME_TYPE,    GDA_VALUE_TYPE_TIMESTAMP }, //   8
+  { "smalldatetime", CS_DATETIME4_TYPE,   GDA_VALUE_TYPE_TIMESTAMP }, //   9
+  // Numeric types
+  { "tinyint",       CS_TINYINT_TYPE,     GDA_VALUE_TYPE_TINYINT },   //  10
+  { "smallint",      CS_SMALLINT_TYPE,    GDA_VALUE_TYPE_SMALLINT },  //  11
+  { "int",           CS_INT_TYPE,         GDA_VALUE_TYPE_INTEGER },   //  12
+  { "decimal",       CS_DECIMAL_TYPE,     GDA_VALUE_TYPE_NUMERIC },   //  13
+  { "numeric",       CS_NUMERIC_TYPE,     GDA_VALUE_TYPE_NUMERIC },   //  14
+  { "float",         CS_FLOAT_TYPE,       GDA_VALUE_TYPE_DOUBLE },    //  15
+  { "real",          CS_REAL_TYPE,        GDA_VALUE_TYPE_SINGLE },    //  16
+  { "text",          CS_TEXT_TYPE,        GDA_VALUE_TYPE_STRING },    //  17
+  { "image",         CS_IMAGE_TYPE,       GDA_VALUE_TYPE_BINARY },    //  18
+
+  // Security types
+  { "boundary",      CS_BOUNDARY_TYPE,    GDA_VALUE_TYPE_BINARY },    //  19
+  { "sensitivity",   CS_SENSITIVITY_TYPE, GDA_VALUE_TYPE_BINARY },    //  20
+
+// Types unsupported by gda-srv are reported as varchar and at the end
+// of this list
+	// Money types
+  { "money",         CS_MONEY_TYPE,       GDA_VALUE_TYPE_STRING },    //  21
+  { "smallmoney",    CS_MONEY4_TYPE,      GDA_VALUE_TYPE_STRING },    //  22
+//{ "money",         CS_MONEY_TYPE,       GDA_VALUE_TYPE_MONEY },     //  23
+//{ "smallmoney",    CS_MONEY4_TYPE,      GDA_VALUE_TYPE_MONEY },     //  22
 	
 	
-  { NULL,            CS_ILLEGAL_TYPE,     GDA_VALUE_TYPE_UNKNOWN }    /*  23 */
+  { NULL,            CS_ILLEGAL_TYPE,     GDA_VALUE_TYPE_UNKNOWN }    //  23
 };
 
 
@@ -83,7 +81,6 @@
                           GdaValue *value, GdaSybaseField *field)
 {
 	GdaError   *error = NULL;
-	GdaNumeric numeric;
 	gboolean   success = FALSE;
 	
 	g_return_val_if_fail (value != NULL, FALSE);
@@ -107,13 +104,11 @@
 	}
 
 	switch (field->fmt.datatype) {
-		/* FIXME: binary datatypes */
-/*
-		case CS_BINARY_TYPE:
-		case CS_LONGBINARY_TYPE:
-		case CS_VARBINARY_TYPE:
-			break;
-*/
+		// FIXME: binary datatypes
+//		case CS_BINARY_TYPE:
+//		case CS_LONGBINARY_TYPE:
+//		case CS_VARBINARY_TYPE:
+//			break;
 		case CS_BIT_TYPE:
 			gda_value_set_boolean (value, (gboolean) *field->data);
 			return TRUE;
@@ -146,15 +141,13 @@
 			gda_value_set_integer (value, *field->data);
 			return TRUE;
 			break;
-		/* FIXME: implement numeric types */
-/*
-		case CS_DECIMAL_TYPE,
-		     CS_NUMERIC_TYPE:
-			memset (&numeric, 0, sizeof (numeric));
-
-			gda_value_set_numeric (value, numeric);
-			break;
-*/
+		// FIXME: implement numeric types
+//		case CS_DECIMAL_TYPE,
+//		     CS_NUMERIC_TYPE:
+//			memset (&numeric, 0, sizeof (numeric));
+//
+//			gda_value_set_numeric (value, numeric);
+//			break;
 		case CS_FLOAT_TYPE:
 			gda_value_set_double (value, (gdouble) *field->data);
 			return TRUE;
@@ -168,16 +161,14 @@
 			gda_value_set_string (value, field->data);
 			return TRUE;
 			break;
-		/* FIXME: implement those types */
-/*
-		case CS_IMAGE_TYPE:
-		case CS_BOUNDARY_TYPE:
-		case CS_SENSITIVITY_TYPE:
-*/
+		// FIXME: implement those types
+//		case CS_IMAGE_TYPE:
+//		case CS_BOUNDARY_TYPE:
+//		case CS_SENSITIVITY_TYPE:
 		case CS_MONEY_TYPE:
 		case CS_MONEY4_TYPE:
 		default:
-			/* try cs_convert data to CS_CHAR_TYPE */
+			// try cs_convert data to CS_CHAR_TYPE
 			success = gda_sybase_set_value_general (scnc, value,
 			                                        field);
 			break;
@@ -232,6 +223,7 @@
 		        _("data conversion failed for type %d"),
 			field->fmt.datatype);
 		gda_connection_add_error (scnc->gda_cnc, error);
+		sybase_check_messages(scnc->gda_cnc);
 		return FALSE;
 	}
 	
@@ -257,20 +249,20 @@
 		g_date_set_dmy (&date, 1, 1, 1900);
 		g_date_add_days(&date, (guint) dt->dtdays);
 
-		realhours = dt->dttime / 1080000; /* div (60 * 60 * 300) */
+		realhours = dt->dttime / 1080000; // div (60 * 60 * 300)
 		timestamp.hour = (gushort) (realhours % 24);
 
-		/* this should not happen... */
+		// this should not happen...
 		if (realhours > 23) {
 			g_date_add_days (&date, (guint) (realhours / 24));
 		}
 		remainder = dt->dttime - (realhours * 1080000);
-		timestamp.minute = (gushort) (remainder / 18000); /* (div 60*300) */
+		timestamp.minute = (gushort) (remainder / 18000); // (div 60*300)
 		remainder = remainder - (timestamp.minute * 18000);
 		timestamp.second = (gushort) (remainder / 300);
 		remainder = remainder - (timestamp.second * 300);
 		
-		/* FIXME: What is correct fraction for timestamp? */
+		// FIXME: What is correct fraction for timestamp?
 		timestamp.fraction = remainder / 3;
 		
 		timestamp.year = g_date_get_year (&date);
@@ -304,7 +296,7 @@
 		timestamp.hour = (gushort) realhours % 24;
 		timestamp.minute = (gushort) (dt4->minutes - (realhours * 60));
 		
-		/* this should not happen... */
+		// this should not happen...
 		if (realhours > 23) {
 			g_date_add_days (&date, (guint) (realhours / 24));
 		}
Index: gda-sybase-types.h
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/gda-sybase-types.h,v
retrieving revision 1.3
diff -u -u -r1.3 gda-sybase-types.h
--- gda-sybase-types.h	3 Feb 2003 17:12:22 -0000	1.3
+++ gda-sybase-types.h	28 Mar 2003 03:39:08 -0000
@@ -29,6 +29,7 @@
 #  define __gda_sybase_types_h__
 
 #if defined(HAVE_CONFIG_H)
+#  include <config.h>
 #endif
 #include <string.h>
 #include "gda-sybase.h"
@@ -44,7 +45,7 @@
   gchar            *name;
   CS_INT           sql_type;
   GdaValueType     gda_type;
-/*  sybase_conv_Func conv_sql2gda; */
+//  sybase_conv_Func conv_sql2gda;
 } sybase_Types;
 
 #define GDA_SYBASE_TYPE_CNT 23
Index: gda-sybase.h
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/gda-sybase.h,v
retrieving revision 1.9
diff -u -u -r1.9 gda-sybase.h
--- gda-sybase.h	3 Feb 2003 17:12:22 -0000	1.9
+++ gda-sybase.h	28 Mar 2003 03:39:08 -0000
@@ -29,38 +29,21 @@
 #  define __gda_sybase_h__
 
 #if defined(HAVE_CONFIG_H)
+#  include <config.h>
 #endif
 
 #include <glib/gmacros.h>
 #include <libgda/gda-intl.h>
 #include <libgda/gda-server-provider.h>
-
 #include <ctpublic.h>
 #include <cspublic.h>
-
 #include "gda-sybase-provider.h"
-
-/* share schema queries with freetds provider */
-/* #include "../freetds/gda-tds-schemas.h" */
 #include "gda-sybase-schemas.h"
 
 #define GDA_SYBASE_PROVIDER_ID		"GDA sybase provider"
 
 G_BEGIN_DECLS
 
-typedef struct _sybaseError
-{
-		gchar *error_msg;
-} sybase_error;
-
-
-typedef struct _sybaseConnection
-{
-		CS_CONTEXT    *context;
-		CS_CONNECTION *connection;
-		sybase_error err;
-} sybase_connection; 
-
 #define PARENT_TYPE GDA_TYPE_SERVER_PROVIDER
 #define OBJECT_DATA_SYBASE_HANDLE "GDA_Sybase_SybaseHandle"
 #define GDA_SYBASE_COMPONENT_FACTORY_ID "OAFIID:GNOME_Database_Sybase_ComponentFactory"
@@ -69,24 +52,6 @@
  * Utility functions
  */
 
-/*
-GdaError *gda_sybase_make_error (sybase_connection *);
-
-gboolean sybase_check_messages(GdaServerConnection *);
-
-gboolean sybase_check_clientmsg(GdaServerConnection *);
-
-gboolean sybase_check_servermsg(GdaServerConnection *);
-
-gboolean sybase_check_cmsg(GdaServerConnection *);
-
-gchar *sprintf_clientmsg(const gchar *, 
-																									CS_CLIENTMSG *);
-
-gchar *sprintf_servermsg(const gchar *,
-																									CS_SERVERMSG *);
-*/
-
 gboolean sybase_check_messages(GdaConnection *cnc);
 
 CS_RETCODE CS_PUBLIC gda_sybase_csmsg_callback (CS_CONTEXT *context,
@@ -102,7 +67,6 @@
 
 void sybase_debug_msg(gchar *fmt, ...);
 void sybase_error_msg(gchar *fmt, ...);
-
 
 G_END_DECLS
 
Index: libmain.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/libmain.c,v
retrieving revision 1.3
diff -u -u -r1.3 libmain.c
--- libmain.c	18 Jan 2003 14:19:45 -0000	1.3
+++ libmain.c	28 Mar 2003 03:39:08 -0000
@@ -37,7 +37,7 @@
 const gchar *
 plugin_get_description (void)
 {
-	return _("Provider for sybase databases (using OpenClient)");
+	return _("GDA provider for sybase databases (using OpenClient)");
 }
 
 GList *
Index: main.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/main.c,v
retrieving revision 1.5
diff -u -u -r1.5 main.c
--- main.c	16 Jan 2003 00:13:29 -0000	1.5
+++ main.c	28 Mar 2003 03:39:08 -0000
@@ -23,6 +23,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include <config.h>
 #include <bonobo/bonobo-i18n.h>
 #include "libgda/libgda.h"
 #include "gda-sybase.h"
Index: utils.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/sybase/utils.c,v
retrieving revision 1.7
diff -u -u -r1.7 utils.c
--- utils.c	3 Feb 2003 17:12:22 -0000	1.7
+++ utils.c	28 Mar 2003 03:39:09 -0000
@@ -23,6 +23,7 @@
 
 
 #if defined(HAVE_CONFIG_H)
+#  include <config.h>
 #endif
 
 #include <libgda/gda-log.h>
@@ -31,6 +32,16 @@
 
 #include "gda-sybase.h"
 
+
+G_BEGIN_DECLS
+                             
+gboolean sybase_add_server_errors_to_list(GdaConnection *cnc);
+gboolean sybase_add_client_errors_to_list(GdaConnection *cnc);
+gboolean sybase_make_errors_from_list(GdaConnection *cnc);
+gboolean sybase_add_cmsg_errors_to_list(GdaConnection *cnc);
+
+G_END_DECLS
+
 CS_RETCODE CS_PUBLIC
 gda_sybase_csmsg_callback(CS_CONTEXT *context, CS_CLIENTMSG *msg)
 {
@@ -101,9 +112,14 @@
 gboolean
 sybase_check_messages(GdaConnection *cnc)
 {
+	/* when inline error handling is enabled, this function */
+	/* will return TRUE if there are any messages where generated */
+	/* by open client or the server. */
+
+
 	GdaSybaseConnectionData *sconn;
 	
-	CS_CLIENTMSG msg;
+	//	CS_CLIENTMSG msg;
 	CS_INT       msgcnt = 0;
 	CS_INT       msgcur = 0;
 
@@ -119,12 +135,13 @@
 		                       CS_ALLMSG_TYPE, 
 		                       CS_UNUSED,
 		                       &msgcnt);
-	} else {
+	} 
+	else {
 		sconn->mret = cs_diag (sconn->context,
 		                       CS_STATUS,
-				       CS_CLIENTMSG_TYPE,
-				       CS_UNUSED,
-				       &msgcnt);
+																									CS_CLIENTMSG_TYPE,
+																									CS_UNUSED,
+																									&msgcnt);
 	}
 	if (sconn->mret != CS_SUCCEED) {
 		sybase_debug_msg (_("ct_diag() failed determining # of client messages."));
@@ -135,8 +152,362 @@
 		msgcur++;
 	}
 
-	sybase_debug_msg (_("%d messages fetched."), msgcnt);
-	return TRUE;
+	//sybase_debug_msg (_("%d messages fetched."), msgcnt);
+
+	/* add any messages to the GdaConnection error list*/
+	/* there are some messages we can safely ignore, so */
+	/* use the return of sybase_make_errors_from_list() */
+	/* to determine if there was an error or not */
+	return (sybase_make_errors_from_list(cnc));
+}
+
+gboolean sybase_make_errors_from_list(GdaConnection *cnc)
+{
+	gboolean cmsg_errors = FALSE;
+	gboolean server_errors = FALSE;
+	gboolean client_errors = FALSE;
+
+	cmsg_errors = sybase_add_cmsg_errors_to_list(cnc);
+	client_errors = sybase_add_client_errors_to_list(cnc);
+	server_errors = sybase_add_server_errors_to_list(cnc);
+
+	if ( cmsg_errors || server_errors || client_errors ) 
+		return TRUE;
+	else
+		return FALSE;
+}
+
+gboolean sybase_add_cmsg_errors_to_list(GdaConnection *cnc)
+{
+	CS_RETCODE ret; 
+	CS_INT msgcnt = 0; 
+	CS_INT msgcur = 0; 
+	CS_CLIENTMSG msg; 
+	char *tempspace = NULL; 
+	GdaError *error;
+	gboolean returner = FALSE;
+	GdaSybaseConnectionData *sconn;
+
+	sconn = g_object_get_data (G_OBJECT (cnc), OBJECT_DATA_SYBASE_HANDLE);
+	g_return_val_if_fail (sconn != NULL, FALSE);
+
+	ret = cs_diag (sconn->context, 
+																CS_STATUS, 
+																CS_CLIENTMSG_TYPE, 
+																CS_UNUSED, 
+																&msgcnt);   
+	if ( ret != CS_SUCCEED ) { 
+		error = gda_error_new();
+		g_return_val_if_fail (error != NULL, FALSE);
+		gda_error_set_description (error, _("call to cs_diag failed when attempting to the amount of client messages"));
+		gda_error_set_number (error, -1);
+		gda_error_set_source (error, "gda-sybase");
+		gda_error_set_sqlstate (error, _("Not available"));					
+		gda_connection_add_error (cnc, error);
+		return TRUE;
+	} 
+	while ( msgcur < msgcnt ) { 
+		msgcur++;            
+		ret = cs_diag (sconn->context, 
+																	CS_GET, 
+																	CS_CLIENTMSG_TYPE, 
+																	msgcur, 
+																	&msg); 
+		if ( ret != CS_SUCCEED ) 
+			{ 
+				error = gda_error_new();
+				g_return_val_if_fail (error != NULL, FALSE);
+				gda_error_set_description (error, _("an error occured when calling cs_diag attempting to retrieve a client message"));
+				gda_error_set_number (error, -1);
+				gda_error_set_source (error, "gda-sybase");
+				gda_error_set_sqlstate (error, _("Not available"));					
+				gda_connection_add_error (cnc, error);
+				return TRUE;
+			} 
+		else { 
+			if (msg.osstringlen > 0) {
+				tempspace = g_strdup_printf("%s %ld %s %s",
+																																_("OS_Error:("),
+																																msg.osnumber,
+																																_(") Message: "),
+																																msg.osstring);
+				error = gda_error_new();
+				g_return_val_if_fail (error != NULL, FALSE);
+				gda_error_set_description (error,tempspace);
+				gda_error_set_number (error, -1);
+				gda_error_set_source (error, "gda-sybase");
+				gda_error_set_sqlstate (error, _("Not available"));					
+				gda_connection_add_error (cnc, error);
+				returner = TRUE;
+			}
+			else {
+				tempspace = g_strdup_printf("%s %ld %s %ld %s %ld %s %ld : %s",
+																																_("Sybase OpenClient Msg: severity("),
+																																(long) CS_SEVERITY(msg.severity), 																																		
+																																_("), number("),
+																																(long) CS_NUMBER(msg.msgnumber),
+																																_("), origin("),
+																																(long) CS_ORIGIN(msg.msgnumber), 
+																																_("), layer("),
+																																(long) CS_LAYER(msg.msgnumber),
+																																(msg.msgstring) ? msg.msgstring : "");
+				error = gda_error_new();
+				g_return_val_if_fail (error != NULL, FALSE);
+				gda_error_set_description (error,tempspace);
+				gda_error_set_number (error, -1);
+				gda_error_set_source (error, "gda-sybase");
+				gda_error_set_sqlstate (error, _("Not available"));					
+				gda_connection_add_error (cnc, error);
+				returner = TRUE;
+			} 
+		}
+	} 
+	g_free((gpointer)tempspace); 
+
+	if ( returner ) {
+		ret = cs_diag (sconn->context, 
+																	CS_CLEAR, 
+																	CS_CLIENTMSG_TYPE, 
+																	CS_UNUSED, 
+																	NULL);   
+		if ( ret != CS_SUCCEED ) { 
+			error = gda_error_new();
+			g_return_val_if_fail (error != NULL, FALSE);
+			gda_error_set_description (error, _("call to cs_diag failed when attempting to clear the client messages"));
+			gda_error_set_number (error, -1);
+			gda_error_set_source (error, "gda-sybase");
+			gda_error_set_sqlstate (error, _("Not available"));					
+			gda_connection_add_error (cnc, error);
+			return TRUE;
+		} 
+	}
+	return returner; 
+}
+
+gboolean sybase_add_server_errors_to_list(GdaConnection *cnc)
+{
+	CS_RETCODE ret; 
+	CS_INT msgcnt = 0; 
+	CS_INT msgcur = 0; 
+	char *error_msg;
+	CS_SERVERMSG msg; 
+	char *servername = NULL; 
+	char *procname = NULL; 
+	char *messagenumber = NULL; 
+	char *severity = NULL; 
+	char *state = NULL; 
+	char *line = NULL; 
+	gboolean returner = FALSE;
+	gboolean stupid_5701_message = FALSE;
+	GdaSybaseConnectionData *sconn;
+	GdaError *error;
+	
+
+	sconn = g_object_get_data (G_OBJECT (cnc), OBJECT_DATA_SYBASE_HANDLE);
+	g_return_val_if_fail (sconn != NULL, FALSE);
+
+	ret = ct_diag (sconn->connection, 
+																CS_STATUS, 
+																CS_SERVERMSG_TYPE, 
+																CS_UNUSED, 
+																&msgcnt);   
+	if ( ret != CS_SUCCEED ) { 
+		error = gda_error_new();
+		g_return_val_if_fail (error != NULL, FALSE);
+		gda_error_set_description (error, _("call to ct_diag failed when attempting to the amount of server messages"));
+		gda_error_set_number (error, -1);
+		gda_error_set_source (error, "gda-sybase");
+		gda_error_set_sqlstate (error, _("Not available"));					
+		gda_connection_add_error (cnc, error);
+		return TRUE;			
+	} 
+	while ( msgcur < msgcnt ) { 
+		msgcur++;            
+		ret = ct_diag (sconn->connection, 
+																	CS_GET, 
+																	CS_SERVERMSG_TYPE, 
+																	msgcur, 
+																	&msg); 
+		if ( ret != CS_SUCCEED ) { 
+			error = gda_error_new();
+			g_return_val_if_fail (error != NULL, FALSE);
+			gda_error_set_description (error, _("an error occured when calling ct_diag attempting to retrieve a server message"));
+			gda_error_set_number (error, -1);
+			gda_error_set_source (error, "gda-sybase");
+			gda_error_set_sqlstate (error, _("Not available"));					
+			gda_connection_add_error (cnc, error);
+			return TRUE;					
+		} 
+		else { 
+			if ( msg.msgnumber != 5701 ) {
+				returner = TRUE;
+				if (msg.svrnlen > 0) 
+					servername = g_strdup_printf("%s %s",
+																																		_("Server:"),
+																																		msg.svrname); 
+				if (msg.proclen > 0) 
+					procname = g_strdup_printf("%s %s",
+																																_("Stored Procedure:"),
+																																msg.proc);
+					
+				messagenumber = g_strdup_printf("%s (%ld)",
+																																				_("Number"),
+																																				msg.msgnumber); 
+				severity = g_strdup_printf("%s (%ld)",
+																															_("Severity"),
+																															msg.severity); 
+				state = g_strdup_printf("%s (%ld)",
+																												_("State"),
+																												msg.state); 
+				line = g_strdup_printf("%s (%ld)",
+																											_("Line"),
+																											msg.line);
+				if ( procname)
+					error_msg = 
+						g_strdup_printf("Sybase Server Message:%s %s %s %s %s %s %s", 
+																						servername, 
+																						severity, 
+																						state, 
+																						procname, 
+																						messagenumber, 
+																						line,
+																						msg.text);           
+				else
+					error_msg = 
+						g_strdup_printf("Sybase Server Message:%s %s %s %s %s %s", 
+																						servername, 
+																						severity, 
+																						state, 
+																						messagenumber, 
+																						line,
+																						msg.text);           
+				error = gda_error_new();
+				g_return_val_if_fail (error != NULL, FALSE);
+				gda_error_set_description (error, error_msg);
+				gda_error_set_number (error, -1);
+				gda_error_set_source (error, "gda-sybase");
+				gda_error_set_sqlstate (error, _("Not available"));					
+				gda_connection_add_error (cnc, error);
+			}
+			else
+				stupid_5701_message = TRUE;
+		} 
+	} 
+	g_free((gpointer)servername); 
+	g_free((gpointer)procname); 
+	g_free((gpointer)messagenumber); 
+	g_free((gpointer)severity); 
+	g_free((gpointer)state); 
+	g_free((gpointer)line); 
+
+	if ( ( returner ) || ( stupid_5701_message ) ) {
+		ret = ct_diag (sconn->connection, 
+																	CS_CLEAR, 
+																	CS_SERVERMSG_TYPE, 
+																	CS_UNUSED, 
+																	NULL);   
+		if ( ret != CS_SUCCEED ) { 
+			error = gda_error_new();
+			g_return_val_if_fail (error != NULL, FALSE);
+			gda_error_set_description (error, _("call to ct_diag failed when attempting to clear the server messages"));
+			gda_error_set_number (error, -1);
+			gda_error_set_source (error, "gda-sybase");
+			gda_error_set_sqlstate (error, _("Not available"));					
+			gda_connection_add_error (cnc, error);
+			return TRUE;
+		} 
+	}
+	return returner; 
+}
+
+gboolean sybase_add_client_errors_to_list(GdaConnection *cnc)
+{
+	CS_RETCODE ret; 
+	CS_INT msgcnt = 0; 
+	CS_INT msgcur = 0; 
+	CS_CLIENTMSG msg; 
+	char *tempspace = NULL; 
+	GdaSybaseConnectionData *sconn;
+	GdaError *error;
+	gboolean returner= FALSE;
+
+	sconn = g_object_get_data (G_OBJECT (cnc), OBJECT_DATA_SYBASE_HANDLE);
+	g_return_val_if_fail (sconn != NULL, FALSE);
+
+
+	ret = ct_diag (sconn->connection, 
+																CS_STATUS, 
+																CS_CLIENTMSG_TYPE, 
+																CS_UNUSED, 
+																&msgcnt);   
+	if ( ret != CS_SUCCEED ) { 
+		error = gda_error_new();
+		g_return_val_if_fail (error != NULL, FALSE);
+		gda_error_set_description (error, _("call to ct_diag failed when attempting to the amount of client messages"));
+		gda_error_set_number (error, -1);
+		gda_error_set_source (error, "gda-sybase");
+		gda_error_set_sqlstate (error, _("Not available"));					
+		gda_connection_add_error (cnc, error);
+		return TRUE;			
+	} 
+	while ( msgcur < msgcnt ) { 
+		msgcur++;            
+		ret = ct_diag (sconn->connection, 
+																	CS_GET, 
+																	CS_CLIENTMSG_TYPE, 
+																	msgcur, 
+																	&msg); 
+		if ( ret != CS_SUCCEED ) { 
+			error = gda_error_new();
+			g_return_val_if_fail (error != NULL, FALSE);
+			gda_error_set_description (error, _("an error occured when calling ct_diag attempting to retrieve a client message"));
+			gda_error_set_number (error, -1);
+			gda_error_set_source (error, "gda-sybase");
+			gda_error_set_sqlstate (error, _("Not available"));					
+			gda_connection_add_error (cnc, error);
+			return TRUE;					
+		} 
+		else { 
+			returner = TRUE;
+
+			tempspace = g_strdup_printf("%s %ld %s %ld %s %ld %s %ld : %s %s",
+																															_("Severity"),
+																															(long) CS_SEVERITY (msg.msgnumber),
+																															_("Layer"),
+																															(long) CS_LAYER (msg.msgnumber),
+																															_("Origin"),
+																															(long) CS_ORIGIN (msg.msgnumber),
+																															_("Message Number"),
+																															(long) CS_NUMBER (msg.msgnumber),
+																															msg.msgstring,
+																															msg.osstring);
+			error = gda_error_new();
+			g_return_val_if_fail (error != NULL, FALSE);
+			gda_error_set_description (error, tempspace);
+			gda_error_set_number (error, -1);
+			gda_error_set_source (error, "gda-sybase");
+			gda_error_set_sqlstate (error, _("Not available"));					
+			gda_connection_add_error (cnc, error);					
+		} 
+	} 
+
+	ret = ct_diag (sconn->connection, 
+																CS_CLEAR, 
+																CS_CLIENTMSG_TYPE, 
+																CS_UNUSED, 
+																NULL);   
+	if ( ret != CS_SUCCEED ) { 
+		error = gda_error_new();
+		g_return_val_if_fail (error != NULL, FALSE);
+		gda_error_set_description (error, _("call to ct_diag failed when attempting to clear the client messages"));
+		gda_error_set_number (error, -1);
+		gda_error_set_source (error, "gda-sybase");
+		gda_error_set_sqlstate (error, _("Not available"));					
+		gda_connection_add_error (cnc, error);
+		return TRUE;
+	} 
+
+	return returner; 
 }
 
 GdaError *
@@ -149,8 +520,8 @@
 
 	if (scnc != NULL) {
 		switch (scnc->ret) {
-			case CS_BUSY:	sybase_error_msg(_("Operation not possible, connection busy."));
-					break;
+		case CS_BUSY:	sybase_error_msg(_("Operation not possible, connection busy."));
+			break;
 		}
 	}
 	
@@ -162,7 +533,8 @@
 			va_end(args);
 
 			gda_error_set_description (error, fmt);
-		} else {
+		} 
+		else {
 			gda_error_set_description (error, _("NO DESCRIPTION"));
 		}
 
@@ -177,8 +549,8 @@
 void
 sybase_debug_msg(gchar *fmt, ...)
 {
-/* FIXME: remove comment after reviewing error code */
-/* #ifdef SYBASE_DEBUG */
+	// FIXME: remove comment after reviewing error code
+	//#ifdef SYBASE_DEBUG
 	va_list args;
 	const size_t buf_size = 4096;
 	char buf[buf_size + 1];
@@ -188,8 +560,8 @@
 	va_end(args);
 	
 	gda_log_message("Sybase: %s", buf);
-/* FIXME: remove comment after reviewing error code */
-/* #endif */
+	// FIXME: remove comment after reviewing error code
+	//#endif
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]