[anjuta] symbol-db: Added direct sql execution functions in SymbolDBEngine



commit 923c20d1d62a5ce6e4c4b04e77c80e2caff9c440
Author: Naba Kumar <naba gnome org>
Date:   Wed Apr 7 23:17:46 2010 +0300

    symbol-db: Added direct sql execution functions in SymbolDBEngine

 plugins/symbol-db/symbol-db-engine-core.c |   40 +++++++++++++++++++++++++++++
 plugins/symbol-db/symbol-db-engine-core.h |   12 ++++++++
 2 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/plugins/symbol-db/symbol-db-engine-core.c b/plugins/symbol-db/symbol-db-engine-core.c
index 059cf65..f66340b 100644
--- a/plugins/symbol-db/symbol-db-engine-core.c
+++ b/plugins/symbol-db/symbol-db-engine-core.c
@@ -6500,3 +6500,43 @@ symbol_db_engine_set_db_case_sensitive (SymbolDBEngine *dbe, gboolean case_sensi
 	else 
 		sdb_engine_execute_unknown_sql (dbe, "PRAGMA case_sensitive_like = 0");
 }
+
+GdaStatement*
+symbol_db_engine_get_statement (SymbolDBEngine *dbe, const gchar *sql_str)
+{
+	GdaStatement* stmt;
+	GError *error = NULL;
+	
+	g_return_val_if_fail (SYMBOL_IS_DB_ENGINE (dbe), NULL);
+	stmt = gda_sql_parser_parse_string (dbe->priv->sql_parser,
+	                                    sql_str,
+	                                    NULL, &error);
+	if (error)
+	{
+		g_warning ("SQL parsing failed: %s: %s", sql_str, error->message);
+		g_error_free (error);
+	}
+	return stmt;
+}
+
+GdaDataModel*
+symbol_db_engine_execute_select (SymbolDBEngine *dbe, GdaStatement *stmt,
+                                 GdaSet *params)
+{
+	GdaDataModel *res;
+	GError *error = NULL;
+	
+	res = gda_connection_statement_execute_select (dbe->priv->db_connection, 
+												   stmt, params, &error);
+	if (error)
+	{
+		gchar *sql_str =
+			gda_statement_to_sql_extended (stmt, dbe->priv->db_connection,
+			                               params, 0, NULL, NULL);
+
+		g_warning ("SQL select exec failed: %s, %s", sql_str, error->message);
+		g_free (sql_str);
+		g_error_free (error);
+	}
+	return res;
+}
diff --git a/plugins/symbol-db/symbol-db-engine-core.h b/plugins/symbol-db/symbol-db-engine-core.h
index 36ea09d..978e2a5 100644
--- a/plugins/symbol-db/symbol-db-engine-core.h
+++ b/plugins/symbol-db/symbol-db-engine-core.h
@@ -269,6 +269,18 @@ symbol_db_engine_update_buffer_symbols (SymbolDBEngine * dbe, const gchar * proj
 void
 symbol_db_engine_set_db_case_sensitive (SymbolDBEngine *dbe, gboolean case_sensitive);
 
+/**
+ * Compiles an sql statement
+ */
+GdaStatement*
+symbol_db_engine_get_statement (SymbolDBEngine *dbe, const gchar *sql_str);
+
+/**
+ * Executes a parameterized sql statement
+ */
+GdaDataModel*
+symbol_db_engine_execute_select (SymbolDBEngine *dbe, GdaStatement *stmt,
+                                 GdaSet *params);
 
 G_END_DECLS
 



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