Variable inside a nested loop  
Author Message
Inti





PostPosted: Wed Nov 24 14:09:02 CST 2004 Top

SQL Server Developer >> Variable inside a nested loop

Hello:
I am trying to write a utility/query to get a report from a table. Below
is the some values in the table:
table name: dba_daily_resource_usage_v1
conn|loginame|dbname|cum_cpu|cum_io|cum_mem|last_batch
------------------------------------------------------------
80 |farmds_w|Farm_R|4311 |88 |5305 |11/15/2004 11:30
80 |abcdes_w|efgh_R|5000 |88 |4000 |11/15/2004 12:30
45 |dcp_webu|DCP |5967 |75 |669 |11/16/2004 11:30
95 |dcp_webu|XYZ |5967 |75 |669 |11/17/2004 11:30

I need to write a query which for a given date (say 11/15/2004),
generate a resource usage for a given duration (say 3 days).

Here is my query:
************************************
set quoted_identifier off



--BEGIN OUTER LOOP

begin



--builds a range of date


(10),last_batch,101)))

from dba_daily_resource_usage_v1





--set dateformat mdy








--BEGIN INNER LOOP
declare cur1 cursor read_only for
select distinct loginame,dbname from
dba_daily_resource_usage_v1

--??????PROBLEM AREA ABOVE STATEMENT??????

--however cursor is not being built and hence it exits the
--inner loop (cursor)
open cur1


begin






--processes the cursors






where





end
--END INNER LOOP

deallocate cur1
end
--END OUTER LOOP
************************************
PROBLEM:


used to build the cursor. Hence, the cursor has no row set.

outside the cursor to inside the cursor.

Any help please.
Thanks











*** Sent via Developersdex http://www.hide-link.com/ ***
Don't just participate in USENET...get rewarded for it!

SQL Server226  
 
 
AlejandroMesa





PostPosted: Wed Nov 24 14:09:02 CST 2004 Top

SQL Server Developer >> Variable inside a nested loop Could you post DDL and expected result also?



AMB



> Hello:
> I am trying to write a utility/query to get a report from a table. Below
> is the some values in the table:
> table name: dba_daily_resource_usage_v1
> conn|loginame|dbname|cum_cpu|cum_io|cum_mem|last_batch
> ------------------------------------------------------------
> 80 |farmds_w|Farm_R|4311 |88 |5305 |11/15/2004 11:30
> 80 |abcdes_w|efgh_R|5000 |88 |4000 |11/15/2004 12:30
> 45 |dcp_webu|DCP |5967 |75 |669 |11/16/2004 11:30
> 95 |dcp_webu|XYZ |5967 |75 |669 |11/17/2004 11:30
>
> I need to write a query which for a given date (say 11/15/2004),
> generate a resource usage for a given duration (say 3 days).
>
> Here is my query:
> ************************************
> set quoted_identifier off


>
> --BEGIN OUTER LOOP

> begin


>
> --builds a range of date


> (10),last_batch,101)))

> from dba_daily_resource_usage_v1

>

>

> --set dateformat mdy
>



>


>
> --BEGIN INNER LOOP
> declare cur1 cursor read_only for
> select distinct loginame,dbname from
> dba_daily_resource_usage_v1

> --??????PROBLEM AREA ABOVE STATEMENT??????

> --however cursor is not being built and hence it exits the
> --inner loop (cursor)
> open cur1


> begin





>
> --processes the cursors






> where





> end
> --END INNER LOOP

> deallocate cur1
> end
> --END OUTER LOOP
> ************************************
> PROBLEM:


> used to build the cursor. Hence, the cursor has no row set.

> outside the cursor to inside the cursor.
>
> Any help please.
> Thanks
>
>
>
>
>
>
>
>
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
>