Home » Databases » Sybase » ASE » 35383: DBD::Sybase calls the broken sp_tables stored procedure

35383: DBD::Sybase calls the broken sp_tables stored procedure

35383: DBD::Sybase calls the broken sp_tables stored procedure

Centos 5
Linux dba-dev1 2.6.22.9-default #1 SMP Mon Oct 1 11:26:48 CDT 2007 i686
athlon i386 GNU/Linux

Perl v5.8.8 built for i386-linux-thread-multi
DBD::Sybase 1.07 but 1.08 also has the problem.

Due to Sybase CR 497173, sp_tables can not be relied upon to retrieve
table information correctly for ASE 15.

(ASE 15 stored procedure “sp_tables” doesn’t work with SQL UDFs)

We need to query the system tables instead. Obviously, the below code
would work in v12.0 and higher. A temp table could probably be used for
prior to 12.0 for the TABLE_TYPE to be filled correctly.

diff ../DBD-Sybase-1.07/Sybase.pm Sybase.pm
218c218
< my $sth = $dbh->prepare("sp_tables $table, $schema, $catalog,
$type");
---
<div class="message-stanza-depth-1">
<div class="message-stanza-depth-2">> #     my $sth = $dbh->prepare("sp_tables $table, $schema, $catalog,</div>
</div>
$type");
219a220,238
>       my $sth = $dbh->prepare( q{
>                    select TABLE_QUALIFIER = db_name()
>                 , TABLE_OWNER     = u.name
>                 , TABLE_NAME      = o.name
>                 , TABLE_TYPE      =
>                     case o.type
>                         when "U" then "TABLE"
>                         when "V" then "VIEW"
>                         when "S" then "SYSTEM TABLE"
>                     end
>                 , REMARKS         = NULL
>              from sysobjects o
>                 , sysusers   u
>             where o.type in ('U', 'V', 'S')
>                       and id >99
>               and o.uid = u.uid
>
>               });
>
Share Button

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

Facebook login by WP-FB-AutoConnect