Loops? #306
Answered
by
lovasoa
NathanielCJ99
asked this question in
Q&A
Loops?
#306
|
Want to implement a loop function so I can make a variable number of data entry points(typed by user) in a form. Does not seem as any loops are usable/available. Using this to connect to a testing database, based on the number of values needed per test. Any suggestions? |
Answered by
lovasoa
May 8, 2024
Replies: 2 comments 13 replies
|
Hello and welcome to SQLPage! sql is a declarative language. it doesn't have loops. However, what you want to do is definitively possible to express in sql using a recursive common table expression select 'form' as component;
WITH RECURSIVE InputFields AS (
SELECT 1 AS i
UNION ALL
SELECT i + 1
FROM InputFields
WHERE i < $number_of_fields::int
)
SELECT 'Input field ' || i AS name
FROM InputFields; |
4 replies
|
Adding to this, I am wondering how I could insert the data from My from into the database after submission. Using the same WITH statement? |
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Microsoft SQL Server does indeed support recursive CTEs, but not the keyword "recursive".