FALCONSEYE
Programmer
i have the following cursor
declare PurchasedProductInsert cursor
keyset
global
for
select bundlename
from customer, orders, addressbook, orderitem
where customer.customerid = orders.customerid
and addressbook.customerid = customer.customerid
and orderstatusid in (1,2) -- successfull orders
and datediff(day, orders.orderdate, getdate()) = 1 -- records from yesterday only
and orders.orderid = orderitem.orderid
declare @bundlename varchar(50),
@prodId int
open PurchasedProductInsert
fetch next from PurchasedProductInsert into @bundlename
set nocount on
while @@fetch_status = 0
begin
-- find whether the product exists in the Products table, if not make an insert
use email
select @prodid = ProductID from Products where productname = '@bundlename'
if @@ROWCOUNT = 0
--new product
begin
/*insert into Products(ProductName, ProductNotes, Enabled, enableSubscription)
values (@bundlename, null, 1, 0)
*/
print 'prod name= '+convert(varchar(50),@bundlename)
end
else
begin
print 'SAME AS ABOVE'
end
fetch next from PurchasedProductInsert into @bundlename
end
close PurchasedProductInsert
deallocate purchasedproductinsert
I am trying to find if a product exists. If so, then print SAME AS ABOVE. If not print the product name. For some reason, when i see the output it looks like
prod name= Windows®
prod name= Windows®
prod name= HTML
prod name= Photoshop 7.0
prod name= HTML
prod name= Microsoft® Access
prod name= Excel
as you will see my product check fails. can someone please help me? what am i doing wrong? thanks in advance
declare PurchasedProductInsert cursor
keyset
global
for
select bundlename
from customer, orders, addressbook, orderitem
where customer.customerid = orders.customerid
and addressbook.customerid = customer.customerid
and orderstatusid in (1,2) -- successfull orders
and datediff(day, orders.orderdate, getdate()) = 1 -- records from yesterday only
and orders.orderid = orderitem.orderid
declare @bundlename varchar(50),
@prodId int
open PurchasedProductInsert
fetch next from PurchasedProductInsert into @bundlename
set nocount on
while @@fetch_status = 0
begin
-- find whether the product exists in the Products table, if not make an insert
use email
select @prodid = ProductID from Products where productname = '@bundlename'
if @@ROWCOUNT = 0
--new product
begin
/*insert into Products(ProductName, ProductNotes, Enabled, enableSubscription)
values (@bundlename, null, 1, 0)
*/
print 'prod name= '+convert(varchar(50),@bundlename)
end
else
begin
print 'SAME AS ABOVE'
end
fetch next from PurchasedProductInsert into @bundlename
end
close PurchasedProductInsert
deallocate purchasedproductinsert
I am trying to find if a product exists. If so, then print SAME AS ABOVE. If not print the product name. For some reason, when i see the output it looks like
prod name= Windows®
prod name= Windows®
prod name= HTML
prod name= Photoshop 7.0
prod name= HTML
prod name= Microsoft® Access
prod name= Excel
as you will see my product check fails. can someone please help me? what am i doing wrong? thanks in advance