473,480 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how do arrays work?

OK, you pros out there are rolling your eyes at the subject line, but I have
never had to use arrays before.
The scenario:
ASP Intranet app keeps track of trouble tickets for a tech support group.
Table called Ticket has one row per ticket. Table named History has 0, 1, or
many rows per ticket. As the tech support person makes notes to update the
ticket, it adds a new row per entry into History table. One of the things
storeed in this table is the status (Closed, Suspended, Customer Research,
Customer Testing, my company research, my company coding, or my company
testing). I put it into this table instead of the Ticket table because we
want to know what state it was in as it when through the system until it got
resolved.

It works fine, so far, after 2 months in production. However, now the boss
wants a report which will summarize how long each ticket spent in each
state. So it will show that a ticket spent 3 hours in Customer Testing, 12
hours in my company research, 19 hours in my company coding, etc.

Here's what I have done so far to make this happen:

'(created 2 recordsets, called RSTicketList and RSTicketHistory)

Do While not RSTicketList.EOF

set rsTicketHistory = nothing
Set rsTicketHistory = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * "
strSQL = strSQL & "FROM dbo.TKT_HISTORY H "
strSQL = strSQL & "WHERE TicketID ='"&strTicketID&"' "
rsTicketHistory.Open strSQL, objConnection,1,1

strTempStatus = rsTicketHistory("Status")
strTempTime = rsTicketHistory("TIMESTMP")
Do While not rsTicketHistory.EOF
If strTempStatus = rsTicketHistory("Status") then
'keep checking
Else
strStatusTime = somefunction(strTempTime -
rsTicketHistory("TIMESTMP"))
End if

----------------------------------------------------------------

NOTE: the "somefunction" thing in that 2nd-to-last line is a reference to
the fact that I will have to pull out hours which dont' fall into the
8:00-5:00 timeframe, but that's a bridge I'll cross when I get to it.

NOTE: Although the above code looks as if it would tax the performance of
the database and web server, this report would only be run once a month, and
only a few people use this app at any one time, anyway. Usually, less than 5
people.

Back to the problem: the time needs to be stored into that variable called
strStatusTime, but since it's a loop, there will be several. This probably
needs an array. (Please tell me if there is any easier way) Although I am
aware of their existence, I am not sure how to code arrays. I have
researched MSDN and my ASPbooks, but they aren't much help. They give some
philosophy about arrays, but I already know that stuff. I do much better
with code examples.

Is there an easier way than what I am doing? If I am on the right track,
can anyone offer me code samples or reference to code samples?
thanks
Jul 19 '05 #1
17 2676
A simple example.....

Dim arrStrings(5) 'Create an array with 5 elements, numbered from 0 -
4

'Populate each value
arrStrings(0)="Hi"
arrStrings(1)="there."
arrStrings(2)="How"
arrStrings(3)="are"
arrStrings(4)="you."

Dim iLoop
for iLoop = 0 to 4
Response.write arrStrings(iLoop) & " "
next

This is a single dimension array. You can have multiple dimensions-I'm sure
there's a limit but I don't know what it is.
A two dimensional array you can think of like a table or a tic-tac-toe board

X O X
X O X
X O X

So the X at the top left would be (0,0), the O beside it is (0,1) and the
final X on that row is (0,2),
the next row is (1,0) - (1,1) - (1,2)
the bottom row is (2,0) - (2,1) - (2,2)

A three dimensional one would just be represented like (1,1,1) and four
dimensions like (1,1,1,1) -- Once you get past three or four dimensions, you
need a good imagination to visualize it.
In your question you don't know how big your array will be.
You can either loop through the recordset, like you are doing, and ReDim
preserve your array OR......

use GetRows method of your recordset to get it automagically converted to an
array!

Dim arrTickHistory
Set arrTickHistory=rsTicketHistory.GetRows()

Since you used a SELECT * in your query (naughty, naughty) I don't know how
many columns were returned. Let's pretend just two in which case your array
looks like.....

