How can we use loop in database to repeat some queries ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How can we use loop in database to repeat some queries ?

16th Jul 2016, 8:16 PM
Dev_140897
Dev_140897 - avatar
4 Answers
+ 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
17th Jul 2016, 1:35 AM
Justin McKay
Justin McKay - avatar
+ 2
in oracle you need to learn PL/SQL. SQL natively do not support looping.
19th Jul 2016, 5:12 PM
Saurabh Joshi
Saurabh Joshi - avatar
+ 2
by using pl/SQL we can do loop operations.
21st Jul 2016, 3:37 PM
thanuja
0
by loop some queries or repeat transactions. I think you means jobs ?
26th Jul 2016, 11:09 AM
Abdalrhman Shazally Abdalrhman Alhassan
Abdalrhman Shazally Abdalrhman Alhassan - avatar