SQL Plus Format [message #684884] |
Tue, 21 September 2021 11:02  |
wtolentino
Messages: 373 Registered: March 2005
|
Senior Member |
|
|
i have this line of code on a script:
set linesize 90;
select substr(user,1,15) user_name,
substr(sys_context('userenv','db_name'),1,15) database_name
from dual;
it works fine only the formatting is somewhat not right. when run on this one database format is not correct this was the result:
USER_NAME
------------------------------------------------------------
DATABASE_NAME
------------------------------------------------------------
TUSERSRV
DBUESC
when run on the other database the formatting was correct:
USER_NAME DATABASE_NAME
--------------- ---------------
PUSERSRV PBUESC
i am using SQL*Plus: Release 19.0.0.0.0 Version 19.3.0.0.0.
[Updated on: Tue, 21 September 2021 11:40] Report message to a moderator
|
|
|
|
|
|
Re: SQL Plus Format [message #684890 is a reply to message #684887] |
Wed, 22 September 2021 00:46  |
 |
Michel Cadot
Messages: 68453 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
In this case, the difference is more likely in the Oracle environment parameters.
For instance, changing "cursor_sharing" parameter can change the way SQL*Plus sees and shows the result:
SQL> select substr(user,1,15) user_name,
2 substr(sys_context('userenv','db_name'),1,15) database_name
3 from dual;
USER_NAME DATABASE_NAME
--------------- ---------------
MICHEL MIKB2
1 row selected.
SQL> alter session set cursor_sharing=force;
Session altered.
SQL> select /* force parsing */ substr(user,1,15) user_name,
2 substr(sys_context('userenv','db_name'),1,15) database_name
3 from dual;
USER_NAME
------------------------------
DATABASE_NAME
---------------------------------------------------------------------------------------------------
MICHEL
MIKB2
1 row selected.
|
|
|