How does the go language call the stored procedure of oracle and get the return value of the stored procedure?

how does the go language call the stored procedure of oracle and get the return value of the stored procedure? I saw in goracle.v2 "s github that the driver could get the return value by passing a goracle.PlSQLArrays, to the Exec method, but I tried unsuccessfully. Please give me a lot of advice. Attach your own code as follows:

func main() {
    db, err := sql.Open("goracle", "ods_bak/odsbak@110.1.5.54:1521/ODS_DEV")
    if err != nil {
        fmt.Println(err)
        return
    }
    defer db.Close()
    loginStmt,err:=db.Prepare("begin login(:1,:2,:3);end;")
    defer loginStmt.Close()
    var mail string = "1"
    var pwd string = "2"
    var retVal string
    loginStmt.Exec(goracle.PlSQLArrays,mail,pwd,&retVal)
    fmt.Println(retVal)
}

the stored procedure code is as follows:

create PROCEDURE login(u_mail_in IN VARCHAR2,
    u_pwd_in IN VARCHAR2,
    retval OUT VARCHAR2)
    AS
         l_count NUMBER     ;
    BEGIN
        retval := u_mail_in||u_pwd_in;

    END   login;
    

result

Mar.06,2021

got it done by myself. Use sql.Out to receive the return value parameter


ask how sql.out receives it, and how do you get it done. I have the same problem


func callpro (id string) {

var res interface{}
qry := `BEGIN SP_DEAL_GETLINESBYITEMID(:id,:order_id); END;`

if _, err := Db.Exec(qry,id,sql.Out{Dest:&res});err!=nil{
    Log.Debug("exec err is %s",err)
}
rest := res.(driver.Rows)
value := make([]driver.Value,len(rest.Columns()))
for {
    if err := rest.Next(value);err != nil{
        if err == io.EOF{
            Log.Debug("err is %v",err)
            break
        }
        Log.Debug("value is %v",value)
    }
}

}

error: 2018-09-26 16 br 50 ORA-06550: 57.783 [D] [default.go:66] exec err is dpiStmt_execute (mode=32 arrLen=-1): line 1, column 7:
number of parameters or type errors when PLS-00306: calls' SP_DEAL_GETLINESBYITEMID'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

I would like to ask if the parameter is cursor, how to call the stored procedure? the package "gopkg.in/goracle.v2" is also used

Menu