-
Execute sql query in loop
Hi guys,
I am trying to execute the following statement in Oracle isql*plus, but i am getting error message. Could anyone help?
declare
i varchar(200);
begin
for a in 1 .. 10 loop
i := 'select count(*) from messages';
dbms_output.put_line (i);
a := a + 1;
end loop;
END;
All I would like to do is to run the statement of "select count(*) from messages" in every second, so I was trying to do it in for loop so that I don't need to click execute button in every second.
Thanks
-
"a" is the index variable in a for loop and should not get manually incremented. If left alone it will increment itself. You don't state the error message, but without running the code I'm guessing that that is it. You are also seemingly trying to print out the same query 10 times without changing it. What are you really trying to do, and what error are you getting?
declare
i varchar(200);
begin
for a in 1 .. 10 loop
i := 'select count(*) from messages';
dbms_output.put_line (i);
a := a + 1;
end loop;
END;
-
All I want to do is to get the result of
select count(*) from messages
in every second, instead of keep typing such query.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|