日期:2014-05-17  浏览次数:22269 次

提示错误ORA00905:select * into A from B,缺少关键字
在PLSQL中写了一个语句:select * into A from B
运行时提示:错误00905,缺少关键字


请问是什么原因???谢谢

------解决方案--------------------
select * into A from B


A需要定义。。。。
------解决方案--------------------
那是MS-SQL的写法,ORACLE是
create table b as select * from a
------解决方案--------------------
有点奇怪
如果A没定义 不会报 缺少关键字 而是报A 未定义
如果列数多 也不会报缺少关键字 而是报列数过多

没遇到过 期待
------解决方案--------------------
SQL code

--select * into A from B
--*代表b表中的所有行的记录,即多条记录

--如果你要获取统计记录(单条记录),可以如下写:
SQL> set serveroutput on;
SQL> declare
  2         x number(2);
  3  begin
  4       select count(*) into x
  5       from emp
  6       where deptno=30;
  7  
  8       dbms_output.put_line('The number of department 30 employees are :'||x);
  9  end;
 10  /

The number of department 30 employees are :6

PL/SQL procedure successfully completed
-----------------
--如果你想获得多条记录,可以用游标返回多条记录:
SQL> declare
  2         cursor x is
  3         select ename,deptno,job,sal
  4         from emp;
  5  begin
  6       for v_emp in x
  7       loop
  8           dbms_output.put_line(
  9           'ename= '||v_emp.ename||
 10           ', deptno= '||v_emp.deptno||
 11           ', job= '||v_emp.job||
 12           ', sal= '||v_emp.sal
 13           );
 14       end loop;
 15  end;
 16  /

ename= SMITH, deptno= 20, job= CLERK, sal= 800
ename= ALLEN, deptno= 30, job= SALESMAN, sal= 1600
ename= WARD, deptno= 30, job= SALESMAN, sal= 1250
ename= JONES, deptno= 20, job= MANAGER, sal= 2975
ename= MARTIN, deptno= 30, job= SALESMAN, sal= 1250
ename= BLAKE, deptno= 30, job= MANAGER, sal= 2850
ename= CLARK, deptno= 10, job= MANAGER, sal= 2450
ename= SCOTT, deptno= 20, job= ANALYST, sal= 3100
ename= KING, deptno= 10, job= PRESIDENT, sal= 5000
ename= TURNER, deptno= 30, job= SALESMAN, sal= 1500
ename= ADAMS, deptno= 20, job= CLERK, sal= 1100
ename= JAMES, deptno= 30, job= CLERK, sal= 950
ename= FORD, deptno= 20, job= ANALYST, sal= 3000
ename= MILLER, deptno= 10, job= CLERK, sal= 1300