25
Views
4
Comments
Solved
SQL Query

Hello, 

I'm trying to list the data using sql query instead of aggregate but when I wrote this language filter to a query it gives me this error. What is wrong here?

Thanks

2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

Hi @Mohamed Ramadan ,

there is really no need to make it this complicated

All you need in the import of the SQL widget is 1 import parameter LanguageId (type is language identifier)

In the flow where you use that SQL widget, pass into the LanguageId following expression

If(GetCurrentLocale()="en-US", Entities.Language.En, Entities.Language.Ar)

then in your where clause, you can have the simple condition

WHERE {NewsDetails}.[LanguageId] = @LanguageId

Dorine


2022-08-03 04-32-50
Ravi Punjwani

Hi Mohamed Ramadan,

Can you share what is the error message? It is not visible in any of the screenshots you shared.

You can replace CASE WHEN ... END structure with the following:

WHERE (( @GetCurrentLocale = 'en-US' AND {NewsDetails}.[LanguageId] = @English ) OR 
    ( @GetCurrentLocale <> 'en-US' AND {NewsDetails}.[LanguageId] = @Arabic ))
AND {NewsDetails}.[IsDeleted] = 0

UserImage.jpg
Mohamed Ramadan

Hello Ravi,

2022-08-03 04-32-50
Ravi Punjwani

Did you try using the sql query without Case structure?

CASE structures can be used only when there's no other alternative. It seriously impacts the performance of queries.

A bit more about efficiency comparison among both
https://stackoverflow.com/questions/56689364/sql-case-when-vs-where-efficiency

2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

Hi @Mohamed Ramadan ,

there is really no need to make it this complicated

All you need in the import of the SQL widget is 1 import parameter LanguageId (type is language identifier)

In the flow where you use that SQL widget, pass into the LanguageId following expression

If(GetCurrentLocale()="en-US", Entities.Language.En, Entities.Language.Ar)

then in your where clause, you can have the simple condition

WHERE {NewsDetails}.[LanguageId] = @LanguageId

Dorine


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