arrTickHistory(0,0) contains the returned value from first column, first row
arrTickHistory(1,0) contains the returned value from second column, first
row
arrTickHistory(0,1) contains the returned value from first column, second
row

etc....
Hope that helps

"middletree" <mi********@htomail.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
OK, you pros out there are rolling your eyes at the subject line, but I have never had to use arrays before.
The scenario:
ASP Intranet app keeps track of trouble tickets for a tech support group.
Table called Ticket has one row per ticket. Table named History has 0, 1, or many rows per ticket. As the tech support person makes notes to update the
ticket, it adds a new row per entry into History table. One of the things
storeed in this table is the status (Closed, Suspended, Customer Research,
Customer Testing, my company research, my company coding, or my company
testing). I put it into this table instead of the Ticket table because we
want to know what state it was in as it when through the system until it got resolved.

It works fine, so far, after 2 months in production. However, now the boss
wants a report which will summarize how long each ticket spent in each
state. So it will show that a ticket spent 3 hours in Customer Testing, 12
hours in my company research, 19 hours in my company coding, etc.

Here's what I have done so far to make this happen:

'(created 2 recordsets, called RSTicketList and RSTicketHistory)

Do While not RSTicketList.EOF

set rsTicketHistory = nothing
Set rsTicketHistory = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * "
strSQL = strSQL & "FROM dbo.TKT_HISTORY H "
strSQL = strSQL & "WHERE TicketID ='"&strTicketID&"' "
rsTicketHistory.Open strSQL, objConnection,1,1

strTempStatus = rsTicketHistory("Status")
strTempTime = rsTicketHistory("TIMESTMP")
Do While not rsTicketHistory.EOF
If strTempStatus = rsTicketHistory("Status") then
'keep checking
Else
strStatusTime = somefunction(strTempTime -
rsTicketHistory("TIMESTMP"))
End if

----------------------------------------------------------------

NOTE: the "somefunction" thing in that 2nd-to-last line is a reference to
the fact that I will have to pull out hours which dont' fall into the
8:00-5:00 timeframe, but that's a bridge I'll cross when I get to it.

NOTE: Although the above code looks as if it would tax the performance of
the database and web server, this report would only be run once a month, and only a few people use this app at any one time, anyway. Usually, less than 5 people.

Back to the problem: the time needs to be stored into that variable called
strStatusTime, but since it's a loop, there will be several. This probably
needs an array. (Please tell me if there is any easier way) Although I am
aware of their existence, I am not sure how to code arrays. I have
researched MSDN and my ASPbooks, but they aren't much help. They give some
philosophy about arrays, but I already know that stuff. I do much better
with code examples.

Is there an easier way than what I am doing? If I am on the right track,
can anyone offer me code samples or reference to code samples?
thanks

Jul 19 '05 #2
I don't know that this is the best scenario for working with arrays. What I
would do in this case, is either figure out a query that will return the
summarized data already (I can't think of one, as I'm quite the querying
rookie), or create a variable for each status. You could put all the status
time subs into an array, but there wouldn't be much advantage, in my
opinion.

Ray at work

"middletree" <mi********@htomail.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
OK, you pros out there are rolling your eyes at the subject line, but I have never had to use arrays before.
The scenario:
ASP Intranet app keeps track of trouble tickets for a tech support group.
Table called Ticket has one row per ticket. Table named History has 0, 1, or many rows per ticket. As the tech support person makes notes to update the
ticket, it adds a new row per entry into History table. One of the things
storeed in this table is the status (Closed, Suspended, Customer Research,
Customer Testing, my company research, my company coding, or my company
testing). I put it into this table instead of the Ticket table because we
want to know what state it was in as it when through the system until it got resolved.

It works fine, so far, after 2 months in production. However, now the boss
wants a report which will summarize how long each ticket spent in each
state. So it will show that a ticket spent 3 hours in Customer Testing, 12
hours in my company research, 19 hours in my company coding, etc.

Here's what I have done so far to make this happen:

'(created 2 recordsets, called RSTicketList and RSTicketHistory)

