oracle 从 PL/SQL 生成 HTML
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11840695/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Generating HTML from PL/SQL
提问by Gaurav Soni
CREATE OR replace PROCEDURE Hello_world2
IS
BEGIN
HTP.htmlopen;
HTP.headopen;
HTP.Title ('You knew it was coming...');
HTP.headclose;
HTP.comment ('This phrase is in every computer book.');
HTP.Bodyopen (cattributes => 'body bgcolor=blue');
HTP.Print ('And here it is .... Hello, World!');
HTP.bodyclose;
HTP.htmlclose;
END;
How can I output this to an HTML file? I have tried as shown below:
如何将其输出到 HTML 文件?我试过如下图所示:
spool report.htm
exec hello_world2;
spool off
exit
But I am getting error as shown below:
但我收到如下所示的错误:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "SYS.OWA_UTIL", line 356
ORA-06512: at "SYS.HTP", line 1368
ORA-06512: at "SYS.HTP", line 1443
ORA-06512: at "SYS.HTP", line 1735
ORA-06512: at "SYS.HTP", line 72
ORA-06512: at "T416493.HELLO_WORLD2", line 4
ORA-06512: at line 1
Can anyone help me with this
谁能帮我这个
回答by ik_zelf
Normally you would call owa_util.showpage
to spool the contents out.
Dan has a nice overview of the usages Oracle OWA_UTILThere is something funny about this, it should run from sqlplus but I think it expects to be called from mod_plsql, using a web browser.
通常,您会调用owa_util.showpage
将内容假脱机。Dan 对Oracle OWA_UTIL的用法有一个很好的概述 这
有一些有趣的地方,它应该从 sqlplus 运行,但我认为它希望使用 web 浏览器从 mod_plsql 调用。
If you really only want te generate static web pages, you can also use plain old dbms_output to do that. Otherwise, it might be smarter to take a look at Oracle Apexor maybe even a very nice and capable alternative for Oracle Apex, Formspider
如果你真的只想生成静态网页,你也可以使用普通的旧 dbms_output 来做到这一点。否则,查看Oracle Apex或什至是 Oracle Apex、Formspider 的一个非常好的和功能强大的替代方案可能会更明智
回答by Tagar
ORA-06512: at "SYS.OWA_UTIL", line 356
ORA-06512:在“SYS.OWA_UTIL”,第 356 行
Did you try to see what's there? :-)
That line has
for i in 1..owa.num_cgi_vars
so you're trying to run cgi-aware code in non-cgi environment.
The owa.num_cgi_vars variable is NULL.
你有没有试着看看那里有什么?:-) 那条线有,
for i in 1..owa.num_cgi_vars
所以你试图在非 cgi 环境中运行 cgi-aware 代码。owa.num_cgi_vars 变量为 NULL。
begin for i in 1..null loop null; end loop; end;
begin for i in 1..null loop null; 结束循环;结尾;
will give you the same ORA-06512.
会给你同样的 ORA-06512。
回答by ABC
You need to init the CGI with owa.init_cgi_env
您需要使用 owa.init_cgi_env 初始化 CGI
See http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:347617533333
见http://asktom.oracle.com/pls/asktom/f?p=100:11::::P11_QUESTION_ID:347617533333
It worked for me where everything else failed.
在其他一切都失败的情况下,它对我有用。
回答by Harry McDale
I've had the same problem. I inserted another dad-profile and it worked like a charm :) Somehow the old dad-profile got rotten.
我遇到了同样的问题。我插入了另一个爸爸配置文件,它就像一个魅力:) 不知何故,旧的爸爸配置文件变得腐烂了。
-- as xdbadmin or sys (mpl_user is of course schema where packages reside): exec dbms_epg.create_dad('new_dad', '/my_db/*'); exec dbms_epg.set_dad_attribute('new_dad', 'database-username', 'UUSSEERR'); -- username in uppercase grant execute on dbms_epg to uusseerr;
-- 作为 xdbadmin 或 sys(mpl_user 当然是包所在的模式): exec dbms_epg.create_dad('new_dad', '/my_db/*'); exec dbms_epg.set_dad_attribute('new_dad', 'database-username', 'USSEERR'); -- 大写的用户名授予在 dbms_epg 上执行给 uusseerr;
-- as user (uusseerr): exec dbms_epg.authorize_dad('new_dad');
-- 作为用户 (uusseerr): exec dbms_epg.authorize_dad('new_dad');
回答by Prabhat Ganesh Yaji
Below code will print the html page formed using stored procedure.
下面的代码将打印使用存储过程形成的 html 页面。
set serveroutput on;
declare
vNames owa.vc_arr;
vValues owa.vc_arr;
begin
htp.init;
vNames(1) := 'REQUEST_PROTOCOL';
vValues(1) := 'HTTP';
owa.init_cgi_env(
num_params => 1,
param_name => vNames,
param_val => vValues );
test_package.proc_call; --procedure where html pages are formed using htp.p
owa_util.showpage;
end;
/