Hi There Golang-nuts. 

I am seeking help for my go lang project.

I am having an oracle server and in that there are many Db's Now I am 
createing a store procedure which has almost 20 parameters which are used 
multiple times in one single query. 

Now I checked GO does not support reuse of same parameters so if I have 
already used order_id as a parameter while passing query to be executed I 
can not use the order_id parameter anywhere else in the query. 

So I created a store procedure which would be easier but now in oracle 
while running the store procedure I am running it as follows 

    var rows *sql.Rows

    _, err := r.db.QueryxContext(
        ctx,
        `BEGIN
        PSIGWAY.get_transactions(
            :1, :2, :3, :4, :5, :6, :7, :8, :9, :10,
            :11, :12, :13, :14, :15, :16, :17, :18,
            :19, :20
        );
     END;`,
        request.StoreID,
        request.DateFrom,
        request.DateTo,
        request.Status,
        request.Action,
        request.AuthCode,
        request.OrderID,
        request.UserId,
        request.CustomerIP,
        request.CardType,
        request.CardSpan,
        request.DateFilterType,
        request.AmountFilterType,
        request.Amount,
        request.BillingName,
        request.BillingPostalCode,
        request.BillingProvince,
        Requestpage,
        "GetTransactions",
        sql.Out{Dest: &rows}, // 🔥 THIS IS THE KEY
    )
    if err != nil {
        return response, err
    }
    defer rows.Close()

    for rows.Next() {
        var o models.OrderSummary
        err := rows.Scan(
            &o.IMID,
            &o.OrderID,
            &o.TrxID,
            &o.Amount,
            &o.Name,
            &o.Card,
            &o.UserId,
            &o.Date,
            &o.Action,
            &o.Result,
            &o.ReturnCode,
            &o.External_Reason,
            &o.IDEBITISSNAME,
            &o.IDEBITISSCONF,
            &o.ACQCONFCODE,
        )
        if err != nil {
            return response, err
        }

        orders = append(orders, o)
    }

    if err := rows.Err(); err != nil {
        return response, err
    }

    // Post-processing
    for i := range orders {
        transType := "IOP_TRANSACTIONS"
        if orders[i].TrxID > "2000000000000000000" {
            transType = "CC_TRANSACTIONS"
        }

        orders[i].ActionText = utils.GetActionText(orders[i].Action, 
transType)
        orders[i].ResultText = utils.GetResultText(orders[i].Result, 
transType)
        orders[i].ReturnCodeText = utils.GetReturnCodeText(
            orders[i].Result,
            orders[i].TrxID,
            orders[i].ReturnCode,
            orders[i].IDEBITISSNAME,
            orders[i].IDEBITISSCONF,
            orders[i].ACQCONFCODE,
            orders[i].External_Reason,
        )
    }

    response.TotalResults = len(orders)
    response.Orders = orders


but it throws me an error reflect: call of reflect.Value.Type on zero Value
/usr/local/go/src/reflect/value.go:2474 (0x4c034d)
        Value.abiTypeSlow: panic(&ValueError{"reflect.Value.Type", Invalid})
/usr/local/go/src/reflect/value.go:2462 (0x4c021c)
        Value.typeSlow: return toRType(v.abiTypeSlow())
/usr/local/go/src/reflect/value.go:2457 (0x6fc1fb)
        Value.Type: return v.typeSlow()
/home/ndesai/go/pkg/mod/github.com/godror/[email protected]/stmt.go:3409 
(0x6fc1ab)
        (*conn).getStructObjectType: rvt := rv.Type()
/home/ndesai/go/pkg/mod/github.com/godror/[email protected]/stmt.go:1465 
(0x6e9393)
        (*statement).bindVarTypeSwitch: if ot, err := 
st.conn.getStructObjectType(ctx, value, ""); err != nil { Now it is because 
of the sq.out but not sure How to solve this issue and get it running I 
have spent almost 3 weeks on this please help me with this and help me 
resolve it Thank you. 


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/72d551bf-3b0c-4589-bbab-13681764fe34n%40googlegroups.com.

Reply via email to