SunQuest
           MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old September 22nd, 2003, 09:51 AM
tienliu tienliu is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 3 tienliu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
problem with cursor

Hi,

This is an example of the data:
Date : 2003-08-29 16:31:42.000
ABA: 001
LineNumber: 1
Text: this is test1

The table contains different dates and line numbers can go from 1 to ...

When the user enters a text like '%test1%', the entire report of that date should be returned. I'm using a cursor to do the job, but can't make it work right. Can someone give me some pointers?

CREATE PROCEDURE Test
@date datetime,
@aba char(9),
@text VARCHAR(25)
As

CREATE TABLE #TEMP2
(
FORMAT_D datetime,
ABA_R char(9),
LINE_R int ,
REPORT_X varchar(163)
)
DECLARE @NEWREPORT VARCHAR(136)

DECLARE REPORT_CURSOR CURSOR LOCAL
FOR
SELECT REPORT_X
FROM CAT_ACTIVITY_REPORT
WHERE REPORT_X LIKE '%' + @text + '%'

OPEN REPORT_CURSOR

FETCH NEXT FROM REPORT_CURSOR INTO @NEWREPORT

WHILE @@FETCH_STATUS = 0
BEGIN
print @NEWREPORT
insert into #TEMP2
select
FORMAT_D,
ABA_R,
LINE_R,
REPORT_X

from CAT_ACTIVITY_REPORT
where

FORMAT_D >=@date + '00:00:00'
AND FORMAT_D < dateadd(day,1,@date) + '00:00:00'
AND ABA_R = @aba

FETCH NEXT FROM REPORT_cursor
INTO @NEWREPORT

END
CLOSE REPORT_CURSOR
DEALLOCATE REPORT_CURSOR

SELECT * FROM #TEMP2

Thanks for your help.

Reply With Quote
  #2  
Old November 14th, 2003, 11:16 AM
smackmeister smackmeister is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 21 smackmeister User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
what error does it give?

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > problem with cursor


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway