1

我试图将一条记录插入到包含 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:
4

1 回答 1

0

请提供变量的数据类型

 dept_no := &dept_num;

如下

dept_no number := &dept_num;

希望这能解决你的问题

于 2013-07-26T08:45:44.463 回答