/* * * ProLinga-Data * * Copyright (C) 2002-2008 Xobas Software. * All rights reserved. * * This file is part of ProLinga-Data. * * ProLinga-Data is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ProLinga-Data is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ProLinga-Data. If not, see . * * More information is available at the following addresses: * * Website : http://www.prolinga.org * * Email : prolinga-list@prolinga.org * * */ #include "DatCommon.h" #include "DatMain.hpp" #include "ExecuteSql.hpp" #include GdaDataModel *ExecuteSqlDataModelCommand(GdaConnection *connection, const gchar * buffer, DCSessionPtr sesPtr, const char *sessionId) { GdaCommand *command; // GdaTransaction *trans; GdaDataModel *dm; /* Create and Execute Command */ command = gda_command_new(buffer, GDA_COMMAND_TYPE_TABLE, GDA_COMMAND_OPTION_STOP_ON_ERRORS); /* Check if part of transaction */ // trans = sesPtr->getTransaction(sesPtr, sessionId); // if (trans != NULL) // gda_command_set_transaction(command, trans); /* Execute command */ dm = gda_connection_execute_select_command(connection, command, NULL, NULL); /* Clean up */ gda_command_free(command); /* Return */ return dm; } GdaDataModel *ExecuteSqlSingleCommand(GdaConnection *connection, const gchar *buffer, DCSessionPtr sesPtr, const char *sessionId) { GdaCommand *command; // GdaTransaction *trans; GdaDataModel *dm; GError *error = NULL; /* Create and Execute Command */ command = gda_command_new(buffer, GDA_COMMAND_TYPE_SQL, GDA_COMMAND_OPTION_STOP_ON_ERRORS); /* Check if part of transaction */ // trans = sesPtr->getTransaction(sesPtr, sessionId); // if (trans != NULL) // gda_command_set_transaction(command, trans); /* Execute command */ dm = gda_connection_execute_select_command(connection, command, NULL, &error); if (error != NULL) { g_error_free(error); dm = NULL; } /* Clean up */ gda_command_free(command); /* Return */ return dm; } gint ExecuteSqlNonQuery (GdaConnection *connection, const gchar *buffer, DCSessionPtr sesPtr, const char *sessionId) { GdaCommand *command; // GdaTransaction *trans; gint number = 0; // GList *recList, *list; // GdaDataModel *dataModel; // GError *error = 0; /* Generate and process command */ command = gda_command_new (buffer, GDA_COMMAND_TYPE_SQL, GDA_COMMAND_OPTION_STOP_ON_ERRORS); /* Check if part of transaction */ // trans = sesPtr->getTransaction(sesPtr, sessionId); // if (trans != NULL) // { // gda_command_set_transaction(command, trans); // printf("NOT NULL %s - %d\n", sessionId, trans); // } // else // printf("NULL %s \n", sessionId); /* Execute command */ //number = gda_connection_execute_non_query (connection, command, NULL, NULL); number = gda_connection_execute_non_select_command (connection, command, NULL, NULL); //printf("NUMBER !!!!!!!!! %d\n", number); // recList = gda_connection_execute_command_l (connection, command, NULL, &error); // if (!recList) // return -1; // // if (error == NULL) // return 0; //{ // printf("ERROR: %s\n", error->message); // g_error_free (error); //} // dataModel = (GdaDataModel *) recList->data; // if (GDA_IS_DATA_MODEL (dataModel)) // number = gda_data_model_get_n_rows (dataModel); // // list = recList; // for (list = recList; list; list = g_list_next (list)) // if (list->data) // g_object_unref (list->data); // // g_list_free (recList); /* Clean up */ gda_command_free (command); /* Return */ return (number); }