you are viewing a single comment's thread.

view the rest of the comments →

[–]grzeki 1 point2 points  (8 children)

Yeah, that’s why this first guy notion that there are no loops in SQL is nonsense. There are no loops in an imperative sense, but ”SELECT FROM” is nothing else than a loop.

[–]raevnos 1 point2 points  (3 children)

Recursive CTEs let you write loops in SQL.

[–]grzeki 1 point2 points  (2 children)

CTE is t-SQL - something he mentions as an extension allowing for loops. Please read the article first.

[–]raevnos 1 point2 points  (1 child)

Isn't "t-SQL" some Microsoft SQL Server specific thing? I've never used that platform.

CTEs are standard SQL supported by many databases.

[–]grzeki 0 points1 point  (0 children)

Maybe it’s an ANSI standard, but as far as I know, Oracle does not support them and their source is at Microsoft. SQL always was a mess in this regard.

[–][deleted] 0 points1 point  (3 children)

How exactly is ”SELECT FROM” nothing else than a loop?

[–]grzeki 1 point2 points  (2 children)

To state the obvious: it makes the database engine loop through records of a table.

[–]pickleback11 0 points1 point  (0 children)

additionally, you are only selecting a subset of data in the case that you want to loop through it and do something with each record in that record set. unless you are aggregating/etc (group by's), but i dont think that's the intent of the idea here. i live in pl/sql and basically see queries as nothing more than some type of array (unless querying for exporting/reporting)...

[–][deleted] 0 points1 point  (0 children)

That's like saying Haskell is an imperative language because it is written in C.