我写了这个查询
系统显示enter image description here
如何解决这一问题?
The code should only show those data within the two date we enter.
ACCEPT sDate CHAR FORMAT 'A10' PROMPT ' Enter the start date: '
ACCEPT ednDate CHAR FORMAT 'A10' PROMPT ' Enter the end date: '
SELECT s.customerID, c.fname, m.memberID, salesID, co.countriesName, p.productName,s.totalAmount,s.totalAmount*discountAmount AS subtotal,salesdate
FROM sales s, customers c, member m, list l, discount d, product p,shop sh,countries co
WHERE c.customerID = m.customerID AND
m.memberID = d.memberID AND
d.discountID = s.discountID AND
s.listID = l.listID AND
l.productID = p.productID AND
s.shopID = sh.shopID AND
sh.countriesID = co.countriesID AND
salesdate BETWEEN TO_DATE(sDate, 'DD/MM/YYYY') AND TO_DATE(ednDate, 'DD/MM/YYYY')
order by customerID,salesdate;
2条答案
按热度按时间mctunoxg1#
sDate
和ednDate
被定义为替换变量,因此您需要将引用更改为前缀为&
,并将它们括在引号中:如果你不引用它们,那么它将尝试执行
TO_DATE(01/12/2022, 'DD/MM/YYYY')
,这将导致ORA-01858错误。rvpgvaaj2#
如果你在sqlplus或PL/SQL开发环境中运行它,允许像sqlplus这样的替换变量,那么这些替换变量前面应该有
&
,比如: