[Solved] CASEWHEN and OR
[Solved] CASEWHEN and OR
I have a table with fields ConvenorID1 and ConvenorID2. When either has a value, I wish to use a query to create a new field Both containing the word 'Convenor'. I have made a new field in the query with the statement:
CASEWHEN( "ConvenorID1", 'Convenor', '' ) which works fine as does CASEWHEN( "ConvenorID2", 'Convenor', '' ) . However, I have not been able to extend it to have both conditions at once, i.e. the logical condition 'ConvenorID1 or ConvenorID2'. Thus the statement:
CASEWHEN( "ConvenorID1" OR "ConvenorID2" ), 'Convenor', '' ) gives an error, as do all variants I have tried including OR("ConvenorID1";"ConvenorID2")
What is the correct syntax please?
Regards
Nocton
CASEWHEN( "ConvenorID1", 'Convenor', '' ) which works fine as does CASEWHEN( "ConvenorID2", 'Convenor', '' ) . However, I have not been able to extend it to have both conditions at once, i.e. the logical condition 'ConvenorID1 or ConvenorID2'. Thus the statement:
CASEWHEN( "ConvenorID1" OR "ConvenorID2" ), 'Convenor', '' ) gives an error, as do all variants I have tried including OR("ConvenorID1";"ConvenorID2")
What is the correct syntax please?
Regards
Nocton
Last edited by Nocton on Wed Jan 19, 2011 7:31 pm, edited 1 time in total.
OpenOffice 4.1.12 on Windows 10
Re: CASEWHEN and OR
Hello
You have a bug in the syntax
Romke
You have a bug in the syntax
I think use thisNocton wrote:CASEWHEN( "ConvenorID1" OR "ConvenorID2" ), 'Convenor', '' )
Code: Select all
CASEWHEN( "ConvenorID1" OR "ConvenorID2" , 'Convenor', '' )
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: CASEWHEN and OR
Sorry, that extra ) was a typo. Your version is the one I am using and it gives an error message:
"The column CASEWHEN( "ConvenorID1" OR "ConvenorID2" , 'Convenor', '' ) is unknown".
"The column CASEWHEN( "ConvenorID1" OR "ConvenorID2" , 'Convenor', '' ) is unknown".
OpenOffice 4.1.12 on Windows 10
Re: CASEWHEN and OR
Hello
I think you give to little information for an answer.
What is the complete SQL. And what are the column names in your table.
You spelled the column name wrong as far I know now.
Romke
I think you give to little information for an answer.
What is the complete SQL. And what are the column names in your table.
You spelled the column name wrong as far I know now.
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: CASEWHEN and OR
In fact I have solved my problem with the workaround:
CASEWHEN( CONCAT( "ConvenorID1", "ConvenorID2" ) > 0, 'Convenor', '' )
But I should still like to know why the OR statement does not work.
Regards,
Nocton
CASEWHEN( CONCAT( "ConvenorID1", "ConvenorID2" ) > 0, 'Convenor', '' )
But I should still like to know why the OR statement does not work.
Regards,
Nocton
OpenOffice 4.1.12 on Windows 10
Re: CASEWHEN and OR
The OR is not working because the language is SQL and not C or Javascript or perl or python, ...
In SQL you need two expressions that both return a boolean value (true, false, well or null) on both sides of the OR operator. ConvenorID1 and ConvenorID2 are probably string type if you concatenate them, so they return CHAR or VARCHAR, but not Boolean.
In SQL you need two expressions that both return a boolean value (true, false, well or null) on both sides of the OR operator. ConvenorID1 and ConvenorID2 are probably string type if you concatenate them, so they return CHAR or VARCHAR, but not Boolean.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
Re: CASEWHEN and OR
Code: Select all
CASEWHEN( (NOT "ConvenorID1" IS NULL) OR (NOT "ConvenorID2" IS NULL) , 'Convenor', '' ) AS "Some Alias"
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: CASEWHEN and OR
No, thank you, Villeroy. That does not work either. I already tried with IS NULL.
The fields are numerical/integers.
The fields are numerical/integers.
OpenOffice 4.1.12 on Windows 10
Re: CASEWHEN and OR
Indeed, it does not work with the Base interpreter. In direct mode it works as it should.
This is another variant that runs as documented in direct mode only (embedded HSQLDB 1.8):
All those little helpers in Base are broken beyond repair. At least they do not get it right after 6 years.
This is another variant that runs as documented in direct mode only (embedded HSQLDB 1.8):
Code: Select all
select *,case when (NOT X IS NULL)OR(NOT Y IS NULL) then 'Yes' else 'No' end AS "Blah" FROM "Table1"
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: CASEWHEN and OR
Thanks, again. It is good to know where the problem lies. I've marked it 'Solved'.
As I have got something that works, I'll stick with it. But it does make development frustrating!
As I have got something that works, I'll stick with it. But it does make development frustrating!
OpenOffice 4.1.12 on Windows 10
Re: [Solved] CASEWHEN and OR
Hello
I think when you switch to native mode then you can work with OR.
When you work in the query designer then there is a button with SQL. When you click on this button you switch of OOo-mode to native mode or back.
The SQL button only activ when you are not in the GUI but only in the text mode .
Romke
I think when you switch to native mode then you can work with OR.
When you work in the query designer then there is a button with SQL. When you click on this button you switch of OOo-mode to native mode or back.
The SQL button only activ when you are not in the GUI but only in the text mode .
Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Re: [Solved] CASEWHEN and OR
Direct SQL allows to file the request directly to the underlying database application (HSQLDB, MySQL, whatever). Base does not care about syntax nor features. The SQL may be very different from what the graphical SQL designer can interprete so it makes no sense to design these database specific SQL statements in graphical mode.RPG wrote:Hello
I think when you switch to native mode then you can work with OR.
When you work in the query designer then there is a button with SQL. When you click on this button you switch of OOo-mode to native mode or back.
The SQL button only activ when you are not in the GUI but only in the text mode .
Romke
This way we can circumvent many of Base's bugs and restrictions. Unfortunately we never get editable row sets from direct SQL. Even the most simple SELECT * FROM "Table" returns a read-only set from an editable table when run in direct mode.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice