54
Views
9
Comments
How to fetch list of record from sql
Question

Hi All,

How we can fetch list of record data from sql. i have created structure and write query in sql to fetch record but it is fetching single record only not multiple record in secondlevel no. please help. please find below attachment.(traditional web App)

thanks

2025-03-12 07-08-15
Nilesh Trivedi

Hi @ritu kushwaha, 

Please check that you're storing the child records in a List and not overwriting a single record in each iteration.

If possible, please share your OML file so I can review it in more detail.

Hope it helps.

Thank you.

UserImage.jpg
ritu kushwaha

Hi @Nilesh Trivedi ,

Thankyou for giving response. not possible to share oml file. 

Thanks

2026-01-28 16-57-48
Mihai Melencu
Champion

Hi @ritu kushwaha ,

Are you able to replicate your use case in a sample personal OML and share it?

To display a list within a list, you’ll need to place the sub-list inside a separate block. That block should have an input parameter for the main record’s ID, which you can use to fetch and display the related data. 

UserImage.jpg
ritu kushwaha

Hi @Mihai Melencu,

no we are fetching record through sql query and we don't need to use block our requirement is show data in expression. not able to recreate sample oml.

Thanks

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Ritu,

Mihai's answer is correct. If you do not understand a certain solution, or why it is a solution, you should not just dismiss it.

2018-08-26 20-34-32
Pankaj pant

Hi Ritu,

It looks like your SQL is returning only one record instead of a list — this typically happens when either:

  1. You are assigning the output to a structure or a single record, instead of a list.

  2. Your SQL query is correct, but you're using ExecuteScalar or assigning the result incorrectly in the logic.


Regards,

Pankaj


2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Ritu,

I fear you do not understand how SQL (or an Aggregate) works. By definition, a SQL query will return one or more rows (records) of data, each row containing one or more columns (attributes). It is impossible to have SQL return a row where one column has multiple values.

There are basically two solutions to your requirement:

  1. Return a row for each of the unique values for that column that needs multiple values. Except for that column, all other columns have duplicate values. That's how SQL works. You can then post-process the data, and create a list without the duplicate values, and a list-in-a-list with the unique values.
  2. Like Mihai suggested above, ignore the unique values for that column that needs multiple values. Instead, use a Block that has its own query to retrieve the values for that specific row. If the number of rows on screen is limited, and you do not need the full set of all data in case there are more rows, this solution is typically fast enough.
2023-06-14 11-14-48
Sharath Kumaar K K
AI Generated

Hi @ritu kushwaha, 

I believe your SQL only retrieves a single entry, but you need to compile a list of SecondLevelNo values. 
Below is a solution for you (for Traditional Web App): 

✅ Steps:

Step 1: Go to Domain and Structure and create a structure with name Example:

SecondLevelData - SecondLevelNo (Integer or Text)

Step 2: Select SQL widget and write the following SQL Query:

SELECT SecondLevelNo FROM YourTable WHERE SomeCondition = @InputValue 

Set Output Structure

Make sure to set the Output structure parameter for the SQL widget

Next, navigate to the output tab of the SQL widget. 

Then, add SecondLevelData as output. 

Do not forget to check ‘Is List’ = Yes ✅ 

Output List via Local Variable 

Set Output to a local variable of type List of SecondLevelData

Display in Table (Optional) 

Bind this variable to a Table Records widget to display the data, if needed.

This way you will be able to return and view all SecondLevelNo values from the data as needed. 

Do reach out if you need an OML sample from me. 

This answer was AI-generated. Please read it carefully and use the forums for clarifications
UserImage.jpg
ritu kushwaha

Hi @Sharath Kumaar K K,

thankyou that is the solution i want. now my issue was resolved thankyou so much. 

i used this query in my sql it is working for me.

STUFF((

        SELECT ' ,  ' + CAST([SecondLevelNumber] AS VARCHAR)

        FROM {FIS}

        WHERE {FIS}.[FormInspectionID] = {FI}.[Id]

        FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 2, '') AS ConcatenatedSecondLevelNumbers,


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.