Set data Lob
VojRu opened this issue · 3 comments
Hi, I have question:
How i can set data by Lob?
The goal is to set object by goracle, fill it by data (especialy Lob) and bind it to oracle procedure.
Object in Oracle is created by this:
CREATE OR REPLACE TYPE t_description_o2 AS OBJECT
( title varchar2(200 char)
, short_description varchar2(2000 char)
, long_description clob
)
;
Trying to set cLob into Data:
objectType, _:= goracle.GetObjectType(execer, "oracleObjectName")
object, _ := objectType,.NewObject()
data := &goracle.Data{}
_ = object.GetAttribute(data, "nameOfAttribute")
conn, err := goracle.DriverConn(execer)
switch
...
case Lob:
lob := goracle.Lob{Reader: strings.NewReader(objV.String()), IsClob: true}
specialData, err := conn.NewData(lob,1,objV.Len())
data = specialData[0]
Call procedure:
qry := `BEGIN test_proc( :object); END;
_ , err = execer.Exec(qry, sql.Named("object", object))
With this approach i get no errors but no lob data is put in DB.
Where do you put the LOB's data into the "data"? data.SetLOB is not there yet; can you try data.SetString ?
Then, te data should be set on the object's attribute with object.SetAttribute.
Where do you put the LOB's data into the "data"?
Tought that this rows do it:
lob := goracle.Lob{Reader: strings.NewReader(objectValue), IsClob: true}
specialData, err := conn.NewData(lob,1,objectValue.Len())
data = specialData[0]
I tought that this create Lob that i put into NewData func and this create "data" with Lobs data.
data.SetLOB is not there yet; can you try data.SetString ?
Do you mean data.SetBytes([]byte(StringValue))
???
Cuz data.SetString doesnt exists.
- this not work.. its only work for 24len strings, more chars throw this:
Exception 0xc0000005 0x0 0xffffffffffffffff 0x7ffb767b4ff5 PC=0x7ffb767b4ff5 ......
(So I expecting, this happens because the data has alocate 24len buffer.)
Setting data into object throught data.SetAttribute wokring fine (tested on another types).