使用Record插入Data PL / SQL

时间:2013-07-15 13:41:36

标签: sql plsql plsqldeveloper

我试图在dept_new表中插入一条记录,其中包含2列

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:

1 个答案:

答案 0 :(得分:0)

请提供变量的数据类型

 dept_no := &dept_num;

如下

dept_no number := &dept_num;

希望这能解决您的问题