DEFAULT_WHERE Decode statement [message #302686] |
Tue, 26 February 2008 10:58 |
GHott
Messages: 8 Registered: August 2007
|
Junior Member |
|
|
Are you able to use DECODE or CASE statements within a DEFAULT_WHERE on a block?
I've tried a few variations and it doesn't seem to like what I'm doing.
If DECODE and CASE statements can not be used, is their an equivalent substitution available?
|
|
|
|
Re: DEFAULT_WHERE Decode statement [message #303015 is a reply to message #302686] |
Wed, 27 February 2008 10:38 |
GHott
Messages: 8 Registered: August 2007
|
Junior Member |
|
|
Yes, it will execute successfully within SQL+ when setup for a short dummy run.
However, when I try to execute a:
SET_BLOCK_PROPERTY(BLOCK,DEFAULT_WHERE,'DECODE(IF PARAMETER, IS THIS, THEN DO THIS, ELSE DO THIS)');
It gives me two unable to perform query and two missing right parenthesis errors.
The two DO THIS areas of the decodes are within single quotes, and they are performing long SQL commands...several SELECT THIS MINUS SELECT THIS WHERE....etc. Those queries work perfectly within the DEFAULT_WHERE block without the DECODE statement.
|
|
|
Re: DEFAULT_WHERE Decode statement [message #303150 is a reply to message #302686] |
Thu, 28 February 2008 03:07 |
Flash
Messages: 34 Registered: February 2008
|
Member |
|
|
Decode will work in a default where.
Dude, you have tried wrong options. Please understand the usage of DECODE.
DECODE ( col_name, if_this, then_this, else_this ) is fine for a select.
But when you are using it in a where clause you need to give
DECODE ( col_name, if_this, then_this, else_this ) = This_value
Consider emp table from Scott
My query goes like this
SELECT empno, ename, job, mgr, sal, comm, deptno FROM emp WHERE DECODE(JOB,'SALESMAN','A') = 'A'
And my default_where would look like this.
DECODE(JOB,'SALESMAN','A') = 'A'
This will display all Salesmen when you query the form !!
Please find the attached file.
|
|
|
|