That's it!
Duke Ganote, February 07, 2008 - 1:00 pm UTC
Thanks! You've got a sharp memory!
February 07, 2008 - 1:38 pm UTC
hah, I just did a seminar where I talk about function based indexes and the purity requirement and this is an example I use in it :)
Exactly!
Duke Ganote, February 07, 2008 - 2:18 pm UTC
As I was racking my brains, I was thinking... "here's a stump-the-candidate interview question! (And I'm failing myself)"
Pure as the driven slush.
Gary, February 07, 2008 - 11:21 pm UTC
Being picky but, even though to_date(yyyy||'01','fxYYYYMM')) is accepted by Oracle as 'pure', it actually isn't if you change nls_calendar. Because it isn't pure, you can get a different answer between a query using the index and one that doesn't.
>drop table t;
Table dropped.
>create table t ( yyyy number(4) not null, text_date varchar2(30) );
Table created.
>create index t_idx on t(to_date(yyyy||'01','fxYYYYMM'));
Index created.
>insert into t (yyyy, text_date) values (2008, to_char(sysdate,'MM YYYY') );
1 row created.
>alter session set NLS_CALENDAR="Arabic Hijrah" ;
Session altered.
>select count(*) from t
2 where to_date(yyyy||'01','fxYYYYMM') = date '2008-01-01';
COUNT(*)
--------
1
>select /*+FULL(t) */ count(*) from t
2 where to_date(yyyy||'01','fxYYYYMM') = date '2008-01-01';
COUNT(*)
--------
0
February 08, 2008 - 7:28 am UTC
interesting, thats a bug.
please explain
USKasturi, February 11, 2008 - 3:35 am UTC
Tom
I am really sorry to sak this
I dont understand the Question above and waht exactly is being done
Please explain
RE: please explain
Duke Ganote, February 11, 2008 - 9:20 am UTC
Here's an example:
SQL> alter session set nls_date_format= 'YYYY MONTH DD';
Session altered.
SQL> select sysdate TODAY, to_date('2008','YYYY') "1st_OF_YR?" from dual;
TODAY 1st_OF_YR?
----------------- -----------------
2008 FEBRUARY 11 2008 <b>FEBRUARY</b> 01 -- <b>NOT january!</b>