I want to dynamically specify conditions in the WHERE clause of Database Connector

0
Hi! Is it possible to dynamically specify conditions in the WHERE clause of the Database Connector? As an image, it points to Mybatis of Java Spring Framework.     ★Reference:Mybatis
asked
3 answers
2

Hi Satoshi,

 

You can dynamically built the query before you execute the database connector. So you create a string variable (Call it StringVariable or whatever you want). And initially fill that with 

'SELECT * FROM M_USER'

Then you can do a check if the input field is empty. If not you can change the variable with:

$StringVariable + ' WHERE USER_CD = ' + $Entity/AttributeName

 

Then in the Database connector you can fill the variable $StringVariable in the sql property.

 

If the input field is filled, it will use the WHERE Statement, if it is empty, it will select everything.

answered
1

Hi Satoshi,
If I understand your question correctly, you are looking for Parameterized Query 

If not, Can you please elaborate your use-case ?  

answered
0

Hi Surabhi Saraf.

Thank you for answering the question.

What I want to achieve is to dynamically add a conditional statement in the Where clause.

 

●Case.1

If there is no input in the search conditions, I want to search all items.

The SQL to be executed is as follows. Search all records without specifying WHERE clause.

SELECT * FROM M_USER


 

●Case 2.

 

If there is an input in the search condition, specify the condition in the WHERE clause.

The SQL to be executed is as follows. Specify User Code as a search condition.
 

SELECT * FROM M_USER WHERE USER_CD = '0000000001';

 

I want to realize the above with Database Connector. If you know how to do it, please answer.

answered