+ 2
How can we use loop in database to repeat some queries ?
4 ответов
+ 3
'While' works in SQL Server 2008 & above.
USE AdventureWorks2012;
GO
WHILE (SELECT AVG(ListPrice) FROM Production.Product) < $300
BEGIN
UPDATE Production.Product
SET ListPrice = ListPrice * 2
SELECT MAX(ListPrice) FROM Production.Product
IF (SELECT MAX(ListPrice) FROM Production.Product) > $500
BREAK
ELSE
CONTINUE
END
+ 2
in oracle you need to learn PL/SQL. SQL natively do not support looping.
+ 2
by using pl/SQL we can do loop operations.
0
by loop some queries or repeat transactions. I think you means jobs ?