<html><link rel="SHORTCUT ICON" href="favicon.ico"><body background='textblue.jpg'><head><title> Atenae - Catalog Explorer for DB2</title></head>

<div align="left"><img src="atp.gif" width="120" height="120"></div><div align="center"><a href='index.html'> Principal  </a>
&nbsp&nbsp
<a href='lista_db.php'> DBs  </a>
&nbsp&nbsp
<a href='stmtr3.php?sql=select *                                                       from sysibm.sysdummy1&q=10&dbasef=DSNDB06&dban=DSNDB06&tban=SYSDUMMY1&tabela=SYSDUMMY1&criador=SYSIBM&cran=SYSIBM'> Query  </a></div>
&nbsp&nbsp
</div>



<?php

include 'liga.php';


if ($dbconn != 0) {

   $db=$_GET['db'];
   $or=$_GET['or'];

   $stmt = "SELECT CREATOR, NAME, COLCOUNT, QT, QP, QK
              from sysibm.systables
              left join (select dcreator, dname, count(*) as QT from sysibm.sysviewdep group by dcreator, dname) as V
              on name=v.dname and creator=v.dcreator
              left join (select bcreator, bname, count(*) as QP from sysibm.sysplandep group by bcreator, bname) as P
              on name=p.bname and creator=p.bcreator
              left join (select bqualifier, bname, count(*) as QK from sysibm.syspackdep group by bqualifier, bname) as K
              on name=k.bname and creator=k.bqualifier
              where type='V' and dbname='$db'
              order by $or" ;

   $result = odbc_exec($dbconn, $stmt);

   if ($result == 0) {

      $sqlerror = odbc_errormsg($dbconn);
      echo $sqlerror ; }

   else {

      echo "<table width='85%' border='0' align='center'>
            <caption>
            <h1> Views do DB: $db </h1>
            <h2> ordenado por:
            <form name='fo'>
			<input type=text   name='or' align='left' size=7   value='$or' >
			<input type=hidden name='db' align='left' size=15  value=$db >
			<input type=submit value='ordena'>
			</form></h2>

            <br>
            </caption>
            <tr>
        	     <th onclick=alert('criador_da_view') bgcolor='#FFFF9F' scope='col'> Criador (1) </th>
        	     <th onclick=alert('nome_da_view') bgcolor='#FFFF9F' scope='col'> Nome (2)</th>
        	     <th onclick=alert('quantidade_de_colunas') bgcolor='#FFFF9F' scope='col'> Qtd. colunas (3)</th>
        	     <th onclick=alert('tabelas_usadas_pela_view') bgcolor='#FFFF9F' scope='col'> Tabelas (4)</th>
        	     <th onclick=alert('planos_que_usam_a_view') bgcolor='#FFFF9F' scope='col'> Planos (5)</th>
        	     <th onclick=alert('packages_que_usam_a_view') bgcolor='#FFFF9F' scope='col'> Packages (6)</th>
        	     <th onclick=alert('nmero_de_sequncia_na_pgina') bgcolor='#FFFF9F' scope='col'> seq </th>
        	</tr>" ;

      $n=1;
      $icr=" ";
      $its=" ";
      $pgs=0;
      $mb=0;

      while ($row = odbc_fetch_array($result)) {

        echo "<tr onmouseover=style.backgroundColor='#e7e7e7' onmouseout=style.backgroundColor=''>";

        if ($row['CREATOR'] != $icr)
          echo "<th  align='left' scope='col'> $row[CREATOR] </th>" ;
        else
          echo "<th  align='left' scope='col'> </th>" ;

        echo "
          <th  align='left' scope='col'><a href='lista_views_3i.php?xr=$row[CREATOR]&vi=$row[NAME]'> $row[NAME] </th>
          <th  align='center' scope='col'><a href='lista_co_2i.php?cr=$row[CREATOR]&tb=$row[NAME]'> $row[COLCOUNT] </th>
          <th  align='center' scope='col'><a href='lista_tbs_2i.php?cr=$row[CREATOR]&tb=$row[NAME]'> $row[QT] </th>
          <th  align='center' scope='col'><a href='lista_plandep_2i.php?cr=$row[CREATOR]&tb=$row[NAME]'> $row[QP] </th>
          <th  align='center' scope='col'><a href='lista_packdep_2i.php?cr=$row[CREATOR]&tb=$row[NAME]'> $row[QK] </th>
          <th  bgcolor='#FFFF9F' align='center' scope='col'> $n </th>
          </tr> ";

      $icr=$row['CREATOR'];
      $n++;

      if (ceil($n / 20) == ($n / 20))
        echo "<tr>
        	     <th onclick=alert('criador_da_view') bgcolor='#FFFF9F' scope='col'> Criador (1) </th>
        	     <th onclick=alert('nome_da_view') bgcolor='#FFFF9F' scope='col'> Nome (2)</th>
        	     <th onclick=alert('quantidade_de_colunas') bgcolor='#FFFF9F' scope='col'> Qtd. colunas (3)</th>
        	     <th onclick=alert('tabelas_usadas_pela_view') bgcolor='#FFFF9F' scope='col'> Tabelas (4)</th>
        	     <th onclick=alert('planos_que_usam_a_view') bgcolor='#FFFF9F' scope='col'> Planos (5)</th>
        	     <th onclick=alert('packages_que_usam_a_view') bgcolor='#FFFF9F' scope='col'> Packages (6)</th>
        	     <th onclick=alert('nmero_de_sequncia_na_pgina') bgcolor='#FFFF9F' scope='col'> seq </th>
              </tr>" ;


      }

      echo "</table> <br> <br> <br>";

}}

odbc_close($dbconn);

?>