【发布时间】:2013-07-15 13:41:36
【问题描述】:
我试图将一条记录插入到包含 2 列的 dept_new 表中,
DEPT_NAME VARCHAR2(30)
DEPT_ID VARCHAR2(255)
另一个表 dept 在那里创建记录 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;
-
+1 - 找到自己的答案。
-
您在其中有三个 dept_id 名称——dept_num、dept_no 和 dept_id。为您的 PL/SQL 块命名,使用 >,使用 my_block_name.dept_id 作为 PL/SQL 变量的名称,使用 &dept_id 作为 SQL*Plus 变量的名称。你的代码不会那么混乱。
标签: sql plsql plsqldeveloper