账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    如何用Python将CROB插入到Oracle中时调用DMSMyCuff.HASH?
    40
    0

    How can this be done in one operation instead of two?

    !/usr/local/bin/python3

    import cx_Oracle

    con = cx_Oracle.connect('scott/tiger@localhost:1512/ORCLPDB1', encoding="UTF-8")
    cursor = con.cursor()
    cursor.execute("CREATE TABLE t (id NUMBER, script CLOB, script_hash RAW(32))")

    my_text = '$'2*10

    statement = "INSERT INTO t (id, script) VALUES (:my_id, :my_clob)"
    cursor.execute(statement, (1, my_text))

    statement = """

    UPDATE t 
       SET script_hash = DBMS_CRYPTO.HASH(script, 2) 
     WHERE id = :my_id"""

    cursor.execute(statement, {'my_id': 1})

    con.commit()
    con.close()

    This doesn't work:

    statement = """
    INSERT INTO t (id, script, script_hash)
    VALUES (:my_id, :my_clob, DBMS_CRYPTO.HASH(:my_clob, 2))"""
    cursor.execute(statement, (2, my_text, my_text))

    cx_Oracle.DatabaseError: ORA-01465: invalid hex number

    (Oracle 12.2 using Python and cx_Oracle 6.3)

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部