-
don't understand!!!
check it out:
SELECT DECODE(TO_CHAR(SYSDATE, 'D'), 2, 'SEG',
3, 'TER',
4, 'QUA',
5, 'QUI',
6, 'SEX',
7, 'SÁB')
from dual;
DEC
---
SEX
here is my table values:
SQL> SELECT ID, DIA FROM HORARIO WHERE DIA = 'SEX';
ID DIA
---------- ----
9 SEX
10 SEX
21 SEX
22 SEX
29 SEX
Now I ran this query but it returns no rows!!! Why does it happen? IDs for SEX value exists in DIA column.
SQL> select id from horario
2 where dia = DECODE(TO_CHAR(SYSDATE, 'D'), 2, 'SEG',
3 3, 'TER',
4 4, 'QUA',
5 5, 'QUI',
6 6, 'SEX',
7 7, 'SÁB');
no rows selected
Thanks in Advance
F.
-
Code:
SQL> select ename from emp
2 where substr(to_char(hiredate, 'DAY'),1,3) =
3 DECODE(TO_CHAR(SYSDATE, 'D'),
4 2, 'MON',
5 3, 'TUE',
6 4, 'WED',
7 5, 'THU',
8 6, 'FRI',
9 7, 'SAT')
10 /
ENAME
----------
ALLEN
BLAKE
-
Code:
SQL> create table horario (id number, dia varchar2(10));
Table created.
SQL> insert into horario values (9, 'SEX');
1 row created.
SQL> insert into horario values (10,'SEX');
1 row created.
SQL> select id from horario
2 where dia = DECODE(TO_CHAR(SYSDATE, 'D'),
3 2, 'SEG',
4 3, 'TER',
5 4, 'QUA',
6 5, 'QUI',
7 6, 'SEX',
8 7, 'SÁB');
ID
----------
9
10
-
that's the why my subject is "dont understand!!!". This query worked in my schema. I took a full export, I was moving to production .... and then I used scripts for creating database, it was exactly equal to development db. But with the new schema, that is completly the same as the development one, this query returns no rows. Dia column is char(4). It has nothing to do I believe because dia = 'SEX' , dia = 'SEX ' and dia = 'SEX ' are all the same thing, the query returns when I compare in where clause using string as above ... but ... from the decode function no rows. I cant understand that ... !!! CharacterSet is the same.
F.
-
Oh stecal, thanks. I discovered.
Well, char(4) really had something to do. I changed to char(3) and it worked. Ok, my script was not completely a clone from development
F.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|