Передайте параметры с нулевыми значениями с параметром keywordParamters в cx_Oracle - PullRequest
0 голосов
/ 30 ноября 2018

Это то, что я пытаюсь сделать

def execM2StoredProc(params, storedProcName):
    conn = dbConnection(db=sandra.db)
    cursor = conn.cursor()

    for p, v in params.iteritems():
        if p in ['padmin_no','pusi_trade_ref_id','pbranch_trade_id','pversion','pdealer_intervention_id','pibt_short_code']:
            params[p] = cursor.var(cx_Oracle.STRING)
        elif v[1] is not None:
            if v[0] is not None:
                if v[1] =='bit':
                    if v[0].upper() in ['FALSE','TRUE']:
                        params[p] = v[0][0]
                    elif len(v[0])==1:
                        try:
                            params[p] = int(v[0])
                        except ValueError as e:
                            print e.message
                        finally:
                            params[p] = v[0]
                    else:
                        params[p] = v[0]
                elif v[1] in ['int', 'number', 'Double']:
                    if isinstance(v[0],list):
                        params[p] = cursor.arrayvar(cx_Oracle.NUMBER, [float(i) for i in v[0]])
                    else:
                        params[p] = float(v[0])
                elif v[1] == 'date':
                    if isinstance(v[0],list):
                        params[p] = cursor.arrayvar(cx_Oracle.TIMESTAMP, [datetime.strptime(i, '%Y%m%d').date() for i in v[0]])
                    else:
                        params[p] = datetime.strptime(v[0], '%Y%m%d').date()
                elif v[1] == 'datetime':
                    if isinstance(v[0],list):
                        params[p] = cursor.arrayvar(cx_Oracle.TIMESTAMP, [datetime.strptime(i, '%Y%m%d') for i in v[0]])
                    else:
                        params[p] = datetime.strptime(v[0], '%Y%m%d %H%M%S')
                elif v[1] == 'String':
                    if isinstance(v[0],list):
                        params[p] = cursor.arrayvar(cx_Oracle.STRING, [i for i in v[0]])
                    else:
                        params[p] = v[0]
                else:
                    params[p]=v[0]
            else:
                var = cursor.var(CX_ORACLE_TYPES[v[1]])
                cursor.setinputsizes(None, var)
                params[p] = None
        else:
            params[p] = v[0]

    try:
        ret = cursor.callproc(storedProcName, [], params)
        # conn.commit()

    except Exception as e:
        print e.message
    finally:
        conn.close()
        return False
    return True

, и это приводит к следующей ошибке:

ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'PRC_UPD_PRODUCT_VANILLA'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

Что здесь не так?Спасибо!

...