updateFunc

parser
Numillyash 2022-10-06 17:36:44 +03:00
parent 442264f6a0
commit 2ba8bd9d57
2 changed files with 33 additions and 1 deletions

View File

@ -28,11 +28,13 @@ int main()
printf("uniq:%d \n", deleteNonUniqElements());
char selects[7] = { 1, 5, 3, -1, -1, -1, -1 };
char selects[7] = { 0, 5, 3, -1, -1, -1, -1 };
Condition a = { moreEqual, 2, 0, NULL, 0, NULL };
Condition* conditions[7] = {NULL, NULL, NULL, &a, NULL, NULL, NULL};
printf("\nselect:%d \n", selectFunc(selects, conditions));
printf("\nupdate:%d \n", updateFunc("TeStNaMe", NULL, -1, -1, NULL, NULL, NULL, conditions));
printf("\nselect:%d \n", selectFunc(selects, conditions));
//printDataBase();

View File

@ -485,3 +485,33 @@ int selectFunc(char whatToPrint[7], Condition* conditions[7])
}
return count;
}
int updateFunc(char* lastName, char* firstName, int course, int labID, time_t* startTime, time_t* endTime, int results[99],Condition* conditions[7])
{
int count = 0;
DataBaseElement* tmp;
tmp = head;
while (tmp != NULL)
{
if (isElementRespondConditions(tmp, conditions))
{
if (lastName != NULL)
tmp->last_nm = lastName;
if (firstName != NULL)
tmp->first_nm = firstName;
if (course != -1)
tmp->curse_id = course;
if (labID != -1)
tmp->lab_id = labID;
if (startTime != NULL)
tmp->start_tm = startTime;
if (endTime != NULL)
tmp->end_tm = endTime;
if (results != NULL)
tmp->result = results;
count++;
}
tmp = tmp->nextElement;
}
return count;
}