Registered member login:
Register Now
Altirigos » Notification Server and Solutions » Help Desk » Cursor help

» Current Poll
Do you leave the Aclient enabled?
YES - 82.81%
106 Votes
NO - 17.19%
22 Votes
Total Votes: 128
You may not vote on this poll.
» Stats
Members: 9,488
Threads: 11,748
Posts: 55,278
Top Poster: Nick (4,981)
Welcome our newest member, johno
» Online Users: 36
0 members and 36 guests
No Members online
Most users online at once 294, 06-30-2007 at 12:24 PM.
» March 2010
S M T W T F S
28 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 123
Reply
Old 02-01-2010, 02:32 PM   #1 (permalink)
 
Status: Junior Altiris Admin
Join Date: 01-26-2010
Location: pennsylvania
Posts: 5


Cursor help

I need to make a cursor to grab email addresses. Where an queueID is set to an email address and when the queueID is triggered/ matched it pulls the email address.

I did have a normal query that pulled down one email address. But some emails are assigned to multiple ID and some ID's have multiple emails assigned to it.

Here is the query I had at first:

Select emailAddress
From queueNotification
Where queueId = WORKITEM(workitem_assigned_to_worker_id)
AND (GetDate() Between ticketStartDate AND ticketEndDate
OR ticketEndDate = NULL)

Workitem() is the stntax from the system.

So I started making a stored procedure with a cursor in it so grab each email address that was assigned to that particular ID. So it would go through each orw at a time and put each email address into one long string and then send the emails out. But I'm having trouble.

Here is the Proc.:
Alter Procedure NotificationQueueEmail
(
@queueId int

)
As
Begin
Declare @emailAddress varchar (255)
Declare cursorQN_Email Cursor For

Select emailAddress
From queueNotification
Where queueId = @queueId -- took out WORKITEM(workitem_assigned_to_worker_id) and used the paramter @queueId
AND (GetDate() Between ticketStartDate AND ticketEndDate
OR ticketEndDate = NULL)
Open cursorQN_Email
--Performs the first fetch
Fetch Next From cursorQN_Email
Into @emailAddress
--Check ti see if there are anymore rows to fetch
While @@Fetch_Status = 0
Begin
Print @emailAddress + ';'
--Is executed as long as the previous fetch succeeds
Fetch Next From cursoreQN_Email
Into @emailAddress
End
Close cursorQN_Email
Deallocate cursorQN_Email
End
GO

Then I have this/// HDQUERY[[EXEC Altiris_Incidents.dbo.NotificationQueueEmail]] /// in the TO: section of the email address in the Notification rules.
I don't know if my paramters are the correct ones. Same with what variables I declared before the cursor.
Any help would be greatly apppreciated
mxstar45 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -4. The time now is 01:34 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
vB.Sponsors
Altirigos