是哪本书里面的范例?能给我吗?我只是帮你查了出错代码而已。

解决方案 »

  1.   

    书名为《Oracle8 PL/SQL程序设计》
    做法如下:
    1。先编一个C过程,代码如下:
    #include <stdio.h>
    #include <oci.h>/* Outputs the string contained in message to a file specified by path.
       The file will be created if it doesn't exist. */
    void OutputString(path, message)
    char *path;
    char *message;  {  FILE *file_handle;  /* Open the file for writing. */
      file_handle = fopen(path, "w");  /* Output the string followed by a newline. */
      fprintf(file_handle, "%s\n", message);  /* Close the file. */
      fclose(file_handle);
    }
    2。将其编译为一个后缀为.so的共享库。
    3。如下设置Listener。ora、Tnsnames。ora
    LISTENER。ORA:
    listener =
      (ADDRESS_LIST =
        (ADDRESS =
           (PROTOCOL = ipc)
           (KEY = <<LISTENER_KEY>>)
        )
      )sid_list_listener =
      (SID_LIST =
        (SID_DESC =
          (SID_NAME = <<EXTPROC_SID>>)
          (ORACLE_HOME = <<ORACLE_HOME>>)
          (PROGRAM = extproc)
        )
      )
    TNSNAMES。ORA
    extproc_connection_data =
      (DESCRIPTION =
        (ADDRESS =
          (PROTOCOL = ipc)
          (KEY = <<LISTENER_KEY>>)
        )
        (CONNECT_DATA =
          (SID = <<EXTPROC_SID>>)
        )
      )
    4。在Oracle中敲入:
    CREATE LIBRARY stringlib AS “C过程路径名”
    5。CREATE OR REPLACE PROCEDURE OutputString(
      p_Path IN VARCHAR2,
      p_Message IN VARCHAR2) AS EXTERNAL  LIBRARY stringlib
      NAME "OutputString"
      PARAMETERS (p_Path STRING,
                  p_Message STRING);