March 2019
Intermediate to advanced
336 pages
9h 9m
English
In the following code, the InsertCustomer method takes customer as a parameter to execute the SQL statement for inserting into the CUSTOMER table:
// 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()}
Read now
Unlock full access