Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: OCI program
Yacov Wolfowicz wrote:
> The problem arises when there are some records in the files which have
> the same key ( which is supposed to be unique in the table). Now, the
> whole insert action is failed and none of the 200 records was inserted.
> My question is this: is there a way for me to retreive the INDEX of the
> record that failed? ( let's say that i get an error saying : "record no.
> 95 failed to be inserted" ). That way i can remove the faulty record and
> try again.
I think the errors are in the form of multiple records, like this.... this fn is just for debugging .. might help ..
const int ERR_STRING_LEN = (1024*4);
char oci_errorstring[ERR_STRING_LEN];
char *checkerr(OCIError *errhp, sword status)
{
unsigned char * buff = 0;
long errcode = 0;
char * retval = "unknown OCI error";
int err_call_result = OCI_SUCCESS;
ub4 err_record = 1;
try
{ memset(oci_errorstring, 0, ERR_STRING_LEN); switch (status) { case OCI_SUCCESS: default: break; case OCI_SUCCESS_WITH_INFO: retval = "Error - OCI_SUCCESS_WITH_INFO\0"; break; case OCI_NEED_DATA: retval = "Error - OCI_NEED_DATA\0"; break; case OCI_NO_DATA: retval = "Error - OCI_NODATA\0"; break; case OCI_ERROR: lstrcpy(oci_errorstring, "Error - "); while(err_call_result == OCI_SUCCESS) { buff = (unsigned char *)&(oci_errorstring[lstrlen(oci_errorstring)]); err_call_result = OCIErrorGet(errhp, err_record++, NULL, &errcode, buff, (ub4)ERR_STRING_LEN-lstrlen(oci_errorstring), OCI_HTYPE_ERROR); } retval = oci_errorstring; break; case OCI_INVALID_HANDLE: retval = "Error - OCI_INVALID_HANDLE\0"; break; case OCI_STILL_EXECUTING: retval = "Error - OCI_STILL_EXECUTE\0"; break; }; }
![]() |
![]() |