瀏覽器 ←→ Internet ←→ Oracle WebServer (iAS/OC4J) ←→ PL/SQL Gateway (mod_plsql/OWA) ←→ Oracle Database
中間件管理連接池、會話狀態、HTTP 協議轉換,PL/SQL 過程直接生成 HTML 響應。
HTP.P, HTP.TABLEOPEN...)。HTF.FORMTEXT, HTF.ANCHOR...)。CREATE OR REPLACE PROCEDURE score_into_webpage (code_in IN NUMBER) AS
CURSOR score_cursor IS
SELECT code, name, score FROM student WHERE code = code_in;
BEGIN
HTP.HTMLOPEN;
HTP.HEADOPEN;
HTP.TITLE('Student Score Information');
HTP.HEADCLOSE;
HTP.BODYOPEN(HTP.CATTRIBUTES => 'BGCOLOR="#808000"');
HTP.TABLEOPEN(HTP.CATTRIBUTES => 'BORDER="1"');
HTP.TABLECAPTION('Score Information', 'CENTER');
HTP.TABLEROWOPEN;
HTP.TABLEHEADER('Student Code');
HTP.TABLEHEADER('Student Name');
HTP.TABLEHEADER('Student Score');
HTP.TABLEROWCLOSE;
FOR score_rec IN score_cursor LOOP
HTP.TABLEROWOPEN;
HTP.TABLEDATA(score_rec.code);
HTP.TABLEDATA(score_rec.name);
HTP.TABLEDATA(score_rec.score);
HTP.TABLEROWCLOSE;
END LOOP;
HTP.TABLECLOSE;
HTP.BODYCLOSE;
HTP.HTMLCLOSE;
END score_into_webpage;
/
-- 授權公開訪問
GRANT EXECUTE ON score_into_webpage TO PUBLIC;
CREATE OR REPLACE PROCEDURE ScoreForm AS
BEGIN
HTP.HEADOPEN;
HTP.TITLE('Code Entry Form');
HTP.HEADCLOSE;
HTP.BODYOPEN;
HTP.HEADER(2, 'Score Information Code Form');
HTP.P(' ');
HTP.FORMOPEN('score_into_webpage', HTP.CMETHOD => 'GET');
HTP.TABLEOPEN(HTP.CATTRIBUTES => 'BORDER="1"');
HTP.TABLEROWOPEN;
HTP.TABLEDATA('Enter Student Code');
HTP.TABLEDATA(HTF.FORMTEXT('code_in', 5, 5)); -- name=code_in 對應參數
HTP.TABLEROWCLOSE;
HTP.TABLEROWOPEN;
HTP.TABLEDATA(HTF.FORMSUBMIT); -- 提交按鈕
HTP.TABLEDATA(HTF.FORMRESET); -- 重置按鈕
HTP.TABLEROWCLOSE;
HTP.FORMCLOSE;
HTP.BODYCLOSE;
HTP.HTMLCLOSE;
END ScoreForm;
/
GRANT EXECUTE ON ScoreForm TO PUBLIC;
mod_plsql (Apache) 或 ORDS (REST Data Services) 映射 DAD (Database Access Descriptor)。https://host:port/pls/DAD/ScoreForm → 顯示輸入表單。score_into_webpage?code_in=123 → 顯示成績表格。Oracle 推薦使用 Oracle REST Data Services (ORDS) + Oracle APEX 或 PL/SQL REST API 替代傳統 mod_plsql:
GRANT EXECUTE TO PUBLIC,生產環境應建立專用 WEB_USER 角色授權。DBMS_ASSERT.ENQUOTE_LITERAL 或改用靜態游標)。OWA_UTIL.SIGNATURE 或自定義簽名驗證防 CSRF。