1 00:00:12,140 --> 00:00:18,100 Hello and welcome to the Golang programming language course in the Perilya session, we could define, 2 00:00:18,110 --> 00:00:21,650 create table function and indecision. 3 00:00:21,890 --> 00:00:27,980 We want to create the function to insert a new student in the student table in person database. 4 00:00:30,020 --> 00:00:39,350 So go to the DB connection, find and first define the function name safe that accept and object parameters 5 00:00:39,350 --> 00:00:40,370 in the interface. 6 00:00:43,440 --> 00:00:57,180 So we right fine save and set the parameter as object by the time interface. 7 00:01:03,850 --> 00:01:11,110 Now calling chronic function for initializing minuscule data source name, this function returns a DB 8 00:01:11,110 --> 00:01:17,230 object from gore and package, which gives us access to the metals contained in that package to perform 9 00:01:17,230 --> 00:01:18,400 covert operations. 10 00:01:18,910 --> 00:01:25,720 So first, define a variable like DB column equals and calling conic function. 11 00:01:29,080 --> 00:01:32,050 After creating a DB object from quorum package. 12 00:01:32,050 --> 00:01:40,360 Be invoked, create function DB Dot column create function. 13 00:01:40,690 --> 00:01:48,640 This function accept that any interface object as argument and insert the instance in its corresponding 14 00:01:48,640 --> 00:01:50,920 table in the database, so be set. 15 00:01:50,970 --> 00:01:54,040 Receive objects as parameter for this function. 16 00:01:57,570 --> 00:02:00,330 Reformat the code and save the project. 17 00:02:01,170 --> 00:02:06,240 Now we were able to write the function of inserting an object in the database. 18 00:02:07,170 --> 00:02:11,580 It's time to go to the main function to use this query statement. 19 00:02:11,820 --> 00:02:13,440 Go to the main function. 20 00:02:15,600 --> 00:02:17,370 First, clear the last code. 21 00:02:23,760 --> 00:02:29,880 In this case, we want to say the newest student in person database, so we should use from, say, 22 00:02:29,900 --> 00:02:36,990 function from DV tools that they accept an extra instance as A. interface that we want to send a student 23 00:02:36,990 --> 00:02:38,880 an instance as input argument. 24 00:02:39,270 --> 00:02:44,800 So first, create a student instance from a student's Astrup and initialize it. 25 00:02:44,820 --> 00:02:55,620 So first, define a variable like student calling equals model dot student and initialize the field 26 00:02:56,460 --> 00:03:01,230 ID equals one and name. 27 00:03:01,500 --> 00:03:14,640 For example, it came and age 20 and now invoked, say, function from DevTools package and send created 28 00:03:14,640 --> 00:03:17,100 a student object that arguments to eat 29 00:03:20,280 --> 00:03:27,660 daily tools don't save and set a student asked parameter 30 00:03:31,140 --> 00:03:34,350 and set a message for inserting new object. 31 00:03:34,740 --> 00:03:44,490 If the new student has an inserted 32 00:03:46,830 --> 00:03:48,000 database. 33 00:03:50,220 --> 00:03:56,880 Reformat the code, save the project and execute the program go wrong. 34 00:03:57,420 --> 00:04:01,230 I guess this Maine and Maine don't go. 35 00:04:05,100 --> 00:04:13,740 Now we can see the output new student has exerted in database, now we enter the MySchool database and 36 00:04:13,740 --> 00:04:17,670 check to see if a new record has been added to the person table or not. 37 00:04:21,690 --> 00:04:21,970 OK. 38 00:04:22,110 --> 00:04:30,510 In the left panel, right click on the Navigator and select Refresh on Select Person database. 39 00:04:31,080 --> 00:04:34,950 Open it and select a student table from the table list. 40 00:04:37,910 --> 00:04:43,070 Right click on the student and table and press select roles to display the records indicated. 41 00:04:46,580 --> 00:04:55,460 A student table information is displayed, and we see that our new data is inserted inside it now returned 42 00:04:55,460 --> 00:05:01,940 to the Villa School program and at a few new recourse to the new student table by calling the same function 43 00:05:01,940 --> 00:05:02,360 again. 44 00:05:04,370 --> 00:05:21,290 For example, I.D. two and Nain sits Robert and age 25, ran the program again and do this work again 45 00:05:21,290 --> 00:05:24,350 for a new object I.D. three 46 00:05:28,340 --> 00:05:34,520 name Jessica and age 13. 47 00:05:37,800 --> 00:05:40,200 Save the project and execute the game. 48 00:05:45,460 --> 00:05:55,060 OK, go back to my later, this first reference on and then run the query for displaying a student table 49 00:05:55,070 --> 00:05:56,080 information again. 50 00:05:59,140 --> 00:06:06,910 Now we see that all the records created in the database have been saved successfully in order not to 51 00:06:06,910 --> 00:06:08,350 prolong the time of decision. 52 00:06:08,500 --> 00:06:12,310 We will finish it and we'll continue the content in the next session. 53 00:06:12,700 --> 00:06:13,240 Goodbye.