24
Views
4
Comments
Solved
How to Retrieve Single Row Data Using Where condition

Hello,

       How to fetch single row data using where condition.

i am create one table Product. fields are show below:

id |  product no | description

1 |         20        |   Product 1

2 |        25         |  Product 2


How can I am fetch product description using product no?

mvp_badge
MVP
Rank: #18
Solution

Hi Swapnil,

This is a very basic question that should be covered if you have followed some of the trainings on:
outsystems.com/learn.

Here is a list of documentation regarding fetching data:
https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Query_Data

To answer your question:
You normally add an aggregate to your preperation (traditional web) or screen (mobile/reactive app), and set a filter in your case On Product number.Like in the example screen shot below, just replace Id with ProductNumber

Regards,

Daniel

Rank: #270

Swapnil Kadam wrote:

Hello,

       How to fetch single row data using where condition.

i am create one table Product. fields are show below:

id |  product no | description

1 |         20        |   Product 1

2 |        25         |  Product 2


How can I am fetch product description using product no?

 Hi,

yes you can refer Daniel documentation from the above reply.

Also, for your requirement try like this:

select description from Product where id='1'(input data)


 

mvp_badge
MVP
Rank: #19

Hi Swapnil Kadam,

Like Daniel mentions this is the kind of fundamental knowledge that is covered on any of the initial OutSystems trainings... If you haven't yet, you should go through one of them (Reactive Web, Mobile, Traditional Web) before going deeper into development.

Regarding your particular question, if you want to obtain a Product using its Product no. you'd create an Aggregate, drag your Product entity to it and add the following Filter:

Product.ProductNo = ProductNumber 

Where ProductNumber is some variable that holds the product number you are interested in. If you are using the Product number to search for a specific record, you would need to make sure that attribute is unique (by using a unique index) otherwise you might get multiple records.

Hope this helps!

Swapnil Kadam wrote:

Hello,

       How to fetch single row data using where condition.

i am create one table Product. fields are show below:

id |  product no | description

1 |         20        |   Product 1

2 |        25         |  Product 2


How can I am fetch product description using product no?

 Hello Swapnil,


There are multiple ways to achieve it and depends on where do you want to filter the data. Three most popular widgets are :

1. Expression    2. Aggregate     3. Advance Sql 

Now come to second part i.e. where you want to filter the data. If you will use Aggregate or Advance SQL widget then your data will be filtered on source level and your table will have only filtered data. 

Eg: 

Aggregate - 

For your case filter will be : Product.ProductNo = 20 (in Aggregate)

Advance SQL Query : Select {Product}.[ProductDescription] from {product} where {Product}.[ProductNo] = 20

If you use expression then you can fetch all the data in table and in expression you can filter out as you desire.

Eg : 

Product.ProductNo = 20 


Hope it helps!


Regards,

Sanjay