PDA

View Full Version : Need help with OCIDescribeAny()


comcrage
12-01-2004, 12:20 PM
Hi,

I've been having problems gettings OCIDescribeAny to work. I got my
code from Visual C++ to connect successfully to the Oracle database
8.0. I want to check and call a stored procedure. After I login, I use
the OCIDescribeAny with the name of stored procedure passed as 1 of
the arguements, but it always return an error stating that the stored
procedure object does not exist. The stored procedure is verifed and
is part of a package. I tried passing both the sp_name and
package_name.sp_name, but the same errors comes back. I even tried
using the OCI_DescribeAny on a table_name, but the same error returns.
Any help is greatly appeciated.

Thanks,

Rage




OCIEnv *p_env;
OCIError *p_err;
OCISvcCtx *p_svc;
OCIStmt *p_sql;
OCIBind *p_bnd;
OCIDescribe* p_desc;

int COraOCI::test()

{


int rc = 0;
int v_val[4] = {1, 91, 57, 12};

char* v_usr = "phureporter";
char* v_pwd = "phureporter";
char* v_tns = "testphu";

char* v_sql = "BEGIN DCL_VALIDATION_PKG.GET_ENROLLEE_INFO(:x, );
END;";



ub4 v_val_cnt = 4;


rc = OCIInitialize((ub4) OCI_OBJECT, (dvoid *)0,
(dvoid * (*)(dvoid *, size_t)) 0,
(dvoid * (*)(dvoid *, dvoid *, size_t))0,
(void (*)(dvoid *, dvoid *)) 0 );
error(rc);

rc = OCIEnvInit( (OCIEnv **) &p_env, OCI_DEFAULT, (size_t) 0,
(dvoid **) 0 );
error(rc);

rc = OCIHandleAlloc( (dvoid *) p_env, (dvoid **) &p_err,
OCI_HTYPE_ERROR,
(size_t) 0, (dvoid **) 0);
error(rc);

rc = OCIHandleAlloc( (dvoid *) p_env, (dvoid **) &p_svc,
OCI_HTYPE_SVCCTX,
(size_t) 0, (dvoid **) 0);
error(rc);

rc = OCIHandleAlloc( (dvoid *) p_env, (dvoid **) &p_sql,
OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0);
error(rc);

rc = OCIHandleAlloc( (dvoid *) p_env, (dvoid **) &p_desc,
OCI_HTYPE_DESCRIBE, (size_t) 0, (dvoid **) 0);

rc = OCILogon(p_env, p_err, &p_svc, (OraText *) v_usr,
strlen(v_usr),
(OraText *) v_pwd, strlen(v_pwd), (OraText *) v_tns,
strlen(v_tns));
error(rc);



text objptr[] = "DCL_VALIDATION_PKG.GET_VEHICLE_INFO";
ub4 objp_len = strlen("DCL_VALIDATION_PKG.GET_VEHICLE_INFO");



rc = OCIDescribeAny(p_svc, p_err, objptr, objp_len, OCI_OTYPE_NAME,
OCI_DEFAULT, OCI_PTYPE_PROC, p_desc);




error(rc); // The error always returns a -1 for rc to pass to the
error function

}

Rauf Sarwar
12-02-2004, 05:20 AM
You should use OCI_PTYPE_PKG for describing packages.... OCI_PTYPE_PROC
is for standalone procedures. Secondly, I don't think your code will
work because you cannot do describe on packaged
procedures/functions.... they are part of the package. Try again by
using OCI_PTYPE_PKG with just the package name.

Regards
/Rauf

Rauf Sarwar
12-02-2004, 09:38 AM
comic_rage@yahoo.com (comcrage) wrote in message news:<ab5d8404.0412011220.2704d1f9@posting.google.com>... Hi, I've been having problems gettings OCIDescribeAny to work. I got my code from Visual C++ to connect successfully to the Oracle database 8.0. I want to check and call a stored procedure. After I login, I use the OCIDescribeAny with the name of stored procedure passed as 1 of the arguements, but it always return an error stating that the stored procedure object does not exist. The stored procedure is verifed and is part of a package. I tried passing both the sp_name and package_name.sp_name, but the same errors comes back. I even tried using the OCI_DescribeAny on a table_name, but the same error returns. Any help is greatly appeciated. Thanks, Rage OCIEnv *p_env; OCIError *p_err; OCISvcCtx *p_svc; OCIStmt *p_sql; OCIBind *p_bnd; OCIDescribe* p_desc; int COraOCI::test() { int rc = 0; int v_val[4] = {1, 91, 57, 12}; char* v_usr = "phureporter"; char* v_pwd = "phureporter"; char* v_tns = "testphu"; char* v_sql = "BEGIN DCL_VALIDATION_PKG.GET_ENROLLEE_INFO(:x, ); END;"; ub4 v_val_cnt = 4; rc = OCIInitialize((ub4) OCI_OBJECT, (dvoid *)0, (dvoid * (*)(dvoid *, size_t)) 0, (dvoid * (*)(dvoid *, dvoid *, size_t))0, (void (*)(dvoid *, dvoid *)) 0 ); error(rc); rc = OCIEnvInit( (OCIEnv **) &p_env, OCI_DEFAULT, (size_t) 0, (dvoid **) 0 ); error(rc); rc = OCIHandleAlloc( (dvoid *) p_env, (dvoid **) &p_err, OCI_HTYPE_ERROR, (size_t) 0, (dvoid **) 0); error(rc); rc = OCIHandleAlloc( (dvoid *) p_env, (dvoid **) &p_svc, OCI_HTYPE_SVCCTX, (size_t) 0, (dvoid **) 0); error(rc); rc = OCIHandleAlloc( (dvoid *) p_env, (dvoid **) &p_sql, OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0); error(rc); rc = OCIHandleAlloc( (dvoid *) p_env, (dvoid **) &p_desc, OCI_HTYPE_DESCRIBE, (size_t) 0, (dvoid **) 0); rc = OCILogon(p_env, p_err, &p_svc, (OraText *) v_usr, strlen(v_usr), (OraText *) v_pwd, strlen(v_pwd), (OraText *) v_tns, strlen(v_tns)); error(rc); text objptr[] = "DCL_VALIDATION_PKG.GET_VEHICLE_INFO"; ub4 objp_len = strlen("DCL_VALIDATION_PKG.GET_VEHICLE_INFO"); rc = OCIDescribeAny(p_svc, p_err, objptr, objp_len, OCI_OTYPE_NAME, OCI_DEFAULT, OCI_PTYPE_PROC, p_desc); error(rc); // The error always returns a -1 for rc to pass to the error function }

You should use OCI_PTYPE_PKG for describing packages.... OCI_PTYPE_PROC
is for standalone procedures. Secondly, I don't think your code will
work because you cannot do describe on packaged
procedures/functions.... they are part of the package. Try again by
using OCI_PTYPE_PKG with just the package name.

Regards
/Rauf


MyLounge.com Site Map
Forum: Cars, Cell Phone, Database, Games, Home Improvement, IT, Music, School, Sports, Web Design, Web Server, Weight Loss

The MyLounge.com forum is intended for informational use only and should not be relied upon and is not a substitute for any advice. The information contained on MyLounge.com are opinions and suggestions of members and is not a representation of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for the accuracy, completeness or usefulness of any postings or the qualifications of any person responding. Please consult a expert or seek the services of an attorney in your area for more accuracy on your specific situation. Please note that our forums also serve as mirrors to Usenet newsgroups. Many posts you see on our forums are made by newsgroup users who may not be members of MyLounge.com Term of Service