summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/firebird/FStatement.cxx
diff options
context:
space:
mode:
authorJavier Fernandez <jfernandez@igalia.com>2013-05-22 08:56:23 +0000
committerJavier Fernandez <jfernandez@igalia.com>2013-06-06 09:37:41 +0000
commit358b46a56df542226021af2c347595354e457684 (patch)
tree84663243e74d96b8412a04d3726bc5ecb2793dfe /connectivity/source/drivers/firebird/FStatement.cxx
parenta19f942743b83a1a4f654131b67b3d608b80103a (diff)
Debug info and some API methods implementation.
* getTypeInfo * getTables * prepared statements. Change-Id: I549f4a9468b5346e22479363fe0fb81039bc6665
Diffstat (limited to 'connectivity/source/drivers/firebird/FStatement.cxx')
-rw-r--r--connectivity/source/drivers/firebird/FStatement.cxx70
1 files changed, 69 insertions, 1 deletions
diff --git a/connectivity/source/drivers/firebird/FStatement.cxx b/connectivity/source/drivers/firebird/FStatement.cxx
index 153b99352818..53452703850b 100644
--- a/connectivity/source/drivers/firebird/FStatement.cxx
+++ b/connectivity/source/drivers/firebird/FStatement.cxx
@@ -46,6 +46,8 @@
#include <cppuhelper/typeprovider.hxx>
#include "propertyids.hxx"
+#include <ibase.h>
+
using namespace connectivity::firebird;
//------------------------------------------------------------------------------
using namespace com::sun::star::uno;
@@ -151,18 +153,84 @@ sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(S
}
// -------------------------------------------------------------------------
+/*
+ * Print the status, the SQLCODE, and exit.
+ * Also, indicate which operation the error occured on.
+ */
+static int pr_error (long* status, char* operation)
+{
+ printf("[\n");
+ printf("PROBLEM ON \"%s\".\n", operation);
+
+ isc_print_status(status);
+
+ printf("SQLCODE:%d\n", isc_sqlcode(status));
+
+ printf("]\n");
+
+ return 1;
+}
+
Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
{
+ char sqlStr[128];
+ strcpy(sqlStr, OUStringToOString( sql, RTL_TEXTENCODING_ASCII_US ).getStr());
+ printf("DEBUG !!! connectivity.firebird => OStatement_Base::executeQuery() got called with sql: %s \n", sqlStr);
+
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
-
Reference< XResultSet > xRS = NULL;
// create a resultset as result of executing the sql statement
// you have to here something :-)
+
+ ISC_STATUS_ARRAY status; /* status vector */
+ isc_db_handle db = NULL; /* database handle */
+ isc_tr_handle trans = NULL; /* transaction handle */
+ isc_stmt_handle stmt = NULL; /* prepared statement handle */
+ XSQLDA * sel_sqlda;
+ int CURRENLEN = 10;
+ char orig_name[CURRENLEN + 1];
+
+ if (isc_attach_database(status, 0, "new.fdb", &db, 0, NULL))
+ if (pr_error(status, "attach database"))
+ return xRS;
+
+ if (isc_start_transaction(status, &trans, 1, &db, 0, NULL))
+ if (pr_error(status, "start transaction"))
+ return xRS;
+
+ sel_sqlda = (XSQLDA *) malloc(XSQLDA_LENGTH(1));
+ sel_sqlda->sqln = 1;
+ sel_sqlda->version = 1;
+
+ if (isc_dsql_allocate_statement(status, &db, &stmt))
+ if (pr_error(status, "allocate statement"))
+ return xRS;
+ if (isc_dsql_prepare(status, &trans, &stmt, 0, sqlStr, 1, sel_sqlda))
+ if (pr_error(status, "prepare statement"))
+ return xRS;
+
+ sel_sqlda->sqlvar[0].sqldata = orig_name;
+ sel_sqlda->sqlvar[0].sqltype = SQL_TEXT;
+ sel_sqlda->sqlvar[0].sqllen = CURRENLEN;
+
+ if (isc_dsql_execute(status, &trans, &stmt, 1, NULL))
+ if (pr_error(status, "execute query"))
+ return xRS;
+ if (isc_dsql_fetch(status, &stmt, 1, sel_sqlda))
+ if (pr_error(status, "fetch data"))
+ return xRS;
+
+ if (isc_commit_transaction (status, &trans))
+ isc_print_status(status);
+ printf("DEBuG !!! connectivity.firebird => OStatement_Base::executeQuery() Changes committed.\n");
+
m_xResultSet = xRS; // we nedd a reference to it for later use
return xRS;
}
+
+
// -------------------------------------------------------------------------
Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLException, RuntimeException)