Hello and welcome to the Golang programming language course in the Perilya session, we could define,
create table function and indecision.
We want to create the function to insert a new student in the student table in person database.
So go to the DB connection, find and first define the function name safe that accept and object parameters
in the interface.
So we right fine save and set the parameter as object by the time interface.
Now calling chronic function for initializing minuscule data source name, this function returns a DB
object from gore and package, which gives us access to the metals contained in that package to perform
covert operations.
So first, define a variable like DB column equals and calling conic function.
After creating a DB object from quorum package.
Be invoked, create function DB Dot column create function.
This function accept that any interface object as argument and insert the instance in its corresponding
table in the database, so be set.
Receive objects as parameter for this function.
Reformat the code and save the project.
Now we were able to write the function of inserting an object in the database.
It's time to go to the main function to use this query statement.
Go to the main function.
First, clear the last code.
In this case, we want to say the newest student in person database, so we should use from, say,
function from DV tools that they accept an extra instance as A. interface that we want to send a student
an instance as input argument.
So first, create a student instance from a student's Astrup and initialize it.
So first, define a variable like student calling equals model dot student and initialize the field
ID equals one and name.
For example, it came and age 20 and now invoked, say, function from DevTools package and send created
a student object that arguments to eat
daily tools don't save and set a student asked parameter
and set a message for inserting new object.
If the new student has an inserted
database.
Reformat the code, save the project and execute the program go wrong.
I guess this Maine and Maine don't go.
Now we can see the output new student has exerted in database, now we enter the MySchool database and
check to see if a new record has been added to the person table or not.
OK.
In the left panel, right click on the Navigator and select Refresh on Select Person database.
Open it and select a student table from the table list.
Right click on the student and table and press select roles to display the records indicated.
A student table information is displayed, and we see that our new data is inserted inside it now returned
to the Villa School program and at a few new recourse to the new student table by calling the same function
again.
For example, I.D. two and Nain sits Robert and age 25, ran the program again and do this work again
for a new object I.D. three
name Jessica and age 13.
Save the project and execute the game.
OK, go back to my later, this first reference on and then run the query for displaying a student table
information again.
Now we see that all the records created in the database have been saved successfully in order not to
prolong the time of decision.
We will finish it and we'll continue the content in the next session.
Goodbye.