int sqlpg::insert(vector<string> text) {
clog<<"insert(vector<string>) begin\n";
+ string command="INSERT INTO raw (date, texte) VALUES ($1::timestamp, $2::text);";/*PQgetvalue(res, 0, 0);*/
+ clog<<"commande : "<<command<<endl;
- string command="INSERT INTO raw (date, texte) VALUES ($1::timestamp, $2::text);";
string tmp="";
int argc=2;
const char * value[2];
int length[2];
int binary[2];
PQprepare(conn, "insert", command.c_str(), 2, NULL);
-
+ string a;
if (text.size()>2){
if ((isdate(text[0]))+(isdate(text[1]))==3){
clog<<"text[0]+text[1]==3(L55)\n";
date=text[0];
- string a=date+" "+text[1];
+ a=date+" "+text[1];
value[0]=a.c_str();
length[0]=a.size();
binary[0]=0;
else if((text[0]=="-")&&(isdate(text[1])==2)){
clog<<"date partielle(L72)\n";
tmp=text[2];
- string a=date+" "+text[1];
+ a=date+" "+text[1];
value[0]=a.c_str();
length[0]=a.size();
binary[0]=0;
}
else{
- clog<<"text.size()>2 && text[0] & text[1] isn't date. L89";
+ clog<<"text.size()>2 && text[0] & text[1] isn't date. L101";
tmp=text[0];
- string a="1971-11-11 22:22:22";
+ a="now";
+ for (int i=1;i<text.size(); i++){
+ tmp=tmp+" "+text[i];
+ }
value[0]=a.c_str();
length[0]=a.size();
binary[0]=0;
value[1]=tmp.c_str();
length[1]=tmp.size();
binary[1]=0;
- for (int a=1;a<text.size(); a++){
- tmp=tmp+" "+text[a];
- }
//command="INSERT INTO raw (date, texte) VALUES ('now()', '"+tmp+"')";
};
-
}
else {
clog<<"text.size()<2\n";