PL/SQLããDLLãå¼ã³åºã
çããä»äºé¢é£ãªè©±é¡ãPL/SQLããDLLãå¼ã³åºãã«ã¯ã©ãããã°è¯ãã質åãããã®ã§ãã¡ãã£ã¨èª¿ã¹ã¦ã¿ã¾ããã
listener.oraã«ä»¥ä¸ã®è¨è¿°ã追å ã
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0)) ) ... ) SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = C:\Oracle\Ora92) (PROGRAM = extproc) ) ... )
ORACLE_HOMEã¯ç°å¢ã«åãããã
tnsnames.oraã«ä»¥ä¸ã®è¨è¿°ã追å ã
EXTPROC_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0)) ) (CONNECT_DATA = (SID = PLSExtProc) (PRESENTATION = RO) ) )
ããã§ãªã¹ãã¼ãåèµ·åã
PL/SQLããå¼ã³åºããµã³ãã«DLLãä½ã£ã¦ã¿ãã
hello.c
#include <stdio.h> __declspec(dllexport) void hello(char* key, char* msg) { sprintf (msg, "Hello, %s", key); }
ã³ã³ãã¤ã«ãã¦hello.dllãä½æããã
$ cl /MD /LD hello.c
PL/SQLããå¼ã³åºãDLLã¯%ORACLE_HOME%\binã«ç½®ã(windowsçã®å¶éï¼)
$ copy hello.dll %ORACLE_HOME%\bin
DLLãå¼ã³åºãããã·ã¼ã¸ã£ãç¨æããã
CREATE OR REPLACE LIBRARY hellolib AS '$ORACLE\bin\hello.dll'; CREATE OR REPLACE PROCEDURE Hello (key IN VARCHAR2, msg OUT VARCHAR2) IS EXTERNAL NAME "hello" LIBRARY hellolib PARAMETERS (key STRING, msg STRING);
ãããSQL*Plusã§æµãã
SQL*Plusããå¼ã³åºãã¦ã¿ãã
> var msg VARCHAR2(255); > call Hello ('World', :msg); > print msg; Hello, World
ã¡ã¢ãä¼ç¤¾ã«ç½®ãã¦ãã¦ãã¾ããæãåºããªãããªã®ã§ééã£ã¦ããããã(^^;
(追è¨) æ¡ã®å®ééãã¦ããã»ã»ã»