LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Repeat same rows multiple times in a result

Solved!
Go to solution

I have an interesting challenge to repeat same rows multiple times in a result.
As an example, I have a table with 3 records.

---------------------------------
| id | Product | Description | Qty |
---------------------------------
| 1 | P1 | Product 1 | 2 |
| 2 | P2 | Product 2 | 3 |

| 3 | P3 | Product 3 | 1 |
---------------------------------

The result set should look like below with 5 rows

---------------------------------
| id | Product | Description | Qty |
---------------------------------
| 1 | P1 | Product 1 | 2 |

| 2 | P2 | Product 2 | 3 |

| 1 | P1 | Product 1 | 2 |
| 3 | P3 | Product 3 | 1 |
| 2 | P2 | Product 2 | 3 |
---------------------------------

I have tried with UNION ALL, IN Functionalities but missing something in a query.

AB
Kudos are Accepted
0 Kudos
Message 1 of 9
(9,945 Views)

Hi AB,

 

The result set should look like below with 5 rows

Index the rows as needed in a loop and use the autoindexed loop output…

 

I have tried with UNION ALL, IN Functionalities but missing something in a query.

Are you talking about LabVIEW here at all?

Could you attach your VI?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(9,937 Views)

Index the rows as needed in a loop and use the auto indexed loop output…

Indexing will increase time to extract data base

 

I am taking about SQL query (UNION ALL,IN)used to extract data from database

AB
Kudos are Accepted
0 Kudos
Message 3 of 9
(9,900 Views)

Hi AB,

 

maybe you should give a FULL view of your task!

 

So you query some "rows" (aka records) from a database. Then you want to output those "rows" somewhere in a certain order with some of the "rows" duplicated in a "random" scheme.

Atleast that's what I read from your description so far…

 

Where do you read from?

How do you read the "rows"?

How do you want to (re)order the rows?

Where do you want to store those "rows"?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 9
(9,893 Views)

Your understanding is correct!

 

Where do you read from?

Table column

How do you read the "rows"?

Based column1

How do you want to (re)order the rows?

based on input array framed

Where do you want to store those "rows"?

storing not required, need to read in text

 

Similar to question posted..

AB
Kudos are Accepted
0 Kudos
Message 5 of 9
(9,876 Views)
After reading the data from SQL Query you have 2d array.
-Instead of SQL Query, my suggestion would be to use array operations on the array to form the result into required format.
-Using Insert into Array and/or Index Array
Thanks
uday
0 Kudos
Message 6 of 9
(9,866 Views)

Like udka seems to be saying, I'd also suggest getting the simplest data into LabVIEW, and then doing more complicated operations natively in LabVIEW. Although you can write obscenely clever queries (perhaps - I can't!...) in SQL, in many cases LabVIEW is more able to handle what you need (and at least for me, often in a simpler to understand (and more importantly code) way).

 

I have found in the past I can read multiple orders of magnitude more data out of a database and decimate it in LabVIEW than try and concoct an indexing function within the database to decimate there in the same time.

 

Once you know the way in which you want to duplicate data, getting LabVIEW to do it (with Insert Into Array as udka suggests, or similar) should be simple.


GCentral
0 Kudos
Message 7 of 9
(9,863 Views)

All ready I have implemented by Indexing..

 

I would like to know any other solution is available.

AB
Kudos are Accepted
0 Kudos
Message 8 of 9
(9,844 Views)
Solution
Accepted by topic author AB@17

I have got solution by using where and IN keywords in combination

AB
Kudos are Accepted
0 Kudos
Message 9 of 9
(9,801 Views)