|
|
| Howto: Overview
of internet Packages in Oracle Database -- UTL_TCP |
| Aug 1,
2001 |
| Tyranno |
| Author's Bio | E-Mail |
| Copyright (C) 2001
exzilla.net |
|
HOWTO: Overview
of Internet Packages in Oracle Database -- UTL_TCP
Prerequistires:
Oracle8i or later
Purpose:
UTL_TCP package มี Procedures และ Functions ต่างๆ เพื่อให้เราสามารถพัฒนา
PL/SQL Application ที่ติดต่อสื่อสาร (Communicate) กับ Server ต่างๆ
ที่ทำงานอยู่บนพื้นฐานของTCP/IP (TCP/IP-Based Servers) ได้
Step-by-Step Example:
ตัวอย่างการใช้งาน utl_tcp Package
Create Anonymous
PL/SQL Block
DECLARE
c utl_tcp.connection; -- TCP/IP connection to echo port
ret_val pls_integer;
BEGIN
c := utl_tcp.open_connection(remote_host => 'archer.exzilla.net',
remote_port => 7,
charset => NULL); -- open connection
ret_val := utl_tcp.write_line(c,
'Hi echo port : line number 1 '); -- send simple string to echo server
dbms_output.put_line(
utl_tcp.get_line(c, TRUE)); -- read result
ret_val := utl_tcp.write_line(c,
'Hi echo port : line number 2 '); -- send simple string to echo server
dbms_output.put_line(utl_tcp.get_line(c, TRUE)); -- read result
utl_tcp.close_connection(c);
END;
|
Testing
จากตัวอย่างทำการติดต่อ กับ เครื่อง archer.exzilla.net โดยผ่าน
tcp/ip port 7 ซึ่งเป็น Port ที่มี echo Server runอยู่ โดยตัวอย่างการทำงานจะทำการเขียนข้อมูลที่
Port 7 และรับข้อมูลที่ Echo ออกมาแสดงที่ Standard Output
SQL> connect scott/tiger
Connected.
SQL>
SQL> set serveroutput on
SQL> DECLARE
2 c utl_tcp.connection; -- TCP/IP connection to echo port
3 ret_val pls_integer;
4 BEGIN
5 c := utl_tcp.open_connection(remote_host => 'archer.exzilla.net',
6 remote_port => 7,
7 charset => NULL); -- open connection
8 ret_val := utl_tcp.write_line(c,
9 'Hi echo port : line number 1 '); -- send simple string to echo server
10
11 dbms_output.put_line(
12 utl_tcp.get_line(c, TRUE)); -- read result
13
14 ret_val := utl_tcp.write_line(c,
15 'Hi echo port : line number 2 '); -- send simple string to echo server
16
17 dbms_output.put_line(utl_tcp.get_line(c, TRUE)); -- read result
18 utl_tcp.close_connection(c);
19
20 END;
21 /
Hi echo port : line number 1
Hi echo port : line number 2
PL/SQL procedure successfully completed.
SQL>
|
Note:
Complete Sample
code:
References:
Oracle9i Supplied PL/SQL Packages and Types Reference Release
1 (9.0.1)
Part Number A89852-02
You can download from http://otn.oracle.com/
More Information:
Oracle9i Supplied PL/SQL Packages and Types Reference Release
1 (9.0.1)
Part Number A89852-02
You can download from http://otn.oracle.com/
Keywords:
Tcp/ip , utl_tcp, packages
|
| |
| |
{exzilla.net
-- e-development QuickStart --}
|