Reputation: 35
I see that there are a couple of similar questions but non of the answers were able to solve my problems and that is why I am posting the code here. I appreciate the help. When I run the code I am getting:
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));
Upvotes: 0
Views: 3271
Reputation: 35
Sorry, I finally figured it out. The INTO clause should follow immediately after the projection: select cityid into cityid_copy from city
Upvotes: 0
Reputation: 64949
You haven't quite got the syntax of a PL/SQL SELECT ... INTO ...
statement right. The variables you are selecting into must come before the FROM
clause.
To fix your error, replace this line
select cityid from city into cityid_copy
with this line
select cityid into cityid_copy from city
Upvotes: 3