I'm trying to execute a stored procedure with a REF CURSOR
parameter.
My stored procedure is something like:
PROCEDURE procName(p_in_str IN VARCHAR2, p_out_result IN OUT SYS_REFCURSOR) ...
And I have based on these post to try to execute it from R:
After many errors I have reached a point where I can not move forward. Thes are my current approaches
Attempt 1
# Not error but not return data temp_output1 <- data.frame(p_in_str = "My string", stringsAsFactors = FALSE) attr(temp_output1$p_in_str, "ora.parameter_name") <- "p_in_str"; attr(temp_output1$p_in_str, "ora.parameter_mode") <- "IN"; rs <- oracleProc(con, "DECLARE c SYS_REFCURSOR; BEGIN procname(:p_in_str, c); END;", data = temp_output1)
Attempt 2
# Wrong number or types of arguments temp_output2 <-data.frame(p_in_str = "My string", p_out_ref = "p_out_ref", stringsAsFactors = FALSE) attr(temp_output2$p_in_str, "ora.parameter_name") <- "p_in_str"; attr(temp_output2$p_in_str, "ora.parameter_mode") <- "IN"; attr(temp_output2$p_out_ref, "ora.parameter_name") <- "p_out_ref"; attr(temp_output2$p_out_ref, "ora.parameter_mode") <- "IN OUT"; attr(temp_output2$p_out_ref, "ora.type") <- "SYS_REFCURSOR" rs <- oracleProc(con, "BEGIN procname(:p_in_str, :p_out_ref); END;", data = temp_output2)
Error in .oci.oracleProc(conn, statement, data = data, prefetch = prefetch,
: ORA-06550: line 2, column 18: PLS-00306: wrong number or types of arguments in call to 'procname' ORA-06550: line 2, column 18: PL/SQL: Statement ignoredAttempt 3
# Bind data does not match bind specification temp_output3 <-data.frame(p_in_str = "My string", p_out_ref = as.character(NA), stringsAsFactors = FALSE) attr(temp_output3$p_in_str, "ora.parameter_name") <- "p_in_str"; attr(temp_output3$p_in_str, "ora.parameter_mode") <- "IN"; attr(temp_output3$p_out_ref, "ora.parameter_name") <- "p_out_ref"; attr(temp_output3$p_out_ref, "ora.parameter_mode") <- "IN OUT"; attr(temp_output3$p_out_ref, "ora.type") <- "m_ref_cursor" rs <- oracleProc(con, "DECLARE c SYS_REFCURSOR; BEGIN procname(:p_in_str, c); END;", data = temp_output3)
Error in .oci.oracleProc(conn, statement, data = data, prefetch = prefetch, : bind data does not match bind specification