Results 1 to 10 of 10
  1. #1
    Join Date
    Mar 2004
    Location
    Berkshire, UK
    Posts
    186

    Question Unanswered: ORA-06520: PL/SQL: Error loading external library on 11g, worked on 10g

    I have an external C library that have been using for years to extracy binary data (images, docs, pdfs etc) from a blob column in a table

    This has been working on Oracle 10.2.0.1 on Windows 32 bit for years.

    I have a new server, Windows 2008 64 bit, have installed 11.2.0.1, created a database and done a full datapump export and import.

    My application seems to work fine with the exception of this external dll

    ORA-06520: PL/SQL: Error loading external library
    ORA-06522: Unable to load DLL
    ORA-06512: at "OUTPUTSTRING", line 1


    I have made sure the dll is in the correct directory on the server and the library is pointing to it :

    Code:
    create or replace library EXTERNPROCEDURES as 'C:\oracle\extern\extern.dll';
    I then have the same wrapper code that works fine on 10g, is there something I need to do on 11g to "authorise" the external dll or anything as I know the security is tighter or is there an issue with the fact this is 64bit Oracle?

    I have set the listener.ora to be the same as on 10g

    Code:
    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS_LIST =
            (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
          )
          (ADDRESS_LIST =
            (ADDRESS = (PROTOCOL = TCP)(HOST = DB12)(PORT = 1521))
          )
        )
      )
     
    SID_LIST_LISTENER =
      (SID_LIST =
        (SID_DESC =
          (SID_NAME = PLSExtProc)
          (ENVS = "EXTPROC_DLLS=ANY")
          (ORACLE_HOME = c:\oracle\ora11g)
          (PROGRAM = extproc)
        )
        (SID_DESC =
          (GLOBAL_DBNAME = UPAD)
          (ORACLE_HOME = c:\oracle\ora11g)
          (SID_NAME = UPAD)
        )
      )
    And the TNS names file

    Code:
    EXTPROC_CONNECTION_DATA =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
        (CONNECT_DATA =
          (SID = PLSExtProc)
          (PRESENTATION = RO)
        )
      )

    Wrapper:

    Code:
    create or replace procedure OutputString(
      p_Path in varchar2,
      p_Message in varchar2,
      p_mode in varchar2,
      p_NumLines in binary_integer)
    as
    external
      library externProcedures
      name "OutputString"
      with context
      parameters (context,
                  p_Path string,
                  p_path INDICATOR,
                  p_Message string,
                  p_message INDICATOR,
                  p_mode string,
                  p_mode INDICATOR,
                  p_NumLines int,
                  p_numlines INDICATOR)
    ;

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >name "OutputString"

    what happens if/when you replace line above with line below?

    name "OUTPUTSTRING"
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Mar 2004
    Location
    Berkshire, UK
    Posts
    186
    I get the same error

    Code:
    create or replace procedure OUTPUTSTRING(
      p_Path in varchar2,
      p_Message in varchar2,
      p_mode in varchar2,
      p_NumLines in binary_integer)
    as
    external
      library EXTERNPROCEDURES
      name "OUTPUTSTRING"
      with context
      parameters (context,
                  p_Path string,
                  p_path INDICATOR,
                  p_Message string,
                  p_message INDICATOR,
                  p_mode string,
                  p_mode INDICATOR,
                  p_NumLines int,
                  p_numlines INDICATOR)
    ;
    There are 10 types of people in the world, those that know Binary and those that don't.

  4. #4
    Join Date
    Mar 2004
    Location
    Berkshire, UK
    Posts
    186
    for what its worth this is the original C code

    Code:
    #include <oci.h>
    
    #define NullValue -1
    #include<stdio.h>
    #include<string.h>
    										
    long __declspec(dllexport) OutputString(context , 
    					path ,  path_ind ,  
    					message , message_ind,
    					filemode ,  filemode_ind , 
    					len ,  len_ind )  
    
    char *path;
    char *message;  
    char *filemode;
    int len;
    OCIExtProcContext *context;
    short              path_ind;
    short              message_ind;
    short              filemode_ind;
    short              len_ind;  
    
    {
     
      FILE *file_handle;
      int i ;
      char str[3];
      int value;
     
      /* Check whether any parameter passing is null  */
    
       if (path_ind == OCI_IND_NULL || message_ind == OCI_IND_NULL ||
          filemode_ind  == OCI_IND_NULL || len_ind == OCI_IND_NULL ) {
          text *initial_msg = (text *)"One of the Parameters Has a Null Value!!! ";
        text *error_msg;
    
        /* Allocate space for the error message text, and set it up.
        We do not have to free this memory - PL/SQL will do that automatically. */
        error_msg = OCIExtProcAllocCallMemory(context,
                      strlen(path) + strlen(initial_msg) + 1);
        strcpy((char *)error_msg, (char *)initial_msg);
        /*strcat((char *)error_msg, path); */
    
        OCIExtProcRaiseExcpWithMsg(context, 20001, error_msg, 0);
        
    
        /* OCIExtProcRaiseExcp(context, 6502); */
        return 0;
      }  
      
     
       /* Open the file for writing. */
    
      file_handle = fopen(path, filemode);
      
      /* Check for success.  If not, raise an error. */
    
      if (!file_handle) {
        text *initial_msg = (text *)"Cannot Create file ";
        text *error_msg ;
    
        /* Allocate space for the error message text, and set it up.
        We do not have to free this memory - PL/SQL will do that automatically. */
        error_msg = OCIExtProcAllocCallMemory(context,
                      strlen(path) + strlen(initial_msg) + 1);
        strcpy((char *)error_msg, (char *)initial_msg);
        strcat((char *)error_msg, path);
    
    
        OCIExtProcRaiseExcpWithMsg(context, 20001, error_msg, 0);
        return 0;
      }
    
      i = 0;
      
      while (i < len) 
       {
    
          /* Read the hexadecimal value(1). */
          str[0] = message[i]; 
    
    	  i++;
    
          /* Read the hexadecimal value(2).         */
          str[1] = message[i]; 
    
             /* Convert the first byte to the binary value. */
             if (str[0] > 64 && str[0] < 71)  
                str[0] = str[0] - 55;
             else
                str[0] = str[0] - 48;
    
             /* Convert the second byte to the binary value. */
             if (str[1] > 64 && str[1] < 71)
                str[1] = str[1] - 55;
             else
                str[1] = str[1] - 48; 
    
             /* Convert the hex value to binary (first & second byte). */
             value = str[0] * 16 + str[1];
    
             /* Write the binary data to the binary file. */
             fprintf(file_handle,"%c",value); 
    
    		 i++;
          
       }
    
      /* Output the string followed by a newline. */
    
       /* fwrite(message,len,1,file_handle);  */
    
      /* Close the file. */
      fclose(file_handle);
    }
    There are 10 types of people in the world, those that know Binary and those that don't.

  5. #5
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    I don't do Windows & on *nix V11 jobs run as OS user "nobody"; so file permissions can be a problem.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  6. #6
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Did you recompile the DLL with 11g libraries and headers?

  7. #7
    Join Date
    Mar 2004
    Location
    Berkshire, UK
    Posts
    186
    The dll has not been compiled for 10 years, it has been used in 8i, 9i and 10g over the last 10 years.

    I could be wrong but it seems to be an issue just finding it rather than an issue with the dll itself
    There are 10 types of people in the world, those that know Binary and those that don't.

  8. #8
    Join Date
    Mar 2004
    Location
    Berkshire, UK
    Posts
    186
    Quote Originally Posted by n_i View Post
    Did you recompile the DLL with 11g libraries and headers?
    I *think* the issue is the fact the os is 64bit looking on metalink.

    I compiled the dll about 10 years ago and really can't recall how I did it!!

    I've been looking at Developing Applications for Windows and it says I can cal the make.bat ... though when I run that it just says 'cl is not recognised'

    Do I need a C compiler to be installed on the server, the doc isn't really clear?
    There are 10 types of people in the world, those that know Binary and those that don't.

  9. #9
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >Do I need a C compiler to be installed on the server, the doc isn't really clear?
    Yes or on another 64-bit system & then use sneakernet on the new DLL
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  10. #10
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    procedure should be version independent

    Ask Tom "Creating dll for executing external proc..."
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •