The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Sybase::ObjectInfo - Return Sybase Object information

SYNOPSIS

 %info = grab Sybase::ObjectInfo($dbh, $database, \@table_list) 

 where:
    $dbh is a Sybase::DBlib handle
    $database is the name of the database
    @table_list is an array containing the tables


 returns a hash for the form:
    $r = $info{$db_name}->{$table_name}->{$field_name}

    $r->{col_id}          # column order
      ->{col_type}        # column fundamental datatype
      ->{col_len}         # column datatype length
      ->{col_allownulls}  # does the column allow nulls
      ->{col_usertype}    # column usertype - if applicable
      ->{col_prec}        # column precision
      ->{col_order}       # an array of the columns names in order

   and per table:
     $info{$db_name}->{$table_name}->{__COLNAMES__} #an array of the column names in order
 

DEPENDENCIES

 perl version 5.004

 Sybase::DBlib

DESCRIPTION

Grabs column information from Sybase system tables for a given list of tables. Information includes column number, type, length, allow null attribute, usertype, and precision.

 It performs the following SQL:
    select
       col_name    = c.name,
       type_name   = t.name,
       col_len     = c.length,
       col_order   = c.colid,
       ctype       = c.type,
       utype       = t.usertype,
       allownulls  = t.allownulls
    from
       $db_name..syscolumns c,
       $db_name..systypes t
    where
       c.id = object_id('$db_name..$tab_name')
       and c.usertype *= t.usertype
    order
       by c.colid

followed by this for each field where utype > 100 to get the underlying datatype for usertypes

    select
       name
    from
       $db_name..systypes
    where
       usertype < 100
       and type=$col->{ctype}
       and name not in ("sysname", "nchar", "nvarchar")

MISC

When supplying the parameters to grab, $database can be null. If so, then tables must be of the form "database.owner.table" (owner can be null)

If only one table is specified then table_list can be a scalar containing the name of the table.

WISH LIST

I should convert this to use DBI/DBD at some point. And if I'm not mistaken these kind of attributes are already built into that system (thereby rendering this module close to obsolete if DBI is installed)

CONTACTS

stephen.sprague@msdw.com

VERSION

Version 0.21 24-FEB-2001 Added return key '{__COLNAMES__}'

Version 0.20 10-FEB-2001 Documentation/pod changes only

version 0.1, 01-OCT-2000 Created