UPDATE/INSERT a single instance of m_type_name into the database.
153{
154 SchedXaction* pSx;
156 E_DB_OPERATION op;
157 gboolean is_infant;
158 gboolean is_ok;
159
160 g_return_val_if_fail (sql_be != NULL, FALSE);
161 g_return_val_if_fail (inst != NULL, FALSE);
162 g_return_val_if_fail (GNC_IS_SX (inst), FALSE);
163
164 pSx = GNC_SX (inst);
165
166 is_infant = qof_instance_get_infant (inst);
168 {
169 op = OP_DB_DELETE;
170 }
171 else if (sql_be->pristine() || is_infant)
172 {
173 op = OP_DB_INSERT;
174 }
175 else
176 {
177 op = OP_DB_UPDATE;
178 }
179 is_ok = sql_be->
do_db_operation(op, SCHEDXACTION_TABLE, GNC_SX_ID, pSx,
180 col_table);
182 if (op == OP_DB_INSERT || op == OP_DB_UPDATE)
183 {
185 }
186 else
187 {
188 gnc_sql_recurrence_delete (sql_be, guid);
189 }
190
191 if (is_ok)
192 {
193
194 if (op == OP_DB_INSERT || op == OP_DB_UPDATE)
195 {
196 is_ok = gnc_sql_slots_save (sql_be, guid, is_infant, inst);
197 }
198 else
199 {
200 is_ok = gnc_sql_slots_delete (sql_be, guid);
201 }
202 }
203
204 return is_ok;
205}
bool do_db_operation(E_DB_OPERATION op, const char *table_name, QofIdTypeConst obj_name, gpointer pObject, const EntryVec &table) const noexcept
Performs an operation on the database.
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
gboolean qof_instance_get_destroying(gconstpointer ptr)
Retrieve the flag that indicates whether or not this object is about to be destroyed.
GList * gnc_sx_get_schedule(const SchedXaction *sx)
The type used to store guids in C.