Do While not RSTicketList.EOF

set rsTicketHistory = nothing
Set rsTicketHistory = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * "
strSQL = strSQL & "FROM dbo.TKT_HISTORY H "
strSQL = strSQL & "WHERE TicketID ='"&strTicketID&"' "
rsTicketHistory.Open strSQL, objConnection,1,1

strTempStatus = rsTicketHistory("Status")
strTempTime = rsTicketHistory("TIMESTMP")
Do While not rsTicketHistory.EOF
If strTempStatus = rsTicketHistory("Status") then
'keep checking
Else
strStatusTime = somefunction(strTempTime -
rsTicketHistory("TIMESTMP"))
End if

----------------------------------------------------------------

NOTE: the "somefunction" thing in that 2nd-to-last line is a reference to
the fact that I will have to pull out hours which dont' fall into the
8:00-5:00 timeframe, but that's a bridge I'll cross when I get to it.

NOTE: Although the above code looks as if it would tax the performance of
the database and web server, this report would only be run once a month, and only a few people use this app at any one time, anyway. Usually, less than 5 people.

Back to the problem: the time needs to be stored into that variable called
strStatusTime, but since it's a loop, there will be several. This probably
needs an array. (Please tell me if there is any easier way) Although I am
aware of their existence, I am not sure how to code arrays. I have
researched MSDN and my ASPbooks, but they aren't much help. They give some
philosophy about arrays, but I already know that stuff. I do much better
with code examples.

Is there an easier way than what I am doing? If I am on the right track,
can anyone offer me code samples or reference to code samples?
thanks

Jul 19 '05 #3
Thanks. I am less far along with queries than ASP, so I posted this question
to the SQL Prog forum, didn't get a workable answer.
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:eM**************@TK2MSFTNGP10.phx.gbl...
I don't know that this is the best scenario for working with arrays. What I would do in this case, is either figure out a query that will return the
summarized data already (I can't think of one, as I'm quite the querying
rookie), or create a variable for each status. You could put all the status time subs into an array, but there wouldn't be much advantage, in my
opinion.

Ray at work

"middletree" <mi********@htomail.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
OK, you pros out there are rolling your eyes at the subject line, but I have
never had to use arrays before.
The scenario:
ASP Intranet app keeps track of trouble tickets for a tech support group. Table called Ticket has one row per ticket. Table named History has 0, 1, or
many rows per ticket. As the tech support person makes notes to update
the ticket, it adds a new row per entry into History table. One of the things storeed in this table is the status (Closed, Suspended, Customer Research, Customer Testing, my company research, my company coding, or my company
testing). I put it into this table instead of the Ticket table because we want to know what state it was in as it when through the system until it

got
resolved.

It works fine, so far, after 2 months in production. However, now the boss wants a report which will summarize how long each ticket spent in each
state. So it will show that a ticket spent 3 hours in Customer Testing, 12 hours in my company research, 19 hours in my company coding, etc.

Here's what I have done so far to make this happen:

'(created 2 recordsets, called RSTicketList and RSTicketHistory)

Do While not RSTicketList.EOF

set rsTicketHistory = nothing
Set rsTicketHistory = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * "
strSQL = strSQL & "FROM dbo.TKT_HISTORY H "
strSQL = strSQL & "WHERE TicketID ='"&strTicketID&"' "
rsTicketHistory.Open strSQL, objConnection,1,1

strTempStatus = rsTicketHistory("Status")
strTempTime = rsTicketHistory("TIMESTMP")
Do While not rsTicketHistory.EOF
If strTempStatus = rsTicketHistory("Status") then
'keep checking
Else
strStatusTime = somefunction(strTempTime -
rsTicketHistory("TIMESTMP"))
End if

----------------------------------------------------------------

NOTE: the "somefunction" thing in that 2nd-to-last line is a reference to the fact that I will have to pull out hours which dont' fall into the
8:00-5:00 timeframe, but that's a bridge I'll cross when I get to it.

