Formatting a string [message #384641] |
Wed, 04 February 2009 10:44 |
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 #384797 is a reply to message #384641] |
Thu, 05 February 2009 04:12 |
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.
|
|
|