473,385 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Count Parameter not right

1
Having an issue with the @Count parameter in the following and I'm rather new to this so I may have missed something:

Create Procedure AAA
As
Declare Customer Cursor Fast_Forward
For
Select ID, DateFld from Table1 where type = 4 and ID In
(Select ID from Table1 where type_ID = 8)
Declare @Expiry Datetime
Declare @CustomerID Varchar(30)
Declare @Count int
Open Customer
Fetch Customer into @CustomerID, @Expiry
while (@@Fetch_Status <> -1)
Begin
Set @Count = (Select Count(*) from Followuptbl where
Datediff(Day,Create_Date,@Expiry) < 366 and ID = @CustomerID)
Update Table1 Set totalfollowupfld = @Count where ID = @CustomerID and Type = 5
Fetch Customer INTO @CustomerID, @Expiry
End
Close Cursor
Deallocate Cursor

I printed the values of @CustomerID, @Expiry and @Count. The procedure pulls in the correct number of Rows, the values in @CustomerID & @Expiry are as expected but @Count is always 0 so nothing changes
Tried running the Select Count statement by itself and filled in the values for @Expiry and @CustomerID. I got the expected Count. This is supposed to track the number of inquiries made during the Customers subscription and update an Integer Column. The Database is not properly normalized hence the funny select statement at the top to get ID's tagged as Active and having an expiry date (Exists on 2 lines in the Table) Any ideas?
Jun 29 '07 #1
1 1646
Motoma
3,237 Expert 2GB
In the future, please use the code tags.

I think all you need is this:
Expand|Select|Wrap|Line Numbers
  1. Select @Count = Count(*) from Followuptbl where Datediff(Day,Create_Date,@Expiry) < 366 and ID = @CustomerID
  2.  
Having an issue with the @Count parameter in the following and I'm rather new to this so I may have missed something:

Create Procedure AAA
As
Declare Customer Cursor Fast_Forward
For
Select ID, DateFld from Table1 where type = 4 and ID In
(Select ID from Table1 where type_ID = 8)
Declare @Expiry Datetime
Declare @CustomerID Varchar(30)
Declare @Count int
Open Customer
Fetch Customer into @CustomerID, @Expiry
while (@@Fetch_Status <> -1)
Begin
Set @Count = (Select Count(*) from Followuptbl where
Datediff(Day,Create_Date,@Expiry) < 366 and ID = @CustomerID)
Update Table1 Set totalfollowupfld = @Count where ID = @CustomerID and Type = 5
Fetch Customer INTO @CustomerID, @Expiry
End
Close Cursor
Deallocate Cursor

I printed the values of @CustomerID, @Expiry and @Count. The procedure pulls in the correct number of Rows, the values in @CustomerID & @Expiry are as expected but @Count is always 0 so nothing changes
Tried running the Select Count statement by itself and filled in the values for @Expiry and @CustomerID. I got the expected Count. This is supposed to track the number of inquiries made during the Customers subscription and update an Integer Column. The Database is not properly normalized hence the funny select statement at the top to get ID's tagged as Active and having an expiry date (Exists on 2 lines in the Table) Any ideas?
Jun 29 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Andreas Paasch | last post by:
I've got somehow a little peculiar problem and can't seem to find the right solution so I could use a hand/hint or two. On toppings.php I have - among others: <a...
4
by: Laszlo Csabi | last post by:
Hi Folks, Can someone explain me why I'm getting the following error? The error message I got is : "Parameter count does not match Parameter Value count."
2
by: Julio Allegue | last post by:
I am getting the wrong Count(*) on vb.net using the ExecuteScalar . It returns all the rows. It doesn't seem to look at the WHERE clause. At the same time, I am getting the correct count on "SQL...
6
by: jack | last post by:
I have a class which overloads the insertion operator '<<' for every type that ostream handles. I do this so that I can use my class a direct replacement for cout and cerr where the insertion...
7
by: Killer42 | last post by:
Hi all. I dabble with Access, but haven't done anything in-depth for a number of years. What I want to do now is probably a fairly simple JOIN or something, but I just can't recall how to go about...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
7
kcdoell
by: kcdoell | last post by:
Good Morning World: I have written the following code: 'Gives the user to delete and replace all records for a specified parameter LockSQL = "SELECT * FROM tblStaticAllForecast WHERE" & _...
13
by: craigchalmers | last post by:
Hi I am a complete novice so hope someone can shed some light on my problem/goal. I have an access database with some records in it. i have two fields 1) ArrivalDate 2) ReturnDate
4
by: AAaron123 | last post by:
trying to understand the below shown code. After this is run the browser opens a file-save dialog box for saving the file. I wonder how it knows I want the file saved? But more important, the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.