Home » SQL & PL/SQL » SQL & PL/SQL » External procedure error (9i)
External procedure error [message #423722] Sun, 27 September 2009 06:52 Go to next message
kashifchughtai
Messages: 113
Registered: October 2007
Senior Member
Hi all,

I am getting the following error when calling one of the external procedure using a oracle library.

"ORA-06525 Length Mismatch for CHAR or RAW data"

any idea about the issue?
Re: External procedure error [message #423724 is a reply to message #423722] Sun, 27 September 2009 06:59 Go to previous messageGo to next message
kashifchughtai
Messages: 113
Registered: October 2007
Senior Member
Though i got the following information

but stilll not able to rectify...

ORA-06525: Length Mismatch for CHAR or RAW data
Cause: The length specified in the length variable has an illegal value. This can happen if you have requested requested a PL/SQL INOUT, OUT or RETURN raw variable to be passed as a RAW with no corresponding length variable. This error can also happen if there is a mismatch in the length value set in the length variable and the length in the orlvstr or orlraw.

Action: Correct the external procedure code and set the length variable correctly.

[Updated on: Sun, 27 September 2009 07:00]

Report message to a moderator

Re: External procedure error [message #423726 is a reply to message #423724] Sun, 27 September 2009 08:33 Go to previous messageGo to next message
ThomasG
Messages: 3185
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Well. You have to correct the external procedure code.

We can't see that, nor can we see which code you actually use to call it. Nobody here is a remote-mind-reader, you know.
Re: External procedure error [message #423728 is a reply to message #423726] Sun, 27 September 2009 08:48 Go to previous message
kashifchughtai
Messages: 113
Registered: October 2007
Senior Member
Thomas,

I was intended to get the genernal idea about the issue.

Anyway just see the code below for external program

void mq_LongRead (OCIExtProcContext *with_context,long p_inqueuehandle,
                 long p_inobjhandle,unsigned char *p_outmessage,
                 long *p_outmessage_len, long *p_outmessage_maxlen,
                 int *p_outerrcode,char *p_outerrmsg)
{
  FILE *fp;
  int retval;
  long i;

    memset(tmp_errormsg,'\0',500);
    CompCode = OpenCode;       /* use MQOPEN result for initial test  */

    Hcon=p_inqueuehandle;
    Hobj=p_inobjhandle;
    /******************************************************************/
    /*   Get messages from the message queue                          */
    /*   Using Commit and RollBack for transaction                    */
    /******************************************************************/

     buflen = sizeof(char_buffer) - 1; /* buffer size can be changed at top  */
     memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId));
     memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId));
     memcpy(md.Format,
                  MQFMT_STRING, (size_t)MQ_FORMAT_LENGTH);

     md.Encoding       = MQENC_NATIVE;
     md.CodedCharSetId = MQCCSI_Q_MGR;

     gmo.Options = MQGMO_WAIT
                        + MQGMO_CONVERT ;

    /********************************************************************/
     /*      Read from MQM                                               */
     /********************************************************************/
     MQGET(Hcon,                /* connection handle                 */
           Hobj,                /* object handle                     */
           &md,                 /* message descriptor                */
           &gmo,                /* get message options               */
           buflen,              /* buffer length                     */
           char_buffer,         /* message buffer                    */
           &messlen,            /* message length                    */
           &CompCode,           /* completion code                   */
           &Reason);            /* reason code                       */

     if (Reason != MQRC_NONE)
     {
       if (Reason == MQRC_NO_MSG_AVAILABLE)
       {     /* special report for normal end    */
             strcpy(tmp_errormsg,"Queue is empty \n");
             strcpy(p_outerrmsg,tmp_errormsg);
             *p_outerrcode = 0; /* Return value is set to 0, when Q is empty*/
             p_outmessage[0]=(unsigned char) '\0';
             *p_outmessage_len = 0;
             *p_outmessage_maxlen = 32000;
             CompCode = MQCC_FAILED;
       }
       else  /* general report for other reasons */
       {
             strcpy(tmp_errormsg,"MQGet ended with reason code : ");
             strcat(tmp_errormsg,itoa(Reason));
             strcpy(p_outerrmsg,tmp_errormsg);

             /*   treat truncated message as a failure for this sample   */
             if (Reason == MQRC_TRUNCATED_MSG_FAILED)
                CompCode = MQCC_FAILED;
       }
     }
     if (CompCode != MQCC_FAILED)
     {
            char_buffer[messlen] = '\0';   /* add terminator   */
            /*memcpy(p_outmessage,char_buffer,messlen);*/

           for (i=0;i<= messlen;i++)
           {
              p_outmessage[i]=(unsigned char)char_buffer[i];
              if (retval==EOF)
                  break;
           }
           *p_outmessage_len = messlen;
           *p_outmessage_maxlen = 32000;


            /* Call MQCMIT to delet read msg from queue */
           MQCMIT(Hcon, &SyncCompCode, &SyncReason);
           strcpy(p_outerrmsg,"Read Successful    \n");

           /* The following code used to check the readmsg text in a file
           fp= fopen("/harpoon17/clpdev/mqs/readmsg.txt","a");
           fprintf(fp,"New msg read is follows\n");
           for (i=0;i<= messlen;i++)
           {
              retval=fputc(p_outmessage[i],fp);
              if (retval==EOF)
                  break;
           }
           fclose(fp);
           */
      }
}


************************************

and i m calling it like

CREATE OR REPLACE PROCEDURE MqLongRead
/**************************************************************************************
*  Purpose  : Prcedure to call external PRO *C procedure mq_LongRead
***************************************************************************************/

   (
    QHandle    in  binary_integer,
    ObjHandle  in  binary_integer,
    outmessage out RAW,
    outerrcode out binary_integer,
    outerrmsg  out varchar2
    ) is
    external name "mq_LongRead"
    library libmqs
    with CONTEXT
    parameters
              (
               CONTEXT,
               QHandle    long,
               ObjHandle  long,
               outmessage RAW,
               outmessage LENGTH,
               outmessage MAXLEN,
               outerrcode int,
               outerrmsg  string

              );
Previous Topic: greater of value in a given list
Next Topic: select query to take row value as column name
Goto Forum:
  


Current Time: Wed Sep 28 17:45:02 CDT 2016

Total time taken to generate the page: 0.15522 seconds