我试图从另一个看起来类似于下面代码的存储过程调用存储过程:
create or replace procedure hello_world is
v_first_name VARCHAR2(30) := 'ABC';
v_LAST_name VARCHAR2(30) := 'XYZ';
BEGIN
htp.p('<HTML>');
htp.p('<HEAD>');
htp.p('<TITLE>Instructor Personal Info</TITLE>');
htp.p('</HEAD>');
htp.p('<BODY bgColor="#99CCCC">');
HTP.P('<input type="text" name = "TEXT" >');
HTP.P('<p id="demo"></p>');
htp.p('<script type="text/javascript">function myFunction() {/**Call the other stored procedure here passing the value from the the element "demo"**/');
htp.p('</script>');
HTP.P('<button type="button" onclick="myFunction()">Personal Info</button>');
HTP.p('<p>This example demonstrates how to assign an "onclick" event to a p element.</p>');
htp.p('<H1>Personal Info For '||v_first_name||' '||v_last_name||'</H1>');
htp.p('</BODY>');
htp.p('</HTML>');
END;
我想传递元素的价值&#34; Demo&#34;作为参数。
这可能吗?以及如何实现这一目标?
答案 0 :(得分:1)
以下是如何执行AJAX-Request的示例。
我无法测试它。
如您所见,您需要使用您的过程名称更改http.open
上的值。
CREATE OR REPLACE PROCEDURE hello_world
IS
v_first_name VARCHAR2 (30) := 'ABC';
v_last_name VARCHAR2 (30) := 'XYZ';
BEGIN
HTP.p ('<HTML>');
HTP.p ('<HEAD>');
HTP.p ('<TITLE>Instructor Personal Info</TITLE>');
HTP.p ('</HEAD>');
HTP.p ('<BODY bgColor="#99CCCC">');
HTP.p ('<input type="text" name = "TEXT" >');
HTP.p ('<p id="demo"></p>');
HTP.p('<script type="text/javascript">function myFunction() {
var http;
var response;
var demo = document.getElementById("demo");
http = new XMLHttpRequest();
http.open("GET", "PROCEDURE_TO_CALL?param1="+ demo.value, false);
http.setRequestHeader("Cache-Control", "no-cache");
http.onreadystatechange = function() {
if(http.readyState == 4 && http.status == 200){
response = http.responseText;
}
}
http.send();
}');
HTP.p ('</script>');
HTP.p('<button type="button" onclick="myFunction()">Personal Info</button>');
HTP.p('<p>This example demonstrates how to assign an "onclick" event to a p element.</p>');
HTP.p( '<H1>Personal Info For '
|| v_first_name
|| ' '
|| v_last_name
|| '</H1>');
HTP.p ('</BODY>');
HTP.p ('</HTML>');
END;