Since the SQL 2005 effort is a mere thought-bubble for now, I got something here about oracle.
Yesterday, I was approaced by a developer with a rather odd problem that they are having. One of their vb codes started spitting out errors because of a column header in a result set of a query not being displayed properly. Here's my attempt to demonstrate the reported problem.
A part of their codes looks like this:
SELECT DISTINCT SUBSTR(SS.LONG_COLUMN_NAME, 1, 4) FROM
SOME_VIEW SS
Now, the result of this query should look something like this:
SUBSTR(SS.LONG_COLUMN_NAME, 1, 4)
--------------------------------
VALUE1
VALUE2
VALUE3
They told me it has been like this every since. It looks like the name of the column (don't ask me why they are not using alias), is being used in other part of the program. But yesterday, they found out that the result given by the query above started to look like this:
SUBSTR(SS.LONG_COLUMN_NAME, 1,
------------------------------
VALUE1
VALUE2
VALUE3
I was told that there were no changes done on the code since 2006. I checked objects involved and the last DDL change done was 2006 as well. The last oracle patch applied on the database was Oct 2007 and the error started happening Nov 18 2007 at 2pm.
Here's something. The database was bounced on Nov 18 2007 12am to increase SGA of the database. Related? Doesn't look like it! The size of SGA has for sure nothing to do with how Oracle displays result set. But this is just too coincidental. So I poked around some more. I posted questions on OraFAQ forum (believe me, this site is just very nice) and alas, I started to see light.
The behavior described above could be affected by database server, client version and the database parameter cursor_sharing. Database server version wasn't changed. Client version upgrade was done on one server but the behavior is shown on any client on any machine so, I thought this couldn't be it. Lastly, the db paramenter... CURSOR_SHARING. By the sound of it, it doesn't look like connected to how oracle would display headers on result sets... but I am running out of suspects..... everyone has been acquited... I only got CURSOR_SHARING left to be placed under a light bulb. I did some tests...
SQL> alter session set cursor_sharing=force;
--------------------------------------------------------------------------------
XXXXXXXXXXXXXXXXXXXXXXXXX1234567890
SQL> select substr(rpad(dummy,35,dummy),1,25)||'1234567890' from dual;
SUBSTR(RPAD(DUMMY,35,DUMMY),1,
--------------------------------------------------------------------------------
XXXXXXXXXXXXXXXXXXXXXXXXX1234567890
--------------------------------------------------------------------------------
XXXXXXXXXXXXXXXXXXXXXXXXX1234567890
Holy Molly! Just look at the last statements. The column header was not truncated when cursor_sharing is set to exact... mmmm-hhhmmm that's right. That's gotta be it. Later within the day, I found out from one of the other dbas that the value of this parameter was changed from FORCE to EXACT by another dba without us knowing or fully aware of. The same time when the database bounce was done. So we finally pinned down the culprit and placed behind bars. Case closed.
Next time, I'd try to explain more on CURSOR_SHARING. This is an interesting and tricky parameter. Be cautious. That's all I can say for now.
Ciao!
