Home » Other » Client Tools » Formatting a string (SQL Developer 1.5.3)
Formatting a string [message #384641] Wed, 04 February 2009 10:44 Go to next message
dheuschkel
Messages: 14
Registered: March 2007
Junior Member
Hello!

I would like to know how to format a string for the script output.

When I enter the following statement:

SELECT LPAD(' ', 3 * LEVEL - 1) || e.ename AS Name, level, e.mgr
FROM emp e
CONNECT BY PRIOR e.empno = e.mgr
START WITH e.mgr IS NULL;

unfortunately the script output generates a extremly big column for the alias Name
The well known column command is not supported. So what can I do to get a string at the length of 30 characters?

Thank you in advance for your answer!

Dagmar
Re: Formatting a string [message #384643 is a reply to message #384641] Wed, 04 February 2009 11:02 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Try to use CAST.

Regards
Michel
Re: Formatting a string [message #384797 is a reply to message #384641] Thu, 05 February 2009 04:12 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Any function where oracle can determine the length of the output string should do it.
For example, if you wrap the Name column in an RPAD like this:
SELECT RPAD(LPAD(' ', 3 * LEVEL - 1) || e.ename,30) AS Name, level, e.mgr 
 FROM emp e
 CONNECT BY PRIOR e.empno = e.mgr 
 START WITH e.mgr IS NULL;
Then Oracle can tell that the column has a width of 30 , and this information will be passed back to whatever client is displaying the data.
Previous Topic: Importing Table using Pl/Sql Developer (merged)
Next Topic: Navigator problem for stored procedure
Goto Forum:
  


Current Time: Fri Mar 29 05:51:57 CDT 2024