给出一个简单的游标语句:
DECLARE vend_cursor CURSOR
FOR SELECT * FROM Purchasing.Vendor
--say my Purchasing.Vendor table did not have 'Company ABC', 'Company F'
--can I explicitly add 'Company ABC' and 'Company F' to the Cursor without
--adding them to the database?
OPEN vend_cursor
FETCH NEXT FROM vend_cursor;
是否可以为游标添加显式值以进行迭代?
实际上,我的应用程序回答了一个显而易见的问题:“为什么你不只是将它们添加到数据库中?”只是看看直接添加到游标的语法是什么样的。
答案 0 :(得分:5)
DECLARE vend_cursor CURSOR
FOR SELECT * FROM Purchasing.Vendor
UNION ALL select .... 'Company ABC'
UNION ALL select .... 'Company F'
--say my Purchasing.Vendor table did not have 'Company ABC', 'Company F'
--can I explicitly add 'Company ABC' and 'Company F' to the Cursor without
--adding them to the database?
OPEN vend_cursor
FETCH NEXT FROM vend_cursor;