NOTE: Although the above code looks as if it would tax the performance of the database and web server, this report would only be run once a month,

and
only a few people use this app at any one time, anyway. Usually, less than 5
people.

Back to the problem: the time needs to be stored into that variable

called strStatusTime, but since it's a loop, there will be several. This probably needs an array. (Please tell me if there is any easier way) Although I am aware of their existence, I am not sure how to code arrays. I have
researched MSDN and my ASPbooks, but they aren't much help. They give some philosophy about arrays, but I already know that stuff. I do much better
with code examples.

Is there an easier way than what I am doing? If I am on the right track, can anyone offer me code samples or reference to code samples?
thanks


Jul 19 '05 #4
This looks like something I can work with. Thanks!
"TomB" <sh*****@hotmail.com> wrote in message
news:#c**************@TK2MSFTNGP10.phx.gbl...
A simple example.....

Dim arrStrings(5) 'Create an array with 5 elements, numbered from 0 - 4

'Populate each value
arrStrings(0)="Hi"
arrStrings(1)="there."
arrStrings(2)="How"
arrStrings(3)="are"
arrStrings(4)="you."

Dim iLoop
for iLoop = 0 to 4
Response.write arrStrings(iLoop) & " "
next

This is a single dimension array. You can have multiple dimensions-I'm sure there's a limit but I don't know what it is.
A two dimensional array you can think of like a table or a tic-tac-toe board
X O X
X O X
X O X

So the X at the top left would be (0,0), the O beside it is (0,1) and the
final X on that row is (0,2),
the next row is (1,0) - (1,1) - (1,2)
the bottom row is (2,0) - (2,1) - (2,2)

A three dimensional one would just be represented like (1,1,1) and four
dimensions like (1,1,1,1) -- Once you get past three or four dimensions, you need a good imagination to visualize it.
In your question you don't know how big your array will be.
You can either loop through the recordset, like you are doing, and ReDim
preserve your array OR......

use GetRows method of your recordset to get it automagically converted to an array!

Dim arrTickHistory
Set arrTickHistory=rsTicketHistory.GetRows()

Since you used a SELECT * in your query (naughty, naughty) I don't know how many columns were returned. Let's pretend just two in which case your array looks like.....

arrTickHistory(0,0) contains the returned value from first column, first row arrTickHistory(1,0) contains the returned value from second column, first
row
arrTickHistory(0,1) contains the returned value from first column, second
row

etc....
Hope that helps

"middletree" <mi********@htomail.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
OK, you pros out there are rolling your eyes at the subject line, but I have
never had to use arrays before.
The scenario:
ASP Intranet app keeps track of trouble tickets for a tech support group. Table called Ticket has one row per ticket. Table named History has 0, 1, or
many rows per ticket. As the tech support person makes notes to update
the ticket, it adds a new row per entry into History table. One of the things storeed in this table is the status (Closed, Suspended, Customer Research, Customer Testing, my company research, my company coding, or my company
testing). I put it into this table instead of the Ticket table because we want to know what state it was in as it when through the system until it

got
resolved.

It works fine, so far, after 2 months in production. However, now the boss wants a report which will summarize how long each ticket spent in each
state. So it will show that a ticket spent 3 hours in Customer Testing, 12 hours in my company research, 19 hours in my company coding, etc.

Here's what I have done so far to make this happen:

'(created 2 recordsets, called RSTicketList and RSTicketHistory)

Do While not RSTicketList.EOF

set rsTicketHistory = nothing
Set rsTicketHistory = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * "
strSQL = strSQL & "FROM dbo.TKT_HISTORY H "
strSQL = strSQL & "WHERE TicketID ='"&strTicketID&"' "
rsTicketHistory.Open strSQL, objConnection,1,1

strTempStatus = rsTicketHistory("Status")
strTempTime = rsTicketHistory("TIMESTMP")
Do While not rsTicketHistory.EOF
If strTempStatus = rsTicketHistory("Status") then
'keep checking
Else
strStatusTime = somefunction(strTempTime -
rsTicketHistory("TIMESTMP"))
End if

