fix obj name
This commit is contained in:
parent
dadc20279b
commit
aa34353a9e
22
obj.go
22
obj.go
@ -265,12 +265,28 @@ func setObjSubTypeId(objId int64, objSubTypeID64 int64) error {
|
||||
}
|
||||
|
||||
func objAddName(objID64 int64, name string) error {
|
||||
stmt, err := db.Prepare(`INSERT INTO obj_name (obj_id, name, priority)
|
||||
SELECT ? obj_id, ? name, (SELECT count(*) FROM obj_name WHERE obj_id = ?) priority FROM DUAL;`)
|
||||
var priority int64
|
||||
|
||||
_, err = stmt.Exec(objID64, name, objID64)
|
||||
stmt, err := db.Prepare(`SELECT COUNT(*) FROM obj_name on WHERE on.obj_id = ?`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
err = stmt.QueryRow(objID64).Scan(&priority)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
stmt2, err := db.Prepare(`INSERT INTO obj_name (obj_id, name, priority)
|
||||
VALUES (?, ?, ?);`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer stmt2.Close()
|
||||
|
||||
_, err = stmt2.Exec(objID64, name, priority)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user