------_=_NextPart_001_01C3655F.E5DC1490
Content-Type: text/plain; charset="iso-8859-1"

Nice as far as it goes, Jared - let us know when you can generate a complete
ER diagram from SQL*Plus... !
 
 
peter
edinburgh
 

-----Original Message-----
Sent: Saturday, August 16, 2003 2:04 AM
To: Multiple recipients of list ORACLE-L



I was playing around with org charts yesterday, and came up with a function 
to use for drawing org charts with lines from sqlplus. 

This has probably been done before, but I couldn't seem to find one via
google. 

The output from scott.emp looks like: 

select 
   org_chart_line(level-1,3) || ename 
from emp e 
start with e.job = 'PRESIDENT' 
connect by prior e.empno = e.mgr 
/ 

----------------------------------------------------------------------------
---- 
KING 
|___JONES 
|        |___SCOTT 
|        |        |___ADAMS 
|        |___FORD 
|        |        |___SMITH 
|___BLAKE 
|        |___ALLEN 
|        |___WARD 
|        |___MARTIN 
|        |___TURNER 
|        |___JAMES 
|___CLARK 
|        |___MILLER 

14 rows selected. 

The problem with working alone (in the Oracle sense ) is there's never
anyone 
in the next cube over to show stuff to. 

Jared 

=============================================== 

create or replace function org_chart_line ( 
        level_in integer 
        , indent_level_in integer 
) 
return varchar2 
is 

        org_line varchar2(100); 

        space_string varchar2(20) := '                    '; 
        char_string varchar2(20) := '____________________'; 

begin 

        if level_in = 0 then 
                return ''; 
        end if; 

        for i in 1 .. ((level_in -1) * indent_level_in ) 
        loop 
                if mod(i,indent_level_in) = 0 then 
                        org_line := org_line ||
substr(space_string,1,indent_level_in -1) || '|'; 
                else 
                        org_line := org_line ||
substr(space_string,1,indent_level_in ) ; 
                end if; 
        end loop; 

        org_line := org_line ||  substr(char_string,1,indent_level_in  ); 

        org_line := '|' || substr(org_line,1); 

        return org_line; 

end; 
/ 

show error function oc 





*********************************************************************
This  e-mail  message,  and  any  files  transmitted  with  it, are
confidential  and intended  solely for the  use of the  addressee. If
this message was not addressed to  you, you have received it in error
and any  copying,  distribution  or  other use  of any part  of it is
strictly prohibited. Any views or opinions presented are solely those
of the sender and do not necessarily represent  those of the British
Geological  Survey. The  security of e-mail  communication  cannot be
guaranteed and the BGS accepts no liability  for claims arising as a
result of the use of this medium to  transmit messages from or to the
BGS. .                            http://www.bgs.ac.uk
*********************************************************************


------_=_NextPart_001_01C3655F.E5DC1490
Content-Type: text/html; charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=709290708-18082003><FONT face=Arial color=#0000ff size=2>Nice 
as far as it goes, Jared - let us know when you can generate a complete ER 
diagram from SQL*Plus... !</FONT></SPAN></DIV>
<DIV><SPAN class=709290708-18082003><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=709290708-18082003></SPAN>&nbsp;</DIV>
<DIV><SPAN class=709290708-18082003><FONT face=Arial color=#0000ff 
size=2>peter</FONT></SPAN></DIV>
<DIV><SPAN class=709290708-18082003><FONT face=Arial color=#0000ff 
size=2>edinburgh</FONT></SPAN></DIV>
<DIV><SPAN class=709290708-18082003><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<BLOCKQUOTE>
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]<BR><B>Sent:</B> Saturday, August 16, 2003 
  2:04 AM<BR><B>To:</B> Multiple recipients of list ORACLE-L<BR><B>Subject:</B> 
  Org charts<BR><BR></FONT></DIV><BR><FONT face=sans-serif size=2>I was playing 
  around with org charts yesterday, and came up with a function</FONT> <BR><FONT 
  face=sans-serif size=2>to use for drawing org charts with lines from 
  sqlplus.</FONT> <BR><BR><FONT face=sans-serif size=2>This has probably been 
  done before, but I couldn't seem to find one via google.</FONT> <BR><BR><FONT 
  face=sans-serif size=2>The output from scott.emp looks like:</FONT> 
  <BR><BR><FONT face=sans-serif size=2>select</FONT> <BR><FONT face=sans-serif 
  size=2>&nbsp; &nbsp;org_chart_line(level-1,3) || ename</FONT> <BR><FONT 
  face=sans-serif size=2>from emp e</FONT> <BR><FONT face=sans-serif 
  size=2>start with e.job = 'PRESIDENT'</FONT> <BR><FONT face=sans-serif 
  size=2>connect by prior e.empno = e.mgr</FONT> <BR><FONT face=sans-serif 
  size=2>/</FONT> <BR><BR><FONT face=sans-serif 
  
