ORA-01036 错误,当使用 cx_oracle 绑定变量时

ORA-01036 error, when binding variables with cx_oracle

当尝试寻址一个函数并绑定一些参数时,我不断得到奇怪的结果

我试过在 vars 中使用不同的变量名和不同的数字,但没有成功

        res_sum = -1
        good_id = 430815501
        self.cur.prepare(":smth := AP_USER_OFFICE_PKG_S.GET_SERVS_SUMS(:smth2).N_GOOD_SUM;")

        self.cur.execute(None, {'smth': res_sum, 'smth2': good_id})

我期待 return 结果的功能,但只得到


    self.cur.execute(None, {'smth': res_sum, 'smth2': good_id})
cx_Oracle.DatabaseError: ORA-01036: illegal variable name/number
``
    def get_service_sum(self, good_id):
        SQL_BLOCK = '''
        DECLARE
            v_good_id    NUMBER;
            v_result  NUMBER;
        BEGIN
            v_good_id := :i_good_id;
            v_result := AP_USER_OFFICE_PKG_S.GET_SERVS_SUMS(v_good_id).N_GOOD_SUM;
            :o_result := v_result;  -- (1)
        END;

        '''
        res_sum = self.cur.var(cx_Oracle.NUMBER)
        good_id = 430815501

        self.cur.execute(SQL_BLOCK, i_good_id=good_id, o_result=res_sum)
        res = res_sum.getvalue()  # (4)
        return res

终于自己找到了解决办法)希望对下一代有用)