Subject | Looping Query to count checkouts |
---|---|
Author | prwels |
Post date | 2011-06-17T23:16:38Z |
Hi all,
I have a database of assets which can be checked out by various people. There is a table of history, which records all the checking and checkout dates and times as well as personnel ids.
So far I am able to use FlameRobin to count the checkouts for one individual at a time, but I would like to loop through all the personnel ids, so I only have to run the script once, rather than 60+ times.
I finally got my initial loop code to work, but as soon as I add my SELECT line the code starts giving me "Token unknown" for the ';' at the end of the SELECT line. If I take out the semi-colon, it gives me the same error for the variable on the next line.
Here is my code so far. Any suggestions would be appreciated.
set term # ;
execute block
as
declare i int = 102;
begin
while (i < 169) do
begin
select a."Description"
from "AssetHistory" a
where a."EntryType" = 'CheckOut' and a."Personnel_ID" = 103;
i = i + 1;
end
end
#
I have a database of assets which can be checked out by various people. There is a table of history, which records all the checking and checkout dates and times as well as personnel ids.
So far I am able to use FlameRobin to count the checkouts for one individual at a time, but I would like to loop through all the personnel ids, so I only have to run the script once, rather than 60+ times.
I finally got my initial loop code to work, but as soon as I add my SELECT line the code starts giving me "Token unknown" for the ';' at the end of the SELECT line. If I take out the semi-colon, it gives me the same error for the variable on the next line.
Here is my code so far. Any suggestions would be appreciated.
set term # ;
execute block
as
declare i int = 102;
begin
while (i < 169) do
begin
select a."Description"
from "AssetHistory" a
where a."EntryType" = 'CheckOut' and a."Personnel_ID" = 103;
i = i + 1;
end
end
#