Delete
Record –
To delete the record or rows or columns in SQL , we
can use directly the query but as we are using same functionality in cpp .We
need to first create record and then by including SQL libraries in code blocks
following with delete record code ,delete function is implemented in our
project.
Code-
cout<<"\nDelete
Operation\n";
query =
"DELETE FROM STUDENT WHERE ID = 2;";
exit =
sqlite3_exec(DB, query.c_str(), callback, 0, &messaggeError);
if (exit
!= SQLITE_OK) {
std::cerr
<< "Error DELETE" << std::endl;
sqlite3_free(messaggeError);
}
else
std::cout
<< "Record deleted Successfully!" << std::endl;
Output-
Search –
Using
this function of SQL ,we can search any element or elements from the given
record and can display it. This is done similarly, in code blocks using SQLite
library. Following code will explain the functionality .
Code-
cout<<"\nSearch
Operation\n";
string
data("CALLBACK FUNCTION");
/*
Create merged SQL statement */
query =
"SELECT * FROM STUDENT WHERE ID = 20;";
/*
Execute SQL statement */
int rc =
sqlite3_exec(DB, query.c_str(), callback, (void*)data.c_str(), NULL);
if (rc
!= SQLITE_OK)
cerr
<< "Error SELECT" << endl;
else {
cout
<< "Operation OK!" << endl; }
Output-
Modify Record-
As name
suggest, modify means to make changes and get it replaced in same record is the
functionality of this SQL query. This is done by including terms to be modified
in code using codeblocks.
Code-
cout<<"\nModify
Record\n";
/*
Create merged SQL statement */
query =
"UPDATE STUDENT set CGPA = 0 where ID=20;
"
"SELECT * from STUDENT";
/* Execute SQL statement */
rc = sqlite3_exec(DB, query.c_str(),
callback, (void*)data.c_str(), NULL);
if( rc != SQLITE_OK )
{
fprintf(stderr, "SQL error: %s\n", messaggeError); sqlite3_free(messaggeError);
}
else
{
fprintf(stdout, "Operation done
successfully\n"); }
Output-
Diksha Avhad
K3




Proper explained functions
ReplyDeleteNicely Explained and Your video also helped 👍
ReplyDeleteExcellent work.....👌👌
ReplyDeleteHelpful! Attachments of results helped a lot to understand the concept
ReplyDeleteWell explained
ReplyDeleteinformative
ReplyDeleteEach part is well explained with code
ReplyDeleteExcellent 👌👌
ReplyDeleteWell explained and videos are also good👍👍
ReplyDeleteNice...conceptual explanation.
ReplyDelete👍👍👍👍👍
ReplyDelete👌
ReplyDeleteWell explained 👍
ReplyDelete