<html>
<title>Demo: <?php echo $PHP_SELF?></title>
<body bgcolor="white">
<h1> <?php echo $PHP_SELF?></h1>
<hr>
<!-- Demo begin -->
<?php
    
// Connect to Oracle using SID=$ORACLE_SID or $TWO_TASKS
    
$con OCILogon("scott""tiger");

function 
DisplayTable($con$sql) {
    echo 
"<p>SQL: ".$sql;
    echo 
"<p>\n";
    
$stmt OCIParse($con$sql);
    
OCIExecute($stmt);
    echo 
"<table border=\"1\"><tr>\n";
    for (
$i=1$i<=OCINumCols($stmt); $i++) {
        echo 
"<th>";
        echo 
OCIColumnName($stmt,$i);
        echo 
"</th>\n";
    }
    echo 
"</tr>\n";
    echo 
"";
    while (
OCIFetchInto($stmt, &$resultOCI_ASSOC)) {
        echo 
"<tr>";
        for (
$i =1$i<=OCINumCols($stmt); $i++) {
            echo 
"<td>";
            echo 
$result[OCIColumnName($stmt,$i)];
            echo 
"</td>";
        }
        echo 
"</tr>\n";
    }
    echo 
"</table>\n";
}

    
$sql "SELECT cols.column_name as Name, nullable, data_type as Type, Decode( data_type, 'NUMBER', data_precision + data_scale, data_length ) Length, data_precision Precision, data_scale Scale, data_length length, data_default, ' ' comments FROM user_tab_columns cols WHERE cols.table_name = 'EMP' order by column_id";
    
DisplayTable($con$sql);
    
$sql "SELECT table_name, tablespace_name, pct_free, pct_used, initial_extent, next_extent, pct_increase, degree, instances, decode(ltrim(cache),'Y', 'CACHE', 'NOCACHE') cache FROM user_tables where table_name='EMP'";
    
DisplayTable($con$sql);
    
$sql "SELECT A.UNIQUENESS, A.INDEX_NAME, A.TABLES PACE_NAME AS Tablespace, A.INITIAL_EXTENT AS InitialExtentSize, A.PCT_INCREASE AS PercentIncrease, A.PCT_FREE AS MinimumPercentFree, A.next_extent FROM USER_INDEXES A WHERE (A.TABLE_NAME = 'EMP')";
    
DisplayTable($con$sql);
    
$sql "SELECT comments FROM user_tab_comments WHERE table_name = 'EMP' AND comments IS NOT NULL" ;
    
DisplayTable($con$sql);
    
$sql "SELECT column_name, comments FROM user_col_comments WHERE table_name = 'EMP' AND column_name = 'EMPNO'";
    
DisplayTable($con$sql);
    
//while (OCIFetchInto($stmt, &$result, OCI_ASSOC)) {
    //    echo $result['TABLE_NAME'];
    //    echo "<br>\n";
    //}
    // Disconnect from Oracle
    
OCILogoff($con);
?>
<!-- Demo end -->
<hr>
<i>by Hans Schou <a href="mailto:chlor@schou.dk">&lt;chlor@schou.dk&gt;</a></i>
<a href="http://www.schou.dk">http://www.schou.dk</a><br><br>
<?php
    
// Display source file if exists
    
if (file_exists($fn basename($PHP_SELF"s") ))
     echo 
"<i>Source file: <a href=\"".$fn."\">$fn</a></i>\n";
    else
     echo 
"<i>Source file $fn is not available< /i>\n";
?>
</body>
</html>