Skip to content

Question - How to get out values from a stored procedure? #95

Closed
@Skada13

Description

@Skada13

oracle = 0.6.3
rust = 1.84.0

Hello Kubo!

I faced a problem with executing a stored oracle procedure that pushes customers payments to our billing. The procedure is:

BEGIN
    EX_PAYMENTS_PKG.EX_PAYMENTS_CHARGE(
        vch_VC_TO_BANK          => :1,
        vch_VC_TO_ACCOUNT       => :2,
        num_N_SUM               => :3,
        vch_VC_TRANSACTION_ID   => :4,
        num_N_FORWHO_ACCOUNT_ID => :5,
        dt_D_TAKING             => :6,
        num_N_DOC_ID            => :7,  -- OUT PARAMETER (NUMBER)
        dt_D_LOAD               => :8   -- OUT PARAMETER (DATE)
        );
    COMMIT;
END;

This procedure has two out parameters - num_N_DOC_ID and dt_D_LOAD that should be returned after executing the procedure. I've binded every value during the execution include the out parameters.

My code is:

let sql = """BEGIN
    EX_PAYMENTS_PKG.EX_PAYMENTS_CHARGE(
        vch_VC_TO_BANK          => :1,
        vch_VC_TO_ACCOUNT       => :2,
        num_N_SUM               => :3,
        vch_VC_TRANSACTION_ID   => :4,
        num_N_FORWHO_ACCOUNT_ID => :5,
        dt_D_TAKING             => :6,
        num_N_DOC_ID            => :7,  -- OUT PARAMETER (NUMBER)
        dt_D_LOAD               => :8   -- OUT PARAMETER (DATE)
        );
    COMMIT;
END;""";
let mut stmt = conn.statement(&sql).build()?;
stmt.execute(&[&bank.bank,
                          &bank.account,
                          &1,
                          &transaction_id,
                          &account_id,
                          date,
                          &oracle::sql_type::OracleType::Int64,  // 7th out parameter 
                          &oracle::sql_type::OracleType::Date   // 8th out parameter
])?;
let doc_id: String = stmt.bind_value(7)?;   // trying to get 7th out parameter
println!("{}", doc_id);

After running this code I get the error "NULL value found", and nothing happens in the billing.

Could you tell me how to execute procedures like this one correctly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions