March 2019
Intermediate to advanced
336 pages
9h 9m
English
The delete operation is as follows. The DeleteCustomer method takes the Customer parameter and creates a prepared statement for the DELETE statement. The statement is used to execute the deletion of a customer row in the table:
// Delete Customer method with parameter customerfunc deleteCustomer(customer Customer){ var database *sql.DB database= GetConnection() var error error var delete *sql.Stmt delete,error = database.Prepare("DELETE FROM Customer WHERE Customerid=?") if error != nil { panic(error.Error()) } delete.Exec(customer.CustomerId) defer database.Close()}// main methodfunc main() { var customers []Customer customers = GetCustomers() fmt.Println("Before Delete",customers) var customer Customer customer.CustomerName ...
Read now
Unlock full access