***********************
** FILE NAME : database.cpp
** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
-** VERSION NUMBER : $Revision: 1.6 $
+** VERSION NUMBER : $Revision: 1.7 $
**
** DESCRIPTION : Implementation of the gnucomo database classes
**
/*****************************
$Log: database.cpp,v $
- Revision 1.6 2003-02-05 09:33:42 arjen
+ Revision 1.7 2003-02-19 12:07:55 arjen
+ Use the SQL function currval() to obtain the identification number
+ of the most recently created notification.
+
+ Revision 1.6 2003/02/05 09:33:42 arjen
gnucomo_database::new_notification() retruns the id number of the
newly created notification record.
*****************************/
-static const char *RCSID = "$Id: database.cpp,v 1.6 2003-02-05 09:33:42 arjen Exp $";
+static const char *RCSID = "$Id: database.cpp,v 1.7 2003-02-19 12:07:55 arjen Exp $";
#include <AXE/date.h>
insertion += issueid + "', '" + now.format("%Y-%m-%d %T") + "', 'new', '";
insertion += Field(0, "suggested_priority") + "')";
- qry = "select notificationid from notification where objectid='";
- qry += objectid + "' and type_of_issueid = '";
- qry += issueid + "' order by notificationid";
-
Query(insertion);
- int tuples = Query(qry);
- if (tuples > 0)
- {
- notif_id = Field(tuples - 1, "notificationid");
+ Query("select currval('notification_notificationid_seq')");
+ notif_id = Field(0, "currval");
+ if (notif_id != "")
+ {
insertion = "insert into action_user (actionid, username, notificationid,";
insertion += " timestamp, statuscode, remarks) values ('1', 'gnucomo', '";
insertion += notif_id + "', '" + now.format("%Y-%m-%d %T") + "', 'new', '";
std::cerr << "Error inserting notification.\n";
}
}
+ else
+ {
+ std::cerr << "DATABASE ERROR: Type of issue " << issue << " not found.\n";
+ }
return notif_id;
}