sijms / go-ora

Pure go oracle client
MIT License
771 stars 169 forks source link

Can't support BFILE type for the bulk insert #470

Closed zhanghaiyang9999 closed 7 months ago

zhanghaiyang9999 commented 8 months ago

HI @sijms this issue is related to the nil value of the BFILE bulk insert. I tested this with version 2.7.24, the behavior is same as the BLOB(in version 2.7.24, blob issue already fixed). I use the following codes, insert two records, it worked well,(bfiles[0] is not nil).

   col_len := 2
names := make([]interface{}, col_len)

bfiles := make([]interface{}, 2)
bfiles[0], err = go_ora.CreateBFile(conn, "BFILES", "1.bmp")
bfiles[1] = go_ora.CreateNullBFile()
col_2 := make([]interface{}, 2)
col_2[0] = "test"
col_2[1] = nil
names[0] = sql.Named("C1", bfiles)
names[1] = sql.Named("C2", col_2)
sql_str := `INSERT INTO BFILE_TEST(COLUMN1,COLUMN2)VALUES(:C1,:C2)`
_, err = conn.Exec(sql_str, names...)
log.Println(err)

But if used the following codes, it will fail, the error is: ORA-00932: inconsistent datatypes: expected FILE got CHAR the difference is bfiles[0] and bfiles[1] both are nil.

col_len := 2
names := make([]interface{}, col_len)

bfiles := make([]interface{}, 2)
bfiles[0] = go_ora.CreateNullBFile()
bfiles[1] = go_ora.CreateNullBFile()
col_2 := make([]interface{}, 2)
col_2[0] = "test"
col_2[1] = nil
names[0] = sql.Named("C1", bfiles)
names[1] = sql.Named("C2", col_2)
sql_str := `INSERT INTO BFILE_TEST(COLUMN1,COLUMN2)VALUES(:C1,:C2)`
_, err = conn.Exec(sql_str, names...)
log.Println(err)
sijms commented 7 months ago

fixed in next release

sijms commented 7 months ago

fixed in v2.7.25