我看到有几个类似的问题,但没有答案能够解决我的问题,这就是我在这里发布代码的原因。我很感激帮助。当我运行代码时,我得到了:
ORA-06550: line 23, column 25:
PL/SQL: ORA-00933: SQL command not properly ended
ORA-06550: line 23, column 1:
PL/SQL: SQL Statement ignored
create table city
(cityid numeric(10),
cityname varchar2(20),
cityregion varchar(20),
citypopulation INT,
constraint city_pk primary key (cityid));
declare
c_id number := 0 ;
c_name varchar2(30) ;
c_region varchar2(30);
c_pop number;
time_now timestamp;
time_after timestamp;
cityid_copy city.cityid%type;
begin
while (c_id <= 3000)
loop
c_name := 'City' || c_id;
c_region := 'Region' || c_id;
c_pop := c_id + 500;
INSERT INTO city
(cityid,cityname,cityregion,citypopulation)
values(c_id,c_name,c_region,c_pop);
c_id := c_id +1;
end loop;
time_now := systimestamp;
select cityid from city into cityid_copy
where cityid = 1;
time_after := systimestamp;
Dbms_Output.Put_Line((time_after)- (time_now));
答案 0 :(得分:3)
你还没有完全掌握PL / SQL SELECT ... INTO ...
语句的语法。您选择的变量必须位于FROM
子句之前。
要修复错误,请替换此行
select cityid from city into cityid_copy
这一行
select cityid into cityid_copy from city
答案 1 :(得分:0)
抱歉,我终于明白了。投影后应立即遵循INTO子句:从城市中选择cityid到cityid_copy