![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Помогите в работе с курсорами MS SQL 7
xxxCrazyManxxx © (2003-04-10 19:00:00)Сам запрос выглядит так:
DECLARE product_curs CURSOR
SCROLL
FOR SELECT Product.Article
FROM Journal INNER JOIN Document ON Journal.Document = Document.Document
INNER JOIN Address ON Document.Debitor = Address.Address
INNER JOIN Product ON Journal.Product = Product.Product
INNER JOIN Shift ON Document.Shift = Shift.Shift
INNER JOIN Operation ON Document.Operation = Operation.Operation
INNER JOIN GroupTax ON Journal.GroupTax = GroupTax.GroupTax
WHERE Address.AddressName = "АСПЕКТ-Л ООО"
FOR READ ONLY
CREATE TABLE #t
(Par varchar(16),
Pnu varchar(16),
Ppu int)
DECLARE
@Par varchar(16),
@Pnu varchar(16),
@Ppu int
SET @Par = ""
SET @Pnu = ""
SET @Ppu = 1
OPEN product_curs
WHILE @Ppu < @@CURSOR_ROWS
BEGIN
IF @Par <> @Pnu
FETCH product_curs INTO @Par
INSERT INTO #t (Pa) VALUES (@Par)
SET @Pnu = @Par
FETCH NEXT FROM product_curs
ELSE
FETCH NEXT FROM product_curs
END
SELECT * FROM #t
DROP TABLE #t
CLOSE product_curs
DEALLOCATE product_curs
Ругается на ELSE (Incorrect syntax near the keyword "ELSE".)
помогите , немогу разобраться.
Заранее благодарен!!!
xxxCrazyManxxx (2003-04-10 21:07:00) [1]Спасибо!!!!!!!!!
Zz_ (2003-04-10 20:53:00) [2]FETCH product_curs INTO @Par
...
FETCH NEXT FROM product_curs
Zelius (2003-04-10 20:30:00) [3]Может в этом дело?
IF @Par <> @Pnu
BEGIN -- <<<
FETCH product_curs INTO @Par
INSERT INTO #t (Pa) VALUES (@Par)
SET @Pnu = @Par
FETCH NEXT FROM product_curs
END -- <<<
ELSE
FETCH NEXT FROM product_curs
END