----------------------------------------------------------------

NOTE: the "somefunction" thing in that 2nd-to-last line is a reference to the fact that I will have to pull out hours which dont' fall into the
8:00-5:00 timeframe, but that's a bridge I'll cross when I get to it.

NOTE: Although the above code looks as if it would tax the performance of the database and web server, this report would only be run once a month,

and
only a few people use this app at any one time, anyway. Usually, less than 5
people.

Back to the problem: the time needs to be stored into that variable

called strStatusTime, but since it's a loop, there will be several. This probably needs an array. (Please tell me if there is any easier way) Although I am aware of their existence, I am not sure how to code arrays. I have
researched MSDN and my ASPbooks, but they aren't much help. They give some philosophy about arrays, but I already know that stuff. I do much better
with code examples.

Is there an easier way than what I am doing? If I am on the right track, can anyone offer me code samples or reference to code samples?
thanks


Jul 19 '05 #5
middletree,

Can you post the field list per table?
I have posted a function to get the work hours between two date stamps
before.

I can repost if needed.

An expeditious solution would be a dictionary object to total the time per
section.
I will help if needed.
--
-dlbjr

Discerning resolutions for the alms
Jul 19 '05 #6
Comments inline:

"dlbjr" <do******@do.u> wrote in message
news:gSRub.198$Qy4.14735@typhoon01...
middletree,
Can you post the field list per table?

Not sure what you mean. Do you mean list the fields here?

If so:

Tablename: Ticket
Fields: TicketID(identity field-integer), ActualTimeStamp, LastModified(a
timestamp field), AssignedEmployee (an integer, which I'll join with
Employee table to pull first and lastname), Environment(varchar),
ProbTye(int, join with ProbType table to obtain description)

and from Tablename: History:
Fields: TicketID (FK --PK on Ticket table), TIMESTMP, Status(Int, joined
with Status table to get description)
I have posted a function to get the work hours between two date stamps
before.

I can repost if needed.

Yes, that was a few days ago, in response to my question. I will have that.
I'm trying to tackle this first, then that.

An expeditious solution would be a dictionary object to total the time per section.
I am not much of an ASP guy, and not sure what a dictionary is. I figure
it's something good to learn, but don't know if I can learn it in time to
get this done by next Wednesday, which is when the boss promised it to the
CEO.
I will help if needed.
--

I appreciate that.
-dlbjr

Discerning resolutions for the alms

Jul 19 '05 #7
Had company and had to act like I cared.

I'll pound on it tomorrow afternoon.
--
-dlbjr

Discerning resolutions for the alms
Jul 19 '05 #8
"dlbjr" <do******@do.u> wrote in message
news:c4Wub.199$Qy4.15048@typhoon01...
Had company and had to act like I cared.


Outstanding! :]

Ray at work
Jul 19 '05 #9
I think the dimensional limit is 256, though what you would possibly want to
do with an array that size is beyond me. In 15 years, I've never had a
reason to go above 3.

- Wm

William Morris
Product Development, Seritas LLC


"TomB" <sh*****@hotmail.com> wrote in message
news:#c**************@TK2MSFTNGP10.phx.gbl...
A simple example.....

Dim arrStrings(5) 'Create an array with 5 elements, numbered from 0 - 4

'Populate each value
arrStrings(0)="Hi"
arrStrings(1)="there."
arrStrings(2)="How"
arrStrings(3)="are"
arrStrings(4)="you."

Dim iLoop
for iLoop = 0 to 4
Response.write arrStrings(iLoop) & " "
next

This is a single dimension array. You can have multiple dimensions-I'm sure there's a limit but I don't know what it is.
A two dimensional array you can think of like a table or a tic-tac-toe board
X O X
X O X
X O X

So the X at the top left would be (0,0), the O beside it is (0,1) and the
final X on that row is (0,2),
the next row is (1,0) - (1,1) - (1,2)
the bottom row is (2,0) - (2,1) - (2,2)

