Hello and welcome to the golden programming language course in the previous session.
They could define multiple update function and in.
We want to create the function to delete a student in a student in an in-person database.
We want to do the delete operation in two ways.
First, for delete a student or a record of the student today and second for delete more than a student
record or many records in the student data.
Delete a student.
First, define the function named single.
Delete that accept a parameter that is an empty interface, which indicates that any instance of a strike
is to be passed to the this method.
Also, this function returns the number of records that have been affected by the delete operation at
the end of the works.
So go to the DB connection PHI and define our function.
Find singular delete.
Set a name like object for empty interface object.
Either tied into and or face.
And return type is in sixty four.
Now calling connect function for initializing MySchool data source name, this function returns a DB
object from garden package.
So define a variable like DB calling equals and invoke connect function.
After creating a DV object from Gore and package, we invoked delete function so we can delete function
on the DBI object and Sith object instance, an argument for it before calling it first define a variable
like reason for the return type delete function.
Deletes value match given conditions if the value has primary key denville, including the primary key
as condition result column equals DB dot lead.
And said, Optic, there's argument to it.
When did it record, you need to ensure its primary field has value and Gorham will use the primary
key to delete the record?
If primary fields blank or invaded, did it are records for the model now invoking those affected field
from resolved return that we showed the remove the fact that records so be right ITR resolved dot rows
affects the format.
The code in SEC, the project we have now succeeded in designing a method to receive a strike instance
from the outside and delete this object from its table in database.
Now we go to the main function to use to this query statement.
First, clear the last code.
In this case, we want to delete a student in person database, so we should use from single digit functions
from TV tools.
Suppose a student with I.D. number two is in the database and we want to delete these records from a
student table in person database.
So first, go to my school database and see this record.
Now we can see the records of the student table in person database.
We want to remove the I.D. number two by the name Robert and age 25.
Now go to the school program and continue.
First, create an a student object from a student, etc. and initialize it value in it.
So override the student calling equals model dot student
and sit idly by two and now invoke delete function from TV tools.
Package and send create the student object argument and fist row effect it.
So first, define a variable like roll call equals calling single digit function from TV tools, TV
tools, dot single let and set a student instance.
Now this a return type as role variable, so right, FP Rose faked it and said roll reformat the code
and save the project, now execute the program.
Glow from the outback is the main main.
That's cool.
OK, now we can see the output rose affected one.
Now go to database again and execute silly query and see the changes executed.
Select query.
OK, we can see that a record of a student with I.D. number two was removed from table and one row is
affected in order not to prolong the time of decision.
We will finish it and we will continue the content in the next session until next session.
Goodbye.