ODBC - ORACLE - SOCI (lib) - ERROR date
Bonjour,
Context:
-Projet C++
-Base Oracle 9i
-lib d acces a la DB : Soci (v 3.0)
-ODBC (Oracle 9i)
-contrainte: Utiliser ODBC pour se connecter a Oracle
Erreur:
Probleme lors d insertion de date de maniere massive.
Error ODBC 22003 :"Numeric value out of range"
Un peu plus de details:
Avec l API soci, il est possible de faire des insertions de 2 manieres differentes:
- -soit 1 par 1
- - soit plusieurs a la fois (vector)
Mon pb vient de l insertion massive.
Si je prend un boost::gregorian::date pour UNE insertion ca marche
Code:
1 2 3 4 5 6 7 8 9
|
double Id = 50;
std::string Name = "InsertFromCode";
boost::gregorian::date dateEval = boost::gregorian::date (boost::gregorian::date::year_type(2010),boost::gregorian::date::month_type(5),boost::gregorian::date::day_type(3));
std::string stuff = "BARSA";
sql << "insert into TEST_ODBC(ID,NAME,DATE_EVAL,STUFF) values(:id,:name,:dateEval,:stuff)", use(Id),use(Name),use(dateEval),use(stuff);
--> Ceci marche tres bien : OK |
Mais si je fais la meme chose avec une insertion massive ca marche pas
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
//INIT
std::vector<double> vectId;
std::vector<boost::gregorian::date > vectDate;
boost::gregorian::date dateEval = boost::gregorian::date(boost::gregorian::date::year_type(2010),boost::gregorian::date::month_type(5),boost::gregorian::date::day_type(3));
double Id=100;
int NBLINE = 10;
for(int i(0);i<NBLINE;++i)
{
Id++;
vectId.push_back(Id);
vectDate.push_back(dateEval );
}
sql << "insert into TEST_ODBC(ID,DATE_EVAL) values(:Id,:DateEval)", use(vectId),use(vectDate);
--> ca marche pas : NOK |
Message d ERREUR:
Error ODBC : 22003
Msg: Numeric value out of range
Je ne comprends pas pkoi si je fais un seul insert ca marche avec le format date (boost::gregorian::date) et pas avec un insert massif (BulkOperation)
On pourra noter que le code suivant marche pour faire un insert massif mais c est tres LAID:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
//INIT
std::vector<double> vectId;
std::vector<std::string> vectDate;
std::string dateStringOK = "05/January/05";(ou "05-January-05";)
double Id=100;
int NBLINE = 10;
for(int i(0);i<NBLINE;++i)
{
Id++;
vectId.push_back(Id);
vectDate.push_back(dateStringOK );
}
sql << "insert into TEST_ODBC(ID,DATE_EVAL) values(:Id,:DateEval)", use(vectId),use(vectDate);
--> Ca marche mais c est tres moche:
- se servir d une string pour faire un insert sur une date
- le format de la string est : "05/January/05";(ou "05-January-05";)
ce qui pose pb sur les langues. |
Si quelqu un a une idee