0.2.4.1 mor statz
This commit is contained in:
@@ -20,7 +20,8 @@ func InsertOrUpdateEstimatedVehicleJourney(db *sql.DB, values []interface{}) err
|
|||||||
operatorref = COALESCE(EXCLUDED.operatorref, estimatedvehiclejourney.operatorref),
|
operatorref = COALESCE(EXCLUDED.operatorref, estimatedvehiclejourney.operatorref),
|
||||||
vehicleref = COALESCE(EXCLUDED.vehicleref, estimatedvehiclejourney.vehicleref),
|
vehicleref = COALESCE(EXCLUDED.vehicleref, estimatedvehiclejourney.vehicleref),
|
||||||
cancellation = COALESCE(EXCLUDED.cancellation, estimatedvehiclejourney.cancellation),
|
cancellation = COALESCE(EXCLUDED.cancellation, estimatedvehiclejourney.cancellation),
|
||||||
other = COALESCE(EXCLUDED.other, estimatedvehiclejourney.other);
|
other = COALESCE(EXCLUDED.other, estimatedvehiclejourney.other)
|
||||||
|
RETURNING CASE WHEN xmax = 0 THEN 'insert' ELSE 'update' END, id;
|
||||||
`
|
`
|
||||||
|
|
||||||
stmt, err := db.Prepare(query)
|
stmt, err := db.Prepare(query)
|
||||||
@@ -29,10 +30,14 @@ func InsertOrUpdateEstimatedVehicleJourney(db *sql.DB, values []interface{}) err
|
|||||||
}
|
}
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
|
|
||||||
_, err = stmt.Exec(values...)
|
var action string
|
||||||
|
var id int
|
||||||
|
err = stmt.QueryRow(values...).Scan(&action, &id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error executing statement: %v", err)
|
return fmt.Errorf("error executing statement: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Action: %s, ID: %d\n", action, id)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user