Date: Wednesday, December 14, 2005 @ 18:23:44
Author: gilles
Path: /cvsroot/carob/carob
Modified: include/DriverResultSet.hpp (1.21 -> 1.22)
src/DriverResultSet.cpp (1.22 -> 1.23)
Throw NullValueException when retrieving a NULL value in DriverResultSet getInt
and getString functions
-----------------------------+
include/DriverResultSet.hpp | 8 ++++++--
src/DriverResultSet.cpp | 19 ++++++++++---------
2 files changed, 16 insertions(+), 11 deletions(-)
Index: carob/include/DriverResultSet.hpp
diff -u carob/include/DriverResultSet.hpp:1.21
carob/include/DriverResultSet.hpp:1.22
--- carob/include/DriverResultSet.hpp:1.21 Tue Dec 13 18:18:51 2005
+++ carob/include/DriverResultSet.hpp Wed Dec 14 18:23:43 2005
@@ -139,9 +139,11 @@
* @return the column value, null for SQL NULL
* @exception DriverException if the ResultSet is closed or the cursor is
* out of bounds
+ * @throw NullValueException if the retrieved value is NULL
*/
std::wstring getString(int columnIndex) throw
(DriverException,
- NotImplementedException,
UnexpectedException);
+ NullValueException, NotImplementedException,
+ UnexpectedException);
/**
* Get the value of a column in the current row as an int.
*
@@ -149,9 +151,11 @@
* @return the column value; NULL if SQL NULL
* @exception DriverException if the ResultSet is closed or the cursor is
* out of bounds
+ * @throw NullValueException if the retrieved value is NULL
*/
int32_t getInt(int columnIndex) throw (DriverException,
- NotImplementedException,
UnexpectedException);
+ NullValueException, NotImplementedException,
+ UnexpectedException);
/**
* Closes the remote ResultSet if the ResultSet was streamed else just closes
* the ResultSet locally.
Index: carob/src/DriverResultSet.cpp
diff -u carob/src/DriverResultSet.cpp:1.22 carob/src/DriverResultSet.cpp:1.23
--- carob/src/DriverResultSet.cpp:1.22 Wed Dec 14 17:47:52 2005
+++ carob/src/DriverResultSet.cpp Wed Dec 14 18:23:44 2005
@@ -198,15 +198,13 @@
}
wstring DriverResultSet::getString(int columnIndex) throw (DriverException,
- NotImplementedException, UnexpectedException)
+ NullValueException, NotImplementedException, UnexpectedException)
{
checkRowAndColPosAndSetNullFlag(columnIndex);
if (wasNullFlag)
{
- //We cannot return a NULL object, so we send an empty string, and let the
- //user check nullity with wasNull() or isNull()
- //TODO: should we additionnaly return a "NullValueException" ?
- return L"";
+ throw (NullValueException(L"getString: value at row " +
toWString(currentRow)
+ + L" column " + toWString(columnIndex) + L" is NULL"));
}
std::wostringstream buffer;
@@ -260,13 +258,16 @@
}
int32_t DriverResultSet::getInt(int columnIndex) throw (DriverException,
- NotImplementedException, UnexpectedException)
+ NullValueException, NotImplementedException, UnexpectedException)
{
checkRowAndColPosAndSetNullFlag(columnIndex);
-/* if (wasNullFlag)
- return NULL;
-*/
+ if (wasNullFlag)
+ {
+ throw (NullValueException(L"getInt: Value at row " + toWString(currentRow)
+ + L" column " + toWString(columnIndex) + L" is NULL"));
+ }
+
//TODO: implement getInt for types other than int...
return (data[currentRow][columnIndex - 1].as_int);
}
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits