Skip to Content (Press Enter)
OutSystems.com
Personal Edition
Community
Support
Training
Training
Online Training
Developer Schools
Boot Camps
Certifications
Tech Talks
Documentation
Documentation
Overview
ODC
O11
Forums
Forge
Get Involved
Get Involved
Jobs
Ideas
Members
Mentorship
User Groups
Platform
Platform
ODC
O11
Search in OutSystems
Log in
Get Started
Back to Forums
majieke
1
Views
7
Comments
Using variable for the name to get a value from an entity or a structure
Question
Hi,
we have a legacy database and there we have fieldnames like xxx001, xxx002, xxx003.... xxx030.
To get the value of the fields of the result from a query we have to get them one by one and append them to a list as name-value pairs, and do this 30 or more times.
As alternative I made a function with a variable for the name and an advanced query to get the value and then use the function in the loop, but then there are a lot of querys.
Is there an other way? Is it possible to get the value by using a variable from an entity or a structure?
best regards,
Majieke
João Rosado
Staff
Hi Majieke,
Can you post an example oml of what you trying to do?
I didn't understand why a normal query doesn't work.
Regards,
João Rosado
1 reply
27 Aug 2014
Show thread
Hide thread
majieke
João Rosado
wrote:
Hi Majieke,
Can you post an example oml of what you trying to do?
I didn't understand why a normal query doesn't work.
Regards,
João Rosado
A normal query works also, but we want from one record to loop through the fields. We want the value of 2nd till 30th element/column of this record. Column name is xxx_001 till xxx_030.
I have tried to make an example oml. The situation is provided in the action GetValues and the alternative GetValues2. I've only made 4 of the 30. Is there another way to get the name-value list?
Regards,
Majieke
ExampleLegacyDatabas.oml
Nuno Reis
Â
MVP
The laziest approach would be to do it once.
Do an Action (Function) that receives a Record and a String. Use a Switch to read what is the String and return the corresponding attribute.
That way, you can just call the function with a string and it will return the value.
You will need a Function for each Record type.
1 reply
27 Aug 2014
Show thread
Hide thread
majieke
Thanks for the reply.
We have more than one table with such construction and one with upto 90 fields, so I was looking for a more generic solution and not to have draw and assigning that many times the same elements .
majieke
Hi,
are there other solutions then drawing each item and that upto 90 times?
we have more legacy tables with the same constuction and we want to know what the options are with outsystems, if we have to draw every item separately, or iff there is a more generic solution for this case.
Nuno Reis
Â
MVP
Well, I created a few similar named columns for
this
test and felt sympathy for your situation.
A Advanced Query can return one column. If you use a Parameter with Expand Inline, you can send the column name in.
The string sent will be "{ReplaceWithTableName}.[
xxx_00
"+number+"]" (you will have to pad the 0's)
You have to create a Structure to contain the possible result, but nothing more.
Even your dinosaur table can be read like this.
majieke
Hi,
that is the same as I had in mine alternative in the example getvalues2, but the problem then is that there is 90 times a roundtrip to the database.
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
See the full guidelines
 Loading...