1
我試圖記錄插入dept_new表,其中包含2列,使用記錄將數據插入PL/SQL
DEPT_NAME VARCHAR2(30)
DEPT_ID VARCHAR2(255)
另一臺部門有沒有從中創建記錄dept_e。
ACCEPT dept_num VARCHAR2(255) NOT NULL PROMPT 'Enter dept_id: ';
DECLARE
dept_e dept%ROWTYPE;
dept_no := &dept_num;
BEGIN
select * INTO dept_e
from dept
where dept_id = dept_no;
INSERT INTO dept_new(dept_id,dept_name)
VALUES (dept_e.dept_id, dept_e.dept_name);
COMMIT;
END;
/
Error report:
ORA-06550: line 3, column 9:
PLS-00103: Encountered the symbol "=" when expecting one of the following:
constant exception <an identifier>
<a double-quoted delimited-identifier> table LONG_ double ref
char time timestamp interval date binary national character
nchar
The symbol "<an identifier>" was substituted for "=" to continue.
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
明白了,DEPT_NO VARCHAR2(255)NOT NULL提供的數據類型:=&dept_num; – May
+1 - 找到自己的答案。 –
你有三個dept_id的名字--dept_num,dept_no和dept_id。使用<< my_block_name >>爲PL/SQL塊命名,使用my_block_name.dept_id作爲PL/SQL變量的名稱,併爲SQL * Plus變量使用dept_id。您的代碼將不那麼令人困惑。 –