size=2>--------------------------------------------------------------------------------</FONT>
 
  <BR><FONT face=sans-serif size=2>KING</FONT> <BR><FONT face=sans-serif 
  size=2>|___JONES</FONT> <BR><FONT face=sans-serif size=2>| &nbsp; &nbsp; 
  &nbsp; &nbsp;|___SCOTT</FONT> <BR><FONT face=sans-serif size=2>| &nbsp; &nbsp; 
  &nbsp; &nbsp;| &nbsp; &nbsp; &nbsp; &nbsp;|___ADAMS</FONT> <BR><FONT 
  face=sans-serif size=2>| &nbsp; &nbsp; &nbsp; &nbsp;|___FORD</FONT> <BR><FONT 
  face=sans-serif size=2>| &nbsp; &nbsp; &nbsp; &nbsp;| &nbsp; &nbsp; &nbsp; 
  &nbsp;|___SMITH</FONT> <BR><FONT face=sans-serif size=2>|___BLAKE</FONT> 
  <BR><FONT face=sans-serif size=2>| &nbsp; &nbsp; &nbsp; &nbsp;|___ALLEN</FONT> 
  <BR><FONT face=sans-serif size=2>| &nbsp; &nbsp; &nbsp; &nbsp;|___WARD</FONT> 
  <BR><FONT face=sans-serif size=2>| &nbsp; &nbsp; &nbsp; 
  &nbsp;|___MARTIN</FONT> <BR><FONT face=sans-serif size=2>| &nbsp; &nbsp; 
  &nbsp; &nbsp;|___TURNER</FONT> <BR><FONT face=sans-serif size=2>| &nbsp; 
  &nbsp; &nbsp; &nbsp;|___JAMES</FONT> <BR><FONT face=sans-serif 
  size=2>|___CLARK</FONT> <BR><FONT face=sans-serif size=2>| &nbsp; &nbsp; 
  &nbsp; &nbsp;|___MILLER</FONT> <BR><BR><FONT face=sans-serif size=2>14 rows 
  selected.</FONT> <BR><BR><FONT face=sans-serif size=2>The problem with working 
  alone (in the Oracle sense ) is there's never anyone</FONT> <BR><FONT 
  face=sans-serif size=2>in the next cube over to show stuff to.</FONT> 
  <BR><BR><FONT face=sans-serif size=2>Jared</FONT> <BR><BR><FONT 
  face=sans-serif size=2>===============================================</FONT> 
  <BR><BR><FONT face=sans-serif size=2>create or replace function org_chart_line 
  (</FONT> <BR><FONT face=sans-serif size=2>&nbsp; &nbsp; &nbsp; &nbsp; level_in 
  integer</FONT> <BR><FONT face=sans-serif size=2>&nbsp; &nbsp; &nbsp; &nbsp; , 
  indent_level_in integer</FONT> <BR><FONT face=sans-serif size=2>)</FONT> 
  <BR><FONT face=sans-serif size=2>return varchar2</FONT> <BR><FONT 
  face=sans-serif size=2>is</FONT> <BR><BR><FONT face=sans-serif size=2>&nbsp; 
  &nbsp; &nbsp; &nbsp; org_line varchar2(100);</FONT> <BR><BR><FONT 
  face=sans-serif size=2>&nbsp; &nbsp; &nbsp; &nbsp; space_string varchar2(20) 
  := ' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  &nbsp;';</FONT> <BR><FONT face=sans-serif size=2>&nbsp; &nbsp; &nbsp; &nbsp; 
  char_string varchar2(20) := '____________________';</FONT> <BR><BR><FONT 
  face=sans-serif size=2>begin</FONT> <BR><BR><FONT face=sans-serif 
  size=2>&nbsp; &nbsp; &nbsp; &nbsp; if level_in = 0 then</FONT> <BR><FONT 
  face=sans-serif size=2>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  return '';</FONT> <BR><FONT face=sans-serif size=2>&nbsp; &nbsp; &nbsp; &nbsp; 
  end if;</FONT> <BR><BR><FONT face=sans-serif size=2>&nbsp; &nbsp; &nbsp; 
  &nbsp; for i in 1 .. ((level_in -1) * indent_level_in )</FONT> <BR><FONT 
  face=sans-serif size=2>&nbsp; &nbsp; &nbsp; &nbsp; loop</FONT> <BR><FONT 
  face=sans-serif size=2>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  if mod(i,indent_level_in) = 0 then</FONT> <BR><FONT face=sans-serif 
  size=2>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  &nbsp; &nbsp; org_line := org_line || substr(space_string,1,indent_level_in 
  -1) || '|';</FONT> <BR><FONT face=sans-serif size=2>&nbsp; &nbsp; &nbsp; 
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else</FONT> <BR><FONT face=sans-serif 
  size=2>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  &nbsp; &nbsp; org_line := org_line || substr(space_string,1,indent_level_in ) 
  ;</FONT> <BR><FONT face=sans-serif size=2>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  &nbsp; &nbsp; &nbsp; end if;</FONT> <BR><FONT face=sans-serif size=2>&nbsp; 
  &nbsp; &nbsp; &nbsp; end loop;</FONT> <BR><BR><FONT face=sans-serif 
  size=2>&nbsp; &nbsp; &nbsp; &nbsp; org_line := org_line || 
  &nbsp;substr(char_string,1,indent_level_in &nbsp;);</FONT> <BR><BR><FONT 
  face=sans-serif size=2>&nbsp; &nbsp; &nbsp; &nbsp; org_line := '|' || 
  substr(org_line,1);</FONT> <BR><BR><FONT face=sans-serif size=2>&nbsp; &nbsp; 
  &nbsp; &nbsp; return org_line;</FONT> <BR><BR><FONT face=sans-serif 
  size=2>end;</FONT> <BR><FONT face=sans-serif size=2>/</FONT> <BR><BR><FONT 
  face=sans-serif size=2>show error function oc</FONT> 
<BR><BR></BLOCKQUOTE><FONT SIZE=3><BR>
<BR>
*********************************************************************<BR>
This  e-mail  message,  and  any  files  transmitted  with  it, are<BR>
confidential  and intended  solely for the  use of the  addressee. If<BR>
this message was not addressed to  you, you have received it in error<BR>
and any  copying,  distribution  or  other use  of any part  of it is<BR>
strictly prohibited. Any views or opinions presented are solely those<BR>
of the sender and do not necessarily represent  those of the British<BR>
Geological  Survey. The  security of e-mail  communication  cannot be<BR>
guaranteed and the BGS accepts no liability  for claims arising as a<BR>
result of the use of this medium to  transmit messages from or to the<BR>
BGS. .                            http://www.bgs.ac.uk<BR>
*********************************************************************<BR>
</FONT>
</BODY></HTML>

------_=_NextPart_001_01C3655F.E5DC1490--
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Robson, Peter
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to