PLS-00306:调用现有存储过程时参数数量或类型错误
我在 C 代码中使用现有的存储过程。 所讨论的存储过程已被编译并被证明可以正常工作,没有任何错误。但是,当我在 C 代码中使用相同的内容时,它会因上述错误而失败。
存储过程定义如下所示:
CREATE OR REPLACE FUNCTION SP(
srq_id integer ,
unid IN SPkg.arr_parmid,
parm_typ IN SPkg.arr_parm_typ,
parm_lbl IN SPkg.arr_parm_lbl,
parm_vlu IN SPkg.arr_parm_vlu,
commit_flag INTEGER DEFAULT 1,
vlu_hint IN SPkg.arr_vlu_hint,
create_flag INTEGER DEFAULT 0)
RETURN INTEGER
类型定义
TYPE arr_parm_typ IS TABLE OF char INDEX BY BINARY_INTEGER;
TYPE arr_parmid IS TABLE OF tbl_parm.UNID%TYPE INDEX BY BINARY_INTEGER;
TYPE arr_parm_lbl IS TABLE OF tbl_parm.PARM_LBL%TYPE INDEX BY BINARY_INTEGER;
TYPE arr_parm_vlu IS TABLE OF tbl_parm.PARM_VLU%TYPE INDEX BY BINARY_INTEGER;
TYPE arr_vlu_hint IS TABLE OF tbl_parm.VLU_HINT%TYPE INDEX BY BINARY_INTEGER;
我的 C 代码如下所示:
typedef struct param
{
char lbl[30][81];
char vlu[30][256];
char typ[30];
ub8 seq_no[30];
char vlu_hint[30];
}PARAM;
ub8 srqid;
int commit_flag;
int create_flag;
PARAM p_array;
我调用存储过程的方式:
char command[250] = "begin :retval := SSP_srq_parm_all(:srq_id,:unid,:parm_typ,:parm_lbl,:parm_vlu,:commit_flag,:vlu_hint,:create_flag); end;";
OCIStmtPrepare2((OCISvcCtx *)svchp, (OCIStmt **)&(stmthp),
(OCIError *)errhp, (OraText *)command,
(ub4)strlen((char*)command), (OraText *)NULL, (ub4)0,
OCI_NTV_SYNTAX, OCI_DEFAULT);
//..... calls to OCIBindByName & OCIBindArrayOfStruct here..........
status= OCIStmtExecute(svchp, stmthp,errhp, (ub4)1, (ub4) 0,(CONST OCISnapshot *) NULL,(OCISnapshot *) NULL, OCI_DEFAULT);
OCIStmtExecute() 失败并出现上述错误。 如果您需要了解“绑定”调用的样子,请告诉我。我不会立即粘贴它们,因为代码块相当大。 有人可以帮忙吗?
I'm using an existing stored procedure in my C code.
The stored procedure in question has been compiled and is proven to work without any errors. However, when I use the same in my C code, its failing with the above error.
The Store procedure definition looks like :
CREATE OR REPLACE FUNCTION SP(
srq_id integer ,
unid IN SPkg.arr_parmid,
parm_typ IN SPkg.arr_parm_typ,
parm_lbl IN SPkg.arr_parm_lbl,
parm_vlu IN SPkg.arr_parm_vlu,
commit_flag INTEGER DEFAULT 1,
vlu_hint IN SPkg.arr_vlu_hint,
create_flag INTEGER DEFAULT 0)
RETURN INTEGER
Type definitions
TYPE arr_parm_typ IS TABLE OF char INDEX BY BINARY_INTEGER;
TYPE arr_parmid IS TABLE OF tbl_parm.UNID%TYPE INDEX BY BINARY_INTEGER;
TYPE arr_parm_lbl IS TABLE OF tbl_parm.PARM_LBL%TYPE INDEX BY BINARY_INTEGER;
TYPE arr_parm_vlu IS TABLE OF tbl_parm.PARM_VLU%TYPE INDEX BY BINARY_INTEGER;
TYPE arr_vlu_hint IS TABLE OF tbl_parm.VLU_HINT%TYPE INDEX BY BINARY_INTEGER;
My C code looks like :
typedef struct param
{
char lbl[30][81];
char vlu[30][256];
char typ[30];
ub8 seq_no[30];
char vlu_hint[30];
}PARAM;
ub8 srqid;
int commit_flag;
int create_flag;
PARAM p_array;
The way I invoke the stored procedure:
char command[250] = "begin :retval := SSP_srq_parm_all(:srq_id,:unid,:parm_typ,:parm_lbl,:parm_vlu,:commit_flag,:vlu_hint,:create_flag); end;";
OCIStmtPrepare2((OCISvcCtx *)svchp, (OCIStmt **)&(stmthp),
(OCIError *)errhp, (OraText *)command,
(ub4)strlen((char*)command), (OraText *)NULL, (ub4)0,
OCI_NTV_SYNTAX, OCI_DEFAULT);
//..... calls to OCIBindByName & OCIBindArrayOfStruct here..........
status= OCIStmtExecute(svchp, stmthp,errhp, (ub4)1, (ub4) 0,(CONST OCISnapshot *) NULL,(OCISnapshot *) NULL, OCI_DEFAULT);
OCIStmtExecute() fails with the above error.
Please let me know if you need to know how the 'bind' calls look like. I dint paste them right away because the code chunk is pretty big.
Can someone please help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,函数不是过程——但这不是问题所在。由于您使用了正确数量的参数,唯一可能的情况是您正在使用的自定义类型的实现在 Oracle 和 C 之间不匹配。它们在 PL/SQL 中是如何定义的?
Firstly, a function is not a procedure - but that isn't the problem. Since you're using the correct number of parameters, the only thing that it could be is that the implementation of the custom types you're using don't match between Oracle and C. How are they defined in PL/SQL?