Do You PHP?    
Search Engine Optimization  php5 powerd  Valid XHTML 1.0!  Valid CSS!  このサイトのはてなブックマーク数 



last updated
2002/10/28

counter hits
since 1999/11/06


裏OCI関数マニュアル - Column編

alertここにある情報はかなり古くなっており、正しくなくなっている可能性があります。掲載しているサンプルコードiなどは、最新のPHPでは動作しない、もしくは、別途設定・調整が必要になるかも知れません。情報を鵜呑みにせず、あなたの手を動かして、あなたの目で確認してください。

懲りずにやります(^-^; 今度は裏(?)OCIマニュアル(2002/10/28時点でマニュアルに説明がないだけで、関数のAPIは表示されています)のColumn関連のみです。

なお、サンプルスクリプトはページの最後にまとめてあります。

OCIColumnPrecision  int OCIColumnPrecision(int stmt, int col)

数値型(NUMBER)の精度(小数点を含む桁数)を返します。

OCIColumnScale  int OCIColumnScale(int stmt, int col)

数値型(NUMBER)の小数点以下の桁数を返します。

OCIColumnTypeRaw  int OCIColumnTypeRaw(int stmt, int col)

外部データ型を数値で返します。数値との対応はocidfn.hに定義されています(以下は、Oracle9.0.1のもの)。

/* input data types */
#define SQLT_CHR  1                        /* (ORANET TYPE) character string */
#define SQLT_NUM  2                          /* (ORANET TYPE) oracle numeric */
#define SQLT_INT  3                                 /* (ORANET TYPE) integer */
#define SQLT_FLT  4                   /* (ORANET TYPE) Floating point number */
#define SQLT_STR  5                                /* zero terminated string */
#define SQLT_VNU  6                        /* NUM with preceding length byte */
#define SQLT_PDN  7                  /* (ORANET TYPE) Packed Decimal Numeric */
#define SQLT_LNG  8                                                  /* long */
#define SQLT_VCS  9                             /* Variable character string */
#define SQLT_NON  10                      /* Null/empty PCC Descriptor entry */
#define SQLT_RID  11                                                /* rowid */
#define SQLT_DAT  12                                /* date in oracle format */
#define SQLT_VBI  15                                 /* binary in VCS format */
#define SQLT_BIN  23                                  /* binary data(DTYBIN) */
#define SQLT_LBI  24                                          /* long binary */
#define SQLT_UIN  68                                     /* unsigned integer */
#define SQLT_SLS  91                        /* Display sign leading separate */
#define SQLT_LVC  94                                  /* Longer longs (char) */
#define SQLT_LVB  95                                  /* Longer long binary */
#define SQLT_AFC  96                                      /* Ansi fixed char */
#define SQLT_AVC  97                                        /* Ansi Var char */
#define SQLT_CUR  102                                        /* cursor  type */
#define SQLT_RDD  104                                    /* rowid descriptor */
#define SQLT_LAB  105                                          /* label type */
#define SQLT_OSL  106                                        /* oslabel type */

#define SQLT_NTY  108                                   /* named object type */
#define SQLT_REF  110                                            /* ref type */
#define SQLT_CLOB 112                                       /* character lob */
#define SQLT_BLOB 113                                          /* binary lob */
#define SQLT_BFILEE 114                                    /* binary file lob */
#define SQLT_CFILEE 115                                 /* character file lob */
#define SQLT_RSET 116                                     /* result set type */
#define SQLT_NCO  122      /* named collection type (varray or nested table) */
#define SQLT_VST  155                                      /* OCIString type */
#define SQLT_ODT  156                                        /* OCIDate type */

/* datetimes and intervals */
#define SQLT_DATE                      184                      /* ANSI Date */
#define SQLT_TIME                      185                           /* TIME */
#define SQLT_TIME_TZ                   186            /* TIME WITH TIME ZONE */
#define SQLT_TIMESTAMP                 187                      /* TIMESTAMP */
#define SQLT_TIMESTAMP_TZ              188       /* TIMESTAMP WITH TIME ZONE */
#define SQLT_INTERVAL_YM               189         /* INTERVAL YEAR TO MONTH */
#define SQLT_INTERVAL_DS               190         /* INTERVAL DAY TO SECOND */
#define SQLT_TIMESTAMP_LTZ             232        /* TIMESTAMP WITH LOCAL TZ */

#define SQLT_PNTY   241              /* pl/sql representation of named types */

また、ここにある関数の結果をまとめて表示するサンプルは以下の通りです。

●サンプルスクリプト

<?php
    $conn = OCILogon("scott", "tiger", "orcl");
    $stmt = OCIParse($conn,"select * from emp ");
    OCIExecute($stmt);
    $ncols = OCINumCols($stmt);

    echo "<table border='1'>";
    echo "<tr>";
    echo "<th>Name</th>";
    echo "<th>Type</th>";
    echo "<th>Precision</th>";
    echo "<th>Scale</th>";
    echo "<th>Size</th>";
    echo "<th>TypeRaw</th>";
    echo "</tr>";
    for ( $i = 1; $i <= $ncols; $i++ ) {
        echo "<tr>";
        echo "<th>" . OCIColumnName($stmt,$i) . "</th>";
        echo "<td>" . OCIColumnType($stmt, $i) . "</td>";
        echo "<td>" . OCIColumnPrecision($stmt, $i) . "</td>";
        echo "<td>" . OCIColumnScale($stmt, $i) . "</td>";
        echo "<td>" . OCIColumnSize($stmt, $i) . "</td>";
        echo "<td>" . OCIColumnTypeRaw($stmt, $i) . "</td>";
        echo "</tr>";
    }
    echo "</table>";

    OCIFreeStatement($stmt);
    OCILogoff($conn);
?>



About This Site |  Privacy Policy |  Contact
Copyright © 1999 - 2002 by Hideyuki SHIMOOKA all rights reserved.