Oracle::OCI 0.04

[email protected] (Tim Bunce) Sat, 21 Jul 2001 02:40:02 +0100
Newsgroups perl.dbi.oracle-oci
Organization Paul Ingram Group, Software Systems, +44 1 483 862800
Message-ID <[email protected]>
The uploaded file

    Oracle-OCI-0.04.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/T/TI/TIMB/Oracle-OCI-0.04.tar.gz
  size: 34930 bytes
   md5: 73d5ef3012f88cbe3ea2c6fbbea29e45


This is a bit of a half-baked release but I wanted to get one out
before the Perl Conference. This one is better in assorted internals
than the previous.

The 05dbi.t script has an _almost_ working example of OCIDescribeAny
(actually the OCIDescribeAny works fine, but the OCIAttrGet to get the
column names of the table returns the length but doesn't seem to update
the string buffer). I've appended the code below.

Enjoy.

Tim.


my $env = get_oci_handle($dbh, OCI_HTYPE_ENV);
ok OCIHandleAlloc($env, my $dschp, OCI_HTYPE_DESCRIBE, 0, 0), 0;
bless $dschp => 'OCIDescribePtr';

ok OCIDescribeAny($dbh, $dbh, oci_buf_len($table), OCI_OTYPE_NAME, 1, OCI_PTYPE_TABLE, $dschp), 0;
 
# get the parameter descriptor
ok OCIAttrGet($dschp, OCI_HTYPE_DESCRIBE, my $parmp_int=0, 0, OCI_ATTR_PARAM, $dbh, 4), 0;
my $parmp = bless \$parmp_int => 'OCIParamPtr';
 
# number of columns
ok OCIAttrGet($parmp, OCI_DTYPE_PARAM, my $numcols=0, 0, OCI_ATTR_NUM_COLS, $dbh, 2), 0;
ok $numcols, 2;
 
DBI->trace(1);
# column list of the table
ok OCIAttrGet($parmp, OCI_DTYPE_PARAM, my $collst_int=0, 0, OCI_ATTR_LIST_COLUMNS, $dbh, 4), 0;
my $collst = bless \$collst_int => 'OCIParamPtr';
 
foreach my $colnum (1..$numcols) {
    my $col_parmdp_int = 0;
    my $col_parmdp = bless \$col_parmdp_int => 'OCIParamPtr';
    ok OCIParamGet($collst, OCI_DTYPE_PARAM, $dbh, $col_parmdp, $colnum), 0;
 
    my $name;
    ok $status=OCIAttrGet($col_parmdp, OCI_DTYPE_PARAM, oci_buf_len($name, 30), OCI_ATTR_NAME, $dbh, 0), 0;
    my $errstr = get_oci_error($dbh, $status, 'OCIAttrGet'); 
    warn $errstr if $status != OCI_SUCCESS;
    warn "COL $colnum NAME = '$name'";
}
DBI->trace(0);