Date: Wednesday, January 25, 2006 @ 23:41:15
Author: marc
Path: /cvsroot/carob/carob
Modified: include/DriverResultSet.hpp (1.28 -> 1.29)
src/DriverResultSet.cpp (1.34 -> 1.35)
quick partial implementation of getAsFloat() (needed for HSQL testing)
-----------------------------+
include/DriverResultSet.hpp | 14 ++++++++++++++
src/DriverResultSet.cpp | 22 ++++++++++++++++++++++
2 files changed, 36 insertions(+)
Index: carob/include/DriverResultSet.hpp
diff -u carob/include/DriverResultSet.hpp:1.28
carob/include/DriverResultSet.hpp:1.29
--- carob/include/DriverResultSet.hpp:1.28 Tue Jan 24 19:37:27 2006
+++ carob/include/DriverResultSet.hpp Wed Jan 25 23:41:15 2006
@@ -235,6 +235,20 @@
NullValueException, NotImplementedException,
UnexpectedException);
/**
+ * Tries to get the value of a column in the current row as a
+ * float. If the value at the given row/col is not of type float or
+ * double, miserably fails TODO.
+ *
+ * @param columnIndex the first column is 1, the second is 2,...
+ * @return the column value; NULL if SQL NULL
+ * @throw DriverException if the ResultSet is closed or the cursor is out of
+ * bounds
+ * @throw NullValueException if the retrieved value is NULL
+ */
+ float getAsFloat(int columnIndex) throw
(DriverException,
+ NullValueException, NotImplementedException,
+ UnexpectedException);
+ /**
* Gets the double value of a column in the current row only if the
* given column is of double type, throws an exception otherwise.
*
Index: carob/src/DriverResultSet.cpp
diff -u carob/src/DriverResultSet.cpp:1.34 carob/src/DriverResultSet.cpp:1.35
--- carob/src/DriverResultSet.cpp:1.34 Tue Jan 24 18:54:51 2006
+++ carob/src/DriverResultSet.cpp Wed Jan 25 23:41:15 2006
@@ -497,6 +497,28 @@
return ((data[currentRow])[columnIndex - 1]).as_float;
}
+float DriverResultSet::getAsFloat(int columnIndex) throw (DriverException,
+ NullValueException, NotImplementedException, UnexpectedException)
+{
+ checkRowAndColPosAndSetNullFlag(columnIndex);
+
+ if (wasNullFlag)
+ {
+ throw (NullValueException(L"getAsFloat: Value at row " +
toWString(currentRow)
+ + L" column " + toWString(columnIndex) + L" is NULL"));
+ }
+
+ switch (columnTypeTags[columnIndex - 1])
+ {
+ case TT_FLOAT:
+ return ((data[currentRow])[columnIndex - 1]).as_float;
+ case TT_DOUBLE:
+ return static_cast<float>(data[currentRow][columnIndex - 1].as_double);
+ default: // TODO
+ throw NotImplementedException(L"float conversion not implemented for
this type yet.");
+ }
+}
+
double DriverResultSet::getDouble(int columnIndex) throw (DriverException,
NullValueException, NotImplementedException, UnexpectedException)
{
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits