I jus wonder why TRIM and SUBSTR are not working on one Oracle9i database
server:
SQL*Plus: Release 9.2.0.1.0 - Production on Thu Feb 10 11:47:01 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
stat@STAT2> select TRIM('Hello ') o from dual;
O
---------------------------
Hello
You see that the string is not trimmed. I would expected (and actually it is
on a different box) the output like this:
O
-----
Hello
Same happen with SUBSTR, doesn't work. But why is this different? Are there
any default sql*plus settings that I'm not aware off?
--
Matthias Wirtz - Norfolk, usa
I cannot reproduce the problem..
--------------------------------------------------------------------------------------------------------------
SQL*Plus: Release 9.2.0.1.0 - Production on Thu Feb 10 11:08:07 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.2.1 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.2.0 - Production
SQL> select trim('Hello ') from dual;
TRIM(
-----
Hello
SQL> select substr('thislongstring',2,4) from dual;
SUBS
----
hisl
SQL>
-------------------------------------------------------------------------------------------------
No setting in SqlPlus have been modified..'out-of-the-box' client install.
HTH
Anurag
Both databases have the same character sets:
stat@STAT2> select * from v$nls_parameters where parameter LIKE
'NLS%_CHARACTERSET';
PARAMETER VALUE
-------------------------- -------------
NLS_CHARACTERSET WE8ISO8859P1
NLS_NCHAR_CHARACTERSET AL16UTF16
Look at the select you have used "trim(bla) o " (label!)
vs what others run "trim(bla)"
However when you try
> select trim(bla) a,length(trim(bla)) from blabla
you should get correct results. Just the presentation of the column
heading is incorrect.
HTH
Michael
ORA92> select trim('Hello ') from dual;
TRIM('HELLO')
--------------------------------
Hello
ORA92> show parameter cursor_sharing
NAME TYPE
VALUE
------------------------------------ --------------------------------
------------------------------
cursor_sharing string
SIMILAR
ORA92> alter session set cursor_sharing=exact;
Session altered.
ORA92> select trim('Hello ') from dual;
TRIM(
-----
Hello
Anurag
Anurag
don't be silly.
consider for 10 seconds , the impact of your statement.
.........
do you think that the whole of your oracle database internal code , does not
use " trim & substr" in any form.
Why is your database still running?
Why has it not crashed beyond a completely irreparable state?
SQL> select length('im a newbie who should not be let near a real database')
from dual;
LENGTH('IMANEWBIEWHOSHOULDNOTBELETNEARAREALDATABASE')
-----------------------------------------------------
54
SQL> select length('im a newbie who should not be let near a real database
') from dual;
LENGTH('IMANEWBIEWHOSHOULDNOTBELETNEARAREALDATABASE')
-----------------------------------------------------
65
select length(trim('im a newbie who should not be let near a real database
'))from dual;
LENGTH(TRIM('IMANEWBIEWHOSHOULDNOTBELETNEARAREALDATABASE'))
-----------------------------------------------------------
54
SQL> select 'stay away from '||substr('im a newbie who should not be let near
a real database',39) from dual;
'STAYAWAYFROM'||SUBSTR('IMANEWB
-------------------------------
stay away from a real database
As part of your training , see if you can manage to cut & paste the above sql
into your sqlplus program , as a test ( pls note, no need for scissors or
glue, but if you feel better you can use the plastic scissors)
steve
> How about cursor sharing?
Yes, that worked. I changed it to exact, like in your example and got the
expected output. Thx.