A three dimensional one would just be represented like (1,1,1) and four
dimensions like (1,1,1,1) -- Once you get past three or four dimensions, you need a good imagination to visualize it.
In your question you don't know how big your array will be.
You can either loop through the recordset, like you are doing, and ReDim
preserve your array OR......

use GetRows method of your recordset to get it automagically converted to an array!

Dim arrTickHistory
Set arrTickHistory=rsTicketHistory.GetRows()

Since you used a SELECT * in your query (naughty, naughty) I don't know how many columns were returned. Let's pretend just two in which case your array looks like.....

arrTickHistory(0,0) contains the returned value from first column, first row arrTickHistory(1,0) contains the returned value from second column, first
row
arrTickHistory(0,1) contains the returned value from first column, second
row

etc....
Hope that helps

"middletree" <mi********@htomail.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
OK, you pros out there are rolling your eyes at the subject line, but I have
never had to use arrays before.
The scenario:
ASP Intranet app keeps track of trouble tickets for a tech support group. Table called Ticket has one row per ticket. Table named History has 0, 1, or
many rows per ticket. As the tech support person makes notes to update
the ticket, it adds a new row per entry into History table. One of the things storeed in this table is the status (Closed, Suspended, Customer Research, Customer Testing, my company research, my company coding, or my company
testing). I put it into this table instead of the Ticket table because we want to know what state it was in as it when through the system until it

got
resolved.

It works fine, so far, after 2 months in production. However, now the boss wants a report which will summarize how long each ticket spent in each
state. So it will show that a ticket spent 3 hours in Customer Testing, 12 hours in my company research, 19 hours in my company coding, etc.

Here's what I have done so far to make this happen:

'(created 2 recordsets, called RSTicketList and RSTicketHistory)

Do While not RSTicketList.EOF

set rsTicketHistory = nothing
Set rsTicketHistory = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * "
strSQL = strSQL & "FROM dbo.TKT_HISTORY H "
strSQL = strSQL & "WHERE TicketID ='"&strTicketID&"' "
rsTicketHistory.Open strSQL, objConnection,1,1

strTempStatus = rsTicketHistory("Status")
strTempTime = rsTicketHistory("TIMESTMP")
Do While not rsTicketHistory.EOF
If strTempStatus = rsTicketHistory("Status") then
'keep checking
Else
strStatusTime = somefunction(strTempTime -
rsTicketHistory("TIMESTMP"))
End if

----------------------------------------------------------------

NOTE: the "somefunction" thing in that 2nd-to-last line is a reference to the fact that I will have to pull out hours which dont' fall into the
8:00-5:00 timeframe, but that's a bridge I'll cross when I get to it.

NOTE: Although the above code looks as if it would tax the performance of the database and web server, this report would only be run once a month,

and
only a few people use this app at any one time, anyway. Usually, less than 5
people.

Back to the problem: the time needs to be stored into that variable

called strStatusTime, but since it's a loop, there will be several. This probably needs an array. (Please tell me if there is any easier way) Although I am aware of their existence, I am not sure how to code arrays. I have
researched MSDN and my ASPbooks, but they aren't much help. They give some philosophy about arrays, but I already know that stuff. I do much better
with code examples.

Is there an easier way than what I am doing? If I am on the right track, can anyone offer me code samples or reference to code samples?
thanks


Jul 19 '05 #10
You've obviously never mapped out the dimensions of object's transformation
over time vbscript. ;]

Ray at work

"William Morris" <NO**************@seamlyne.com> wrote in message
news:bp*************@ID-205671.news.uni-berlin.de...
I think the dimensional limit is 256, though what you would possibly want to do with an array that size is beyond me. In 15 years, I've never had a
reason to go above 3.

- Wm

William Morris
Product Development, Seritas LLC

Jul 19 '05 #11
"middletree" <mi********@htomail.com> wrote in message
news:eQ**************@TK2MSFTNGP09.phx.gbl...
Thanks. I am less far along with queries than ASP, so I posted this question to the SQL Prog forum, didn't get a workable answer.


