Oracle—在不安装oracle客户端的情况下,使用PL/SQL Developer 14
在使用plsql时,需要指定OCI.DLL文件,这就需要安装oracle客户端,不过oracle客户端软件有点庞大,推荐使用下面方法不依赖oracle客户端来使用plsql。
1、准备
虽然不用oracle客户端,但是也要用到一个工具包--instantclient,可以到oracle官网下载(视具体操作系统版本下载对应文件):
2、下载完毕文件名为 instantclient-basic-windows.x64-21.6.0.0.0dbru.zip
3、解压到你自己指定的路径(如C:\Users\11513\Oracle),那么主目录就是 C:\Users\11513\Oracle\instantclient_21_6
4、创建在C:\Users\11513\Oracle\instantclient_21_6\network\admin路径下创建文件tnsnames.ora,内容如下:
# tnsnames.ora Network Configuration File: f:\app\guoshaoyue\product\11.2.0\client_1\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.
ZSYKTEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.133.194)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ZSYKTEST)
)
)
|
5、配置PL/SQL
依次打开“tools--preferences--connection”,配置:
Oracle Home(Oracle主目录):C:\Users\11513\Oracle\instantclient_21_6
OCI library(OCI库):C:\Users\11513\Oracle\instantclient_21_6\oci.dll
6、PL/SQL的SQL窗口执行代码段,注意一定要以 “/” 结尾,否则啥也不会输出:
--set serveroutput on;
declare
v_code number;
v_ret varchar(200);
begin
-- Call the procedure
prpa.PGETREPORTMSG(V_IN_CardType =>'1',
V_IN_CardNo=> 'K093',
V_OUT_RETCODE=> v_code,
V_OUT_RETMSG=> v_ret);
DBMS_OUTPUT.PUT_LINE('V_OUT_RETCODE ="' ||v_code || '"');
DBMS_OUTPUT.PUT_LINE('V_OUT_RETMSG ="' || v_ret|| '"');
end;
/
6、PL/SQL的命令窗口执行代码段,注意一定也要以 “/” 结尾(包括执行SQL文件),否则啥也不会输出:
Connected to Oracle Database 19c Enterprise Edition Release 19.0.0.0.0
Connected as apps@172.18.133.194:1521/ZSYKTEST
SQL>
SQL> declare
2 v_code number;
3 v_ret varchar(200);
4 begin
5 -- Call the procedure
6 prpa.PGETREPORTMSG(V_IN_CardType => '1',
7 V_IN_CardNo => 'K093',
8 V_OUT_RETCODE => v_code,
9 V_OUT_RETMSG => v_ret);
10 DBMS_OUTPUT.PUT_LINE('V_OUT_RETCODE = "' || v_code || '"');
11 DBMS_OUTPUT.PUT_LINE('V_OUT_RETMSG = "' || v_ret || '"');
12 end;
13 /
V_OUT_RETCODE = "5"
V_OUT_RETMSG = " 您的预约报到开始时间为11:30,请于开始后报到。"
PL/SQL procedure successfully completed
SQL>
|
Connected to Oracle Database 19c Enterprise Edition Release 19.0.0.0.0
Connected as apps@172.18.133.194:1521/ZSYKTEST
SQL> @F:\plsqldoc\test.sql
V_OUT_RETCODE = "5"
V_OUT_RETMSG = " 您的预约报到开始时间为11:30,请于开始后报到。"
PL/SQL procedure successfully completed
SQL>
|
F:\plsqldoc\test.sql文件的内容:
--set serveroutput on;
declare
v_code number;
v_ret varchar(200);
begin
-- Call the procedure
prpa.PGETREPORTMSG(V_IN_CardType =>'1',
V_IN_CardNo=> 'K093',
V_OUT_RETCODE=> v_code,
V_OUT_RETMSG=> v_ret);
DBMS_OUTPUT.PUT_LINE('V_OUT_RETCODE ="' ||v_code || '"');
DBMS_OUTPUT.PUT_LINE('V_OUT_RETMSG ="' || v_ret|| '"');
end;
/