Hello.
If oracle use out object with empty field type of object, go-ora can not parse variable.
Oracle object:
create or replace type typeChild as object(
id number,
name varchar2(100)
);
create or replace type typeParent as object(
id number,
child typeChild
);
Golang code:
func testParent(db *sql.DB) {
type typeChild struct {
Id float64 `udt:"ID"`
Name string `udt:"NAME"`
}
type typeParent struct {
Id float64 `udt:"ID"`
Child typeChild `udt:"CHILD"`
}
var parent typeParent
err := go_ora.RegisterType(db, "TYPECHILD", "", typeChild{})
if err != nil {
fmt.Println("err RegisterType typeChild:", err)
}
err = go_ora.RegisterType(db, "TYPEPARENT", "", typeParent{})
if err != nil {
fmt.Println("err RegisterType TYPEPARENT:", err)
}
_, err = db.Exec(`
declare
v_child typeChild := typeChild(null,null);
v_parent typeParent := typeParent(null,null);
begin
v_parent.id := 0;
v_child.id := 1;
-- v_parent.child := v_child; -- <- If use this, all ok. If delete := then not work
:p := v_parent;
end;`,
go_ora.Out{In: false, Dest: &parent},
)
if err != nil {
fmt.Println("err test:", err)
return
}
fmt.Println("parent:", parent)
}
Result
if I remove the filling of the child field:
err test: Invalid Input Number 0401050299ef01010203f5000000002f00000000000000000000000000000101000000000203f50101364f52412d30313031333a2075736572207265717565737465642063616e63656c206f662063757272656e74206f7065726174696f6e0a
Hello. If oracle use out object with empty field type of object, go-ora can not parse variable. Oracle object:
Golang code:
Result if I remove the filling of the child field: err test: Invalid Input Number 0401050299ef01010203f5000000002f00000000000000000000000000000101000000000203f50101364f52412d30313031333a2075736572207265717565737465642063616e63656c206f662063757272656e74206f7065726174696f6e0a
If i make _v_parent.child := vchild then all ok.
Client go-ora: v2.8.6 go: 1.21.3 oracle-client: 12.2.0.1.0