When you get "further along" with queries, here's a stored procedure to
get you started. ;-)

CREATE PROCEDURE uspTicketStatusDurations
@TicketID INT
AS
SELECT
S.Description,
SUM(TH.Duration) AS Duration
FROM
Status AS S,
(
SELECT
THC.Status,
DATEDIFF("s",THC.TIMESTMP,MIN(THN.TIMESTMP)) AS Duration
FROM
TKT_HISTORY AS THC,
TKT_HISTORY AS THN
WHERE
THC.TicketID = @TicketID AND
THN.TicketID = @TicketID AND
THC.TIMESTMP < THN.TIMESTMP
GROUP BY
THC.TIMESTMP,
THC.Status
) AS TH
WHERE
TH.Status = S.StatusID
GROUP BY
S.Description
Notes:
1. In your original post, you wrapped the TicketID value in apostrophes.
This indicated that the datatype was a string. However, in a follow-up
post you indicate that the TicketID is an integer. In the future, please
provide details about related table structures. It would save us both
some time. ;-)

2. Also, please specify what database/version you are using. For the
above, I assumed SQL Server 2000.

3. The duration column returned by the above stored procedure is
reported in seconds.
HTH
-Chris Hohmann
Jul 19 '05 #12
Thanks for this. For the record, SQL Server 2000 is my RDBMS, and in the
tables, TicketID is in fact an Interger, yet when I have it in quotes:
Select * From Ticket Where TicketID = '12345'

it works fine.
"Chris Hohmann" <no****@thankyou.com> wrote in message
news:Ob**************@TK2MSFTNGP10.phx.gbl...
"middletree" <mi********@htomail.com> wrote in message
news:eQ**************@TK2MSFTNGP09.phx.gbl...
Thanks. I am less far along with queries than ASP, so I posted this

question
to the SQL Prog forum, didn't get a workable answer.


When you get "further along" with queries, here's a stored procedure to
get you started. ;-)

CREATE PROCEDURE uspTicketStatusDurations
@TicketID INT
AS
SELECT
S.Description,
SUM(TH.Duration) AS Duration
FROM
Status AS S,
(
SELECT
THC.Status,
DATEDIFF("s",THC.TIMESTMP,MIN(THN.TIMESTMP)) AS Duration
FROM
TKT_HISTORY AS THC,
TKT_HISTORY AS THN
WHERE
THC.TicketID = @TicketID AND
THN.TicketID = @TicketID AND
THC.TIMESTMP < THN.TIMESTMP
GROUP BY
THC.TIMESTMP,
THC.Status
) AS TH
WHERE
TH.Status = S.StatusID
GROUP BY
S.Description
Notes:
1. In your original post, you wrapped the TicketID value in apostrophes.
This indicated that the datatype was a string. However, in a follow-up
post you indicate that the TicketID is an integer. In the future, please
provide details about related table structures. It would save us both
some time. ;-)

2. Also, please specify what database/version you are using. For the
above, I assumed SQL Server 2000.

3. The duration column returned by the above stored procedure is
reported in seconds.
HTH
-Chris Hohmann

Jul 19 '05 #13
Chris,

Your solution is the ultimate since MSSQL is in use.
This is why I asked if middletree was using Access.

Stored Procedures is the only way to go!

-dlbjr

Discerning resolutions for the alms
Jul 19 '05 #14
"middletree" <mi********@htomail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Thanks for this. For the record, SQL Server 2000 is my RDBMS, and in the tables, TicketID is in fact an Interger, yet when I have it in quotes:
Select * From Ticket Where TicketID = '12345'

it works fine.


Yes, there's an implicit coercion taking place, but for those of us
trying to reproduce your environment, knowing the column datatypes
helps. :-)
Jul 19 '05 #15
Whatever I can do to help you help me, I'll do it.
"Chris Hohmann" <no****@thankyou.com> wrote in message
news:uO**************@TK2MSFTNGP09.phx.gbl...
"middletree" <mi********@htomail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Thanks for this. For the record, SQL Server 2000 is my RDBMS, and in

