|
|
| Howto: Overview
of internet Packages in Oracle Database -- UTL_HTTP |
| Aug 1,
2001 |
| Tyranno |
| Author's Bio | E-Mail |
| Copyright (C) 2002
exzilla.net |
|
HOWTO: Overview
of Internet Packages in Oracle Database -- UTL_HTTP
Prerequistires:
Oracle8i or later
Purpose:
UTL_HTTP package
Package นี้จะประกอบ APIs ด้วยหลายตัว ที่ช่วยให้เราสามารถเขียน
PL/SQL Program ติดต่อกับ Web Servers โดยผ่าน ทาง Hypertext Transfer
Protocol (HTTP) ได้ง่ายขึ้น
Step-by-Step Example:
Create Anonymous
PL/SQL Block and Testing UTL_HTTP Package
ได้ในตัวอย่าง Anonymous Block นี้จะเป็นการถึงข้อมูลที่เป็น Text
file จาก http://www.exzilla.net โดยผ่าน Proxy ที่เรากำหนด
SET serveroutput ON SIZE 40000
DECLARE
req utl_http.req;
resp utl_http.resp;
value VARCHAR2(1024);
BEGIN
utl_http.set_proxy('www-proxy.exzilla.net',
'dec4100.exzilla.net');
req := utl_http.begin_request(
'http://www.exzilla.net/underConst/how-to-templete.txt');
utl_http.set_header(req, 'User-Agent', 'Mozilla/4.0');
resp := utl_http.get_response(req);
LOOP
utl_http.read_line(resp, value, TRUE);
dbms_output.put_line(value);
END LOOP;
utl_http.end_response(resp);
EXCEPTION
WHEN utl_http.end_of_body THEN
utl_http.end_response(resp);
END;
|
ในการใช้งานผ่าน Proxy นั้นนอกจากเราจะกำหนดเลือกชื่อ Proxy ที่เราต้องการแล้วเรายังสามารถระบุได้อีกว่าถ้าต้องการติดต่อกับ
Web ได้ที่เราไม่ต้องการผ่าน Proxy ก็สามารถทำได้ซึ่งจากตัวอย่าง
utl_http.set_proxy('www-proxy.exzilla.net', 'dec4100.exzilla.net');
ซึ่งจากตัวอย่างเป็นการกำหนดว่า Proxy ที่เราใช้งานคือ www-proxy.exzilla.net
แต่ถ้าต้องการติดต่อกับ web ที่ทำงาน
Testing
SQL> connect scott/tiger
Connected.
SQL> SET serveroutput ON SIZE 40000
SQL> SQL> DECLARE
2 req utl_http.req;
3 resp utl_http.resp;
4 value VARCHAR2(1024);
5 BEGIN
6
7 utl_http.set_proxy('www-proxy.exzilla.net',
8 'dec4100.exzilla.net');
9
10 req := utl_http.begin_request(
11 'http://www.exzilla.net/underConst/how-to-templete.txt');
12 utl_http.set_header(req, 'User-Agent', 'Mozilla/4.0');
13 resp := utl_http.get_response(req);
14 LOOP
15 utl_http.read_line(resp, value, TRUE);
16 dbms_output.put_line(value);
17 END LOOP;
18 utl_http.end_response(resp);
19 EXCEPTION
20 WHEN utl_http.end_of_body THEN
21 utl_http.end_response(resp);
22 END;
23 /
HOWTO: subjects. HOWTO: The article header
Prerequistires:
Purpose:
Step-by-Step Example:
Note:
Complete Sample code:
References:
More Information:
Keywords:
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:
http protocol , UTL_HTTP, packages
|
| |
| |
{exzilla.net
-- e-development QuickStart --}
|