asdasda asdasda
asdasda asdasda

Reputation: 53

Hybris flexible query is not working for Customer type

I run below query through https://localhost:9002/console/flexsearch#

When I run below query there is no error

SELECT   
           *
            FROM { Customer  AS p} 
            where p_name IS NOT NULL

But, when I run this, it's giving me an error.

SELECT *
            FROM { Customer  AS p} 

            where {p_name} =' zohan'

Upvotes: 0

Views: 7937

Answers (2)

HybrisHelp
HybrisHelp

Reputation: 5810

Confused between flexible and SQL query?

Hybris use flexible query syntax where you can simply use TypeCode (Customer) and their attribute(name) to make the query. Hybris internally convert your query to the respective database syntax. In DB each column name is prefixed with p_. So if you want to directly use SQL query you should use p_name otherwise with flexible search use model attributes name (name in your case)

Flexible search syntax

SELECT * FROM {Customer} WHERE {name} IS NOT NULL

Or

SELECT * FROM {Customer  AS c} WHERE {c.name} IS NOT NULL

SQL query

you can run from HAC > console > FlexibleSearch > SQL query

SELECT * FROM users WHERE p_name is not null

Refer FlexibleSearch Samples and other Tips and Tricks

Upvotes: 1

Johannes von Zmuda
Johannes von Zmuda

Reputation: 1822

When you use Flexible Search, you need to refer to attributes and types by their code. Hybris translates this query then to an sql query. So in your case:

SELECT * FROM {Customer  AS p} WHERE {p.name} IS NOT NULL

Upvotes: 0

Related Questions