发布网友 发布时间:2022-04-23 22:53
共1个回答
热心网友 时间:2023-09-11 09:07
利用TCP实现数据库与外部程序通讯,让数据库服务器通知一个守护程序去执行程序。
set serveroutput on size 100000
DECLARE
c utl_tcp.connection; -- TCP/IP connection to the Web server
i number;
j number;
BEGIN
c := utl_tcp.open_connection('10.18.1.11', 51000); -- open connection
begin
loop
i := utl_tcp.available(c);
exit when i<=0;
dbms_output.put_line('READ='||To_Char(i));
-- while i>0 loop
dbms_output.put(utl_tcp.get_text(c,i)); -- read result
-- i :=i-1;
-- end loop;
end loop;
exception
when others then null;
end;
dbms_output.put_line('');
i := utl_tcp.write_line(c, 'HELLO WORLD');
dbms_output.put_line('WRITE='||To_Char(i));
begin
j := 0;
loop
i := utl_tcp.available(c);
if (i=0) then
j := j+1;
if (j>=50) then
exit;
else
for i in 0..1000 loop
null;
end loop;
end if;
else
dbms_output.put_line('READ='||To_Char(i));
dbms_output.put(utl_tcp.get_text(c,i)); -- read result
end if;
end loop;
exception
when others then null;
end;
dbms_output.put_line('');
utl_tcp.close_connection(c);
end;