我很确定这是一个语法错误,我只是没有看到它。我有一个表单可以将付款信息提交到数据库并将其加载到发票表中。我的输出线只是为了测试正在发生的事情。该表接收 invoice_id、sysdate 和到期的默认值,其他所有内容均为 null。
我的 PSP 表格:
<%@ page language="PL/SQL"%>
<%@ plsql procedure="payment_details"%>
<%@plsql parameter="first_name_text" default="null"%>
<%@plsql parameter="last_name_text" default="null"%>
<%@plsql parameter="email_text" default="null"%>
<%@plsql parameter="phone_text" default="null"%>
<%@plsql parameter="reservation_id_text" default="null"%>
<%@plsql parameter="formsbutton1" default="null"%>
<%! guest_id_text guest.guest_id%type; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta charset="utf-8" />
<title>Hotel Database</title>
<style>
p.inset {
border-style: inset;
margin:auto;
width:250px;
}
</style>
</head>
<body>
<div align="center">
<p><h1>The Golden Key Hotel</h2>
<h2>Hotel Reservation</h2></p>
<a href="reservation_request">Create a Reservation</a> ||
<a href="">View My Reservations</a> ||
<a href="">Administrative View</a>
<hr />
</div>
<br>
<%
insert into guest(guest_id, first_name, last_name, email, phone)
values(guest_sequence.nextval,first_name_text, last_name_text, email_text, phone_text);
commit;
select guest_sequence.currval into guest_id_text
from dual;
update reservation
set guest_id = guest_id_text
where reservation_id = reservation_id_text;
commit;
%>
<p>Guest <%=first_name_text%> with Guest ID <%=guest_id_text%> for Reservation <%=reservation_id_text%> created.</p>
<br>
Enter Payment Details:
<form action="invoice_receipt" method="post">
Card Number: <input type="text" name="cc_no_text" /><br>
Card Type: <input type="radio" name="cc_type_text" value="Visa"> Visa
<input type="radio" name="cc_type_text" value="MasterCard"> MasterCard
<input type="radio" name="cc_type_text" value="Discover"> Discover
<input type="radio" name="cc_type_text" value="Travel"> Travel <br>
Exp Date (last day of month): <input type="date" name="exp_date" /><br>
<input type="hidden" name="guest_id_text" value="<%=guest_id_text%>">
<input type="hidden" name="reservation_id_text" value="<%=reservation_id_text%>">
<input type="submit" name="FormsButton1" value="Submit"/>
</form>
<!-- End Page Content -->
<% exception
when others then %>
<%=sqlerrm%>
</body>
</html>
我收到的 PSP:
<%@ page language="PL/SQL"%>
<%@ plsql procedure="invoice_receipt"%>
<%@plsql parameter="cc_type_text" default="null"%>
<%@plsql parameter="cc_no_text" default="null"%>
<%@plsql parameter="exp_date_text" default="null"%>
<%@plsql parameter="guest_id_text" default="null"%>
<%@plsql parameter="reservation_id_text" default="null"%>
<%@plsql parameter="formsbutton1" default="null"%>
<%! invoice_id_text invoice.invoice_id%type; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta charset="utf-8" />
<title>Hotel Database</title>
<style>
p.inset {
border-style: inset;
margin:auto;
width:250px;
}
</style>
</head>
<body>
<div align="center">
<p><h1>The Golden Key Hotel</h2>
<h2>Hotel Reservation</h2></p>
<a href="">reservation_request">Create a Reservation</a> ||
<a href="">View My Reservations</a> ||
<a href="">Administrative View</a>
<hr />
</div>
<br>
<%
insert into invoice(invoice_id, invoice_date, invoice_due, cc_type, cc_no,
exp_date, guest_id, reservation_id)
values(invoice_sequence.nextval, sysdate, default, cc_type_text, cc_no_text,
to_date(exp_date_text, 'yyyy/mm/dd'), guest_id_text, reservation_id_text);
commit;
select invoice_sequence.currval into invoice_id_text
from dual;
%>
<p>Invoice <%=invoice_id_text%> created on <%=sysdate%> with Reservation <%=reservation_id_text%> and a credit card of <%=cc_type_text%>.</p>
<br>
<!-- End Page Content -->
<% exception
when others then %>
<%=sqlerrm%>
</body>
</html>
步骤:
create or replace procedure invoice_receipt (cc_type_text varchar2,
cc_no_text varchar2, exp_date_text varchar2,
guest_id_text varchar2,reservation_id_text varchar2, formsbutton1 varchar2)
is
invoice_id_text invoice.invoice_id%type;
begin
insert into invoice(invoice_id, invoice_date, invoice_due, cc_type, cc_no,
exp_date, guest_id, reservation_id)
values(invoice_sequence.nextval,sysdate, default, cc_type_text, cc_no_text,
to_date(exp_date_text, 'yyyy/mm/dd'), guest_id_text, reservation_id_text);
commit;
select invoice_sequence.currval into invoice_id_text
from dual;
dbms_output.put_line('Invoice '||invoice_id_text||' created on '||sysdate||'
with Reservation '
||reservation_id_text||' and a credit card of '||cc_type_text);
end;