crouchingpenguin has asked for the wisdom of the Perl Monks concerning the following question:

I am running into a column name being truncated with DBD::Sybase 1.25, when I call $sth->{NAME} (or the uc variant).
my $stmt = $dbo->prepare("select XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX f +rom ${table_name}"); $stmt->execute(); print Dumper $stmt->{NAME_uc},"\n";
where X*34 gets trimmed 5 characters. LongTruncOk and LongReadLen don't seem to apply here. So is there any other attributes I can set to undo this? I think its specific to the DBD as I do not have this problem with PgSQL's DBD.

Thanks!

Replies are listed 'Best First'.
Re: DBI: $sth->{NAME}
by BlueBlazerRegular (Friar) on Sep 12, 2002 at 20:44 UTC
    From "Programming the Perl DBI", p. 323:

    "The names of identifiers, such as tables and columns, cannot exceed thirty characters in length."

    From what I remember, this limitation is in Sybase (at least up thru 10.2) itself. MS SQL Server also appears to have this limitation.

    Pat

      Indeed this seems to be the case:
      The names of Sybase identifiers, such as tables and columns, cannot exceed 30 characters in length.
      from the dbd-sybase.pod.

      I guess I will have to cheat. Thanks for the time and help.
Re: DBI: $sth->{NAME}
by hmerrill (Friar) on Sep 12, 2002 at 20:20 UTC
    Not sure what would cause that. I don't use Sybase, but I've used Oracle, MySQL, and Postgres, and their respective DBD's, and I haven't seen that in any of those. The "Programming ther Perl DBI" book doesn't give any clues in the DBD::Sybase section towards the back - in fact it says that LongReadLen and LongTruncOk attributes aren't even supported. It also says that CHAR, VARCHAR, BINARY, and VARBINARY are all limited to 255 chars in length. Of course, that book is a few years old :-)

    If you don't get any answers here, try asking on the DBI mailing list - there are at least a few Sybase people on that list, including Michael Peppler who is the author of the DBD::Sybase module.

    HTH.
Re: DBI: $sth->{NAME}
by blssu (Pilgrim) on Sep 12, 2002 at 20:39 UTC

    Is Sybase trimming the column name? Have you tested trying something like:

    create table foo ( XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXA integer, XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXB integer );
    If that generates an error, DBI (or the DBD driver) is probably doing the right thing.

      No, sybase isn't trimming the column name. sp_columns ${table_name} returns the full name of the column.

        Since Sybase was trimming the columns, I guess you won't trust that method anymore! (You didn't try my example either, did you? ;)

Re: DBI: $sth->{NAME}
by busunsl (Vicar) on Sep 13, 2002 at 07:25 UTC
    Identifiers (that is table-, column-, procedure-names and so on) in Sybase ASE (up to version 12.5.x) have a maximum length of 30 characters.