I have some questions about the database

How do you write if judgment in outsystems SQL? Can you use dynamic SQL?

Hi chen yabin,

Where you wants to use it in web or mobile?if it is web then

hope this will help you...

regards,

Amreen

Amreen Shaikh wrote:

Hi chen yabin,

Where you wants to use it in web or mobile?

I use it on WEP

My SQL needs to add an IF condition



Amreen Shaikh wrote:

Hi chen yabin,

Where you wants to use it in web or mobile?if it is web then

hope this will help you...

regards,

Amreen

.


Amreen Shaikh wrote:

Amreen Shaikh wrote:

Hi chen yabin,

Where you wants to use it in web or mobile?if it is web then

hope this will help you...

regards,

Amreen

.


Thank you, but I would like to ask is this tool able to directly write IF conditions?




Similarly, you can also use the If() in Advance SQL Query (in server action) without any changes in core sql syntax.

Hope it helps.

Hello Chen,

There is no "OutSystems SQL". An SQL Tool executes Standard SQL statements.
You need to know which database you are using to know what you are able to do.

Said that I must ask: are you MIXING HTML and SQL? Because this will simply not work in the SQL tool...

What are you trying to achieve?

Cheers.

Eduardo Jauch wrote:

Hello Chen,

There is no "OutSystems SQL". An SQL Tool executes Standard SQL statements.
You need to know which database you are using to know what you are able to do.

Said that I must ask: are you MIXING HTML and SQL? Because this will simply not work in the SQL tool...

What are you trying to achieve?

Cheers.

thank you

Using "Outsystems" SQL tools to write SQL statements, SQL statements can add "IF"?That's what I want to ask

Hello Chen,

Don't get me wrong, but your question is not making sense, and that is the reason why a simple answer "yes/no" for your question is not possible. 

What are you trying to do? 

I ask this because the code you are showing is NOT SQL at all (not STANDARD SQL at least). It seems to be mixed with something that resembles HTML (while there is NO <WHERE> tag in HTML, afaik, nor <IF>).

The SQL Tool is used to execute a query in the database, that will perform one of the four operations: SELECT data, INSERT rows, UPDATE rows or DELETE rows. Just that. The result of an SQL Tool will always be a LIST with the output structure defined in the Output folder of the SQL tool. Nothing more.

You can use the CASE statement to simulate an IF, inside a query, and you can use an IF statement from Transact-SQL if you are using SQL Server, but not inside a query (in the WHERE clause).  But if your database is Oracle or MySQL, for example, this will not work.

So, why are you trying to run, in an SQL Tool, something that is not a QUERY? 

Cheers.

Hi Chen,

It looks like you have some kind of XML query definition language? This is definitely non-standard, but to create queries in a similar fashion using OutSystems, you can pass pieces of SQL to an advanced query, setting the only parameter to "expand inline". However, I wouldn't do this unless it's a last resort measure, as it creates messy, difficult to understand and maintain code. It's certainly not something you want to do on a regular basis.