我想在go中的行中使用NEXT,但我的vw在行中收到了警告。NEXT 它说 NEXT undefined (type *“database/sql”)。行没有字段或方法 NEXT)
func FetchViewDO() (shipment_admin.ShipmentViewDetailDOGroup, error) {
var obj ShipmentDOBaseModel
var objg ShipmentDOGroup
var arrobj []ShipmentDOBaseModel
var res shipment_admin.ShipmentViewDetailDOGroup
var db *sql.DB
con := db
sqlStatement := `SELECT s.status_id,sdog.*,sdo.shipment_id,sdo.external_id,sdo.client_code
FROM shipment_delivery_order sdo
LEFT JOIN shipment_delivery_order_group sdog ON sdog.shipment_child_id = sdo.shipment_id
LEFT JOIN shipment s ON s.shipment_id = sdo.shipment_id`
rows, err := con.Query(sqlStatement)
defer rows.Close()
if err != nil {
return res, err
}
for rows.NEXT() {
err = rows.Scan(&objg.ShipmentParentID, &objg.CreatedAt, &objg.ShipmentChildID)
if err != nil {
return res, err
}
}
res.Status = http.StatusOK
res.Message = "Success"
res.Data = arrobj
return res, nil
}
HUX布斯
相关分类