所以我有
SET SERVEROUTPUT ON;
SET VERIFY OFF;
DECLARE
PayNum number := 1;
BEGIN
LOOP
dbms_output.put_line('xx');
dbms_output.put_line('Gathering data to be added to PAYMENT Table');
dbms_output.put_line('____________________________________________');
dbms_output.put_line('xx');
ACCEPT CType CHAR PROMPT 'Please enter credit card type: ';
ACCEPT CCNum NUMBER PROMPT 'Please enter the credit card number: ';
ACCEPT pDate DATE FORMAT 'dd/mm/yyyy' PROMPT 'Please enter payment date (mm/dd/yyyy): ';
ACCEPT Amt NUMBER PROMPT 'Please enter amount to be paid: ';
ACCEPT BankName CHAR PROMPT 'Please enter the credit card number: ';
ACCEPT AccNum NUMBER PROMPT 'Please enter Bank account number: ';
INSERT INTO PAYMENT (PayNum, CType, CCNum, BankName, AccNum, pDate, Amt) VALUES ('&PayNum','&CType','&CCNum','&BankName','&AccNum',to_date('&pDate','mm/dd/yyyy'),'&Amt');
PayNum := PayNum + 1;
dbms_output.put_line('');
ACCEPT usroptn CHAR PROMPT 'Do you want to enter another data? (Y/N)';
dbms_output.put_line('');
EXIT WHEN usroptn = 'N';
END LOOP;
END;
/
当我运行脚本时,我会继续:
@addpayment.sql
Enter value for paynum: 2
ACCEPT CType CHAR PROMPT 'Please enter credit card type: ';
*
ERROR at line 11:
ORA-06550: line 11, column 8:
PLS-00103: Encountered the symbol "CTYPE" when expecting one of the following:
:= . ( @ % ;
我没有在我的代码上要求Paynum。它只是我每次添加数据时应该增加一个支付表的主键。我如何摆脱这个错误?
答案 0 :(得分:0)
ACCEPT是SQL PLUS命令,而不是PL / SQL命令。只有在输入所有替换变量后,才会将PL / SQL块发送到PL / SQL引擎。因为这些,据我所知,不可能在PL / SQL循环语句中调用SQL PLUS命令。