Hello Tommi,
I have added some draft code for support for 64 bit
integers and decimal floating point integers
for Oracle, MySQL 5.1 and PostgreSQL. And for 64 bit
integers for SQLite. There is also some code to map
decimal floating point integers to binary floating point
in SQLite, since my understanding is SQLite 3.4.1 does
not support decimal floating point.
I have run simple tests to write and read decimal
numbers with Oracle 10g r2, MySQL 5.1 beta 21,
PostgreSQL 8.2.4 and SQLite 3.4.1 with Sun Studio 12
64 bit Solaris 10u3.
I will send you an email with the draft of the diffs
just in case you would like to review them sometime (no hurry),
or integrate them with whichever changes you like.
Thanks very much.
Regards, Mark
PS I can't send the draft diffs to the list as they are too long.
Here is the little test program just in case anyone else is
interested:
#include <iostream>
#include <cxxtools/loginit.h>
#include <tntdb/connection.h>
#include <tntdb/connect.h>
#include <tntdb/statement.h>
int main(int argc, char* argv)
{
try
{
log_init_debug();
// tntdb::Connection conn =
tntdb::connect("oracle:;user=username;passwd=password"); //
tntdb::Connection conn = tntdb::connect("sqlite:sqlite.db"); //
tntdb::Connection conn =
tntdb::connect("mysql:db=mysql;user=username;passwd=password");
tntdb::Connection conn = tntdb::connect("postgresql:dbname=username");
try { conn.execute("drop table t1");
}
catch (...)
{
}
conn.execute(
"create table t1(c1 int not null primary key,"
" c2 decimal(38,2) not null)");
conn.execute("insert into t1 values(1, 0)");
conn.execute("insert into t1 values(2, 5)");
conn.execute("insert into t1 values(3, -5)");
conn.execute("insert into t1 values(4, 2767)");
conn.execute("insert into t1 values(5, -2767)");
conn.execute("insert into t1 values(6, 100000)");
conn.execute("insert into t1 values(7, 1234567)");
conn.execute("insert into t1 values(8, 0.01)");
conn.execute("insert into t1 values(9, 5.01)");
conn.execute("insert into t1 values(10, -5.01)");
conn.execute("insert into t1 values(11, 2767.01)");
conn.execute("insert into t1 values(12, -2767.01)");
conn.execute("insert into t1 values(13, 100000.01)");
conn.execute("insert into t1 values(14, 1234567.01)");
tntdb::Statement st = conn.prepare("select c1, c2 from t1");
for (tntdb::Statement::const_iterator cur = st.begin();
cur != st.end(); ++cur)
{
tntdb::Row row = *cur;
int c1 = row[0].getInt();
std::string c1s = row[0].getString();
int64_t c2 = row[1].getInt64();
std::string c2s = row[1].getString();
tntdb::Decimal c2d = row[1].getDecimal();
std::cout << "c1=" << c1 << " c1s=" << c1s << std::endl;
std::cout << "c2=" << c2 << " c2s=" << c2s << " c2d=" << c2d <<
std::endl; }
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
}
return 0;
}
From: Tommi Mäkitalo <[EMAIL PROTECTED]>
To: [email protected]
Subject: Re: [Tntnet-general] tntdb 64 bit integers
Date: Mon, 13 Aug 2007 23:44:36 +0200
Hi,
I would prefer a simple wrapper type just like tntdb::Date, tntdb::Time
and tntdb::Datetime. Passing a non-const reference to receive a return
code is just ugly. It just look much more natural, when an own type is
used:
class Decimal
{
public:
typedef int64_t DataType;
typedef int32_t ExponentType;
Decimal();
explicit Decimal(double value);
Decimal(DataType data, ExponentType exponent);
DataType getData() const;
ExponentType getExponent() const;
double getDouble();
};
class Value
{
public:
Decimal getDecimal() const;
};
class Statement
{
public:
void setDecimal(const std::string& col, const Decimal& value);
}:
----------------
Rather than implementing an incomplete set of arithmentic operations
tntdb::Decimal must not implement any just like tntdb::Date does not
implement any date-logic. The types are trivial to pass to a better
library for doing this.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general