the
tables, TicketID is in fact an Interger, yet when I have it in quotes:
Select * From Ticket Where TicketID = '12345'

it works fine.


Yes, there's an implicit coercion taking place, but for those of us
trying to reproduce your environment, knowing the column datatypes
helps. :-)

Jul 19 '05 #16
I don't have the option of doing SP's. Long story, Painful, even.
"dlbjr" <do******@do.u> wrote in message
news:u0cvb.200$Qy4.15106@typhoon01...
Chris,

Your solution is the ultimate since MSSQL is in use.
This is why I asked if middletree was using Access.

Stored Procedures is the only way to go!

-dlbjr

Discerning resolutions for the alms

Jul 19 '05 #17
"middletree" <mi********@htomail.com> wrote in message
news:uN**************@TK2MSFTNGP09.phx.gbl...
I don't have the option of doing SP's. Long story, Painful, even.


Hmm? I won't ask why, but you have my condolences. You're missing out on
A LOT without stored procedures. However, in this case, there's no real
programmatic logic in the stored procedure so you could just build the
SQL equivalent and run that. They are letting you run queries, right!?
;-)

strSQL = "" & _
"SELECT" & _
"S.Description," & _
"SUM(TH.Duration) AS Duration" & _
"FROM" & _
"Status AS S," & _
"(" & _
"SELECT" & _
"THC.Status," & _
"DATEDIFF("s",THC.TIMESTMP,MIN(THN.TIMESTMP)) AS Duration" & _
"FROM" & _
"TKT_HISTORY AS THC," & _
"TKT_HISTORY AS THN" & _
"WHERE" & _
"THC.TicketID = " & strTicketID & " AND" & _
"THN.TicketID = " & strTicketID & " AND" & _
"THC.TIMESTMP < THN.TIMESTMP" & _
"GROUP BY" & _
"THC.TIMESTMP," & _
"THC.Status" & _
") AS TH" & _
"WHERE" & _
"TH.Status = S.StatusID" & _
"GROUP BY" & _
"S.Description"

-Chris Hohmann
Jul 19 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3439
by: Dariusz | last post by:
I want to use arrays in my website (flat file for a guestbook), but despite having read through countless online tutorials on the topic, I just can't get my code to work. I know there are...
19
2815
by: Canonical Latin | last post by:
"Leor Zolman" <leor@bdsoft.com> wrote > "Canonical Latin" <javaplus@hotmail.com> wrote: > > > ... > >But I'm still curious as to the rational of having type >...
21
3889
by: Matteo Settenvini | last post by:
Ok, I'm quite a newbie, so this question may appear silly. I'm using g++ 3.3.x. I had been taught that an array isn't a lot different from a pointer (in fact you can use the pointer arithmetics to...
9
6650
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the...
7
6831
by: Joseph Lee | last post by:
Hi All, I am having problem when i am using hashtable to keep an array of bytes value as keys. Take a look at the code snippet below --------------------------------------------------- ...
39
19550
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
1
2430
by: Doug_J_W | last post by:
I have a Visual Basic (2005) project that contains around twenty embedded text files as resources. The text files contain two columns of real numbers that are separated by tab deliminator, and are...
16
2502
by: mike3 | last post by:
(I'm xposting this to both comp.lang.c++ and comp.os.ms- windows.programmer.win32 since there's Windows material in here as well as questions related to standard C++. Not sure how that'd go over...
29
35374
weaknessforcats
by: weaknessforcats | last post by:
Arrays Revealed Introduction Arrays are the built-in containers of C and C++. This article assumes the reader has some experiece with arrays and array syntax but is not clear on a )exactly how...
127
4746
by: sanjay.vasudevan | last post by:
Why are the following declarations invalid in C? int f(); int f(); It would be great if anyone could also explain the design decision for such a language restricton. Regards, Sanjay
0
7045
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7087
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6741
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4782
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
182
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.