Skip to content

Commit

Permalink
✨ 添加批量设置和移除会话参数工具函数
Browse files Browse the repository at this point in the history
- AddSessionParams setting database connection session parameters
- DelSessionParams remove session parameters

Signed-off-by: liutianqi <zixizixi@vip.qq.com>
  • Loading branch information
iTanken committed Jan 3, 2024
1 parent 1c7e78f commit 7af68eb
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,43 @@ func GetStringExpr(value string, quotes ...bool) clause.Expr {
return gorm.Expr(value)
}

// AddSessionParams setting database connection session parameters
func AddSessionParams(db *sql.DB, params map[string]string) (err error) {
if db == nil {
return
}
if _, ok := db.Driver().(*go_ora.OracleDriver); !ok {
return
}

for key, value := range params {
if key == "" || value == "" {
continue
}
if err = go_ora.AddSessionParam(db, key, value); err != nil {
return
}
}
return
}

// DelSessionParams remove session parameters
func DelSessionParams(db *sql.DB, keys []string) {
if db == nil {
return
}
if _, ok := db.Driver().(*go_ora.OracleDriver); !ok {
return
}

for _, key := range keys {
if key == "" {
continue
}
go_ora.DelSessionParam(db, key)
}
}

func convertCustomType(val interface{}) interface{} {
rv := reflect.ValueOf(val)
ri := rv.Interface()
Expand Down

0 comments on commit 7af68eb

Please sign in to comment.