|
| Query with condition "IS NULL" parametric |
| Iniciado por guest, 28,ene. 2016 17:13 - 5 respuestas |
| |
| | | |
|
| |
| Publicado el 28,enero 2016 - 17:13 |
Hi, I have in my hand a SELECT query created by the editor. Is there a way to add another "boolean-like" condition in which the result includes (or not) the records that have that certain field as NULL?
i.e. I have a table "students" with these records:
id |name |grade
1 |Alex |C 2 |John |NULL
and a simple query like this: SELECT id,grade FROM students
What I need is a way to have a SELECT query that, given the "boolean-like" condition passed as a parameter (let's say, in the HExecuteQuery() function), it will include the record "2|John|NULL" (or won't include, if the condition "IS NULL" is set to FALSE).
Ps. it is very important for me to do this in a single query, as this is one of the requirements that must be respected
Thanks, Dann |
| |
| |
| | | |
|
| | |
| |
| Publicado el 28,enero 2016 - 17:35 |
Hi Dann,
may be, you can add a statement CASE WHEN grade is null THEN 0 ELSE 1 END AS GradeEvaluated and add a WHERE GradeEvaluated = {paramGrade}
paramGrade can then be true, false or NULL
It is not tested! |
| |
| |
| | | |
|
| | |
| |
| Publicado el 28,enero 2016 - 21:16 |
Hi Dann,
in such cases I do not use the query editor, but hexecutesqlqeuery-
So I can build my SQL string by code.
Best Regards
Stefan. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 29,enero 2016 - 17:13 |
Quote Stefan Bentvelsen
Hi Dann,
may be, you can add a statement CASE WHEN grade is null THEN 0 ELSE 1 END AS GradeEvaluated
and add a WHERE GradeEvaluated = {paramGrade}
paramGrade can then be true, false or NULL
It is not tested!
depend on which version of WD you are using ,
QUE1.paramGrade = NULL
mean that this line " GradeEvaluated = {paramGrade}" will be skip .
i have a program that has query with alot conditions . set the param to NULL in windev to turn ON/OFF the condition.
it's very usefull |
| |
| |
| | | |
|
| | |
| |
| Publicado el 29,enero 2016 - 19:20 |
I think he wants to turn off an IS NULL condition. If it is a = {param} condition you can set param to NULL for turning off the condition. For is NULL condition you cant. Nor feasible in query editor.. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 30,enero 2016 - 01:35 |
| Simply use COALESCE(grade,0) and then look for 0 (or whatever value you decide to use in the COALESCE statement) |
| |
| |
| | | |
|
| | | | |
| | |
|