March 2019
Intermediate to advanced
336 pages
9h 9m
English
The INSERT operation is as follows. The InsertCustomer method takes the Customer parameter and creates a prepared statement for the INSERT statement. The statement is used to execute the insertion of customer rows into the table, as shown in the following snippet:
// InsertCustomer method with parameter customerfunc InsertCustomer(customer Customer) { var database *sql.DB database= GetConnection() var error error var insert *sql.Stmt insert,error = database.Prepare("INSERT INTO CUSTOMER(CustomerName,SSN) VALUES(?,?)") if error != nil { panic(error.Error()) } insert.Exec(customer.CustomerName,customer.SSN) defer database.Close()}
Let's take a look at the variadic functions in the next section.
Read now
Unlock full access