![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi! I have to write a sp, which 1. divides an interval (argument) in smaller intervals 2. calculates the avg-values for these intervals; the PK are timestamps 3. returning the values as resultset for processing in Java 1 and 2 are not worse, but 3 is difficult. |
#3
| |||
| |||
|
|
On Fri, 28 May 2004 12:32:06 +0200, Michael Drewitz wrote: Hi! I have to write a sp, which 1. divides an interval (argument) in smaller intervals 2. calculates the avg-values for these intervals; the PK are timestamps 3. returning the values as resultset for processing in Java 1 and 2 are not worse, but 3 is difficult. What's so difficult? You just select @avg1, @avg2, ... for the local variables into which you've placed the calculated values. Michael It were fine to get the result with one query. In your way there are |
#4
| |||
| |||
|
|
Michael Peppler wrote: On Fri, 28 May 2004 12:32:06 +0200, Michael Drewitz wrote: Hi! I have to write a sp, which 1. divides an interval (argument) in smaller intervals 2. calculates the avg-values for these intervals; the PK are timestamps 3. returning the values as resultset for processing in Java 1 and 2 are not worse, but 3 is difficult. What's so difficult? You just select @avg1, @avg2, ... for the local variables into which you've placed the calculated values. Michael It were fine to get the result with one query. In your way there are returned only a few values per query. And thats a really terrible design for a Java-programmer. |
#5
| |||
| |||
|
|
Michael Peppler wrote: On Fri, 28 May 2004 12:32:06 +0200, Michael Drewitz wrote: Hi! I have to write a sp, which 1. divides an interval (argument) in smaller intervals 2. calculates the avg-values for these intervals; the PK are timestamps 3. returning the values as resultset for processing in Java 1 and 2 are not worse, but 3 is difficult. What's so difficult? You just select @avg1, @avg2, ... for the local variables into which you've placed the calculated values. Michael It were fine to get the result with one query. In your way there are returned only a few values per query. And thats a really terrible design for a Java-programmer. Michael, too :-) |
#6
| |||
| |||
|
|
You just select @avg1, @avg2, ... for the local variables into which you've placed the calculated values. Michael It were fine to get the result with one query. In your way there are returned only a few values per query. And thats a really terrible design for a Java-programmer. I guess you need to be more explicit in what you are trying to accomplish. Maybe there's a way to write a single SQL statement/result set that returns the required data... |
#7
| |||
| |||
|
|
It were fine to get the result with one query. In your way there are returned only a few values per query. And thats a really terrible design for a Java-programmer. Michael, too :-) Possibly you could insert the results into a temp table and then select the table out at the end of the sproc. That way you'd be able to handle any number of output calculations. Would that satisfy a Java Programmer? That's my dream. But I couldnt realize it: |
#8
| |||
| |||
|
|
Adam H wrote: [snip] It were fine to get the result with one query. In your way there are returned only a few values per query. And thats a really terrible design for a Java-programmer. Michael, too :-) Possibly you could insert the results into a temp table and then select the table out at the end of the sproc. That way you'd be able to handle any number of output calculations. Would that satisfy a Java Programmer? That's my dream. But I couldnt realize it: -- The dialect is Transact-SQL ? |
|
declare local temporary table temp_values(avg_values double); .. select avg(fieldname) into #temp_values from tablename where ..; Then I get the error 'item #temp_values already exists' I posted some pseudo code in another message. Michael |
#9
| |||
| |||
|
|
Possibly you could insert the results into a temp table and then select the table out at the end of the sproc. That way you'd be able to handle any number of output calculations. Would that satisfy a Java Programmer? That's my dream. But I couldnt realize it: -- The dialect is Transact-SQL ? declare local temporary table temp_values(avg_values double); .. select avg(fieldname) into #temp_values from tablename where ..; Then I get the error 'item #temp_values already exists' I posted some pseudo code in another message. |
#10
| |||
| |||
|
|
Michael Peppler wrote: [snip] You just select @avg1, @avg2, ... for the local variables into which you've placed the calculated values. Michael It were fine to get the result with one query. In your way there are returned only a few values per query. And thats a really terrible design for a Java-programmer. I guess you need to be more explicit in what you are trying to accomplish. Maybe there's a way to write a single SQL statement/result set that returns the required data... I would like to do the following (sorry for the maybe wrong syntax, its not my SP): begin --arbitrary values, handed over as arguments declare @start_ timestamp; declare @end_ timestamp; |
|
another question: Is it possible to apply a handed over varchar or string in the select expression? |
![]() |
| Thread Tools | |
| Display Modes | |
| |