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

I'm using DBI module to connect to mssql in Unix box. If a field has more than 255 chars, I cannot able to retrieve them using any function.

Is there any option to retrieve those field values in full?

  • Comment on Unable to retrieve field which has more than 255 chars

Replies are listed 'Best First'.
Re: Unable to retrieve field which has more than 255 chars
by Anonymous Monk on Mar 07, 2012 at 08:02 UTC
    show your code, turn on trace level

      This is my code:

      my $dbiConn="DBI:Sybase:server=$prop{dbHost}:1433";

      my $db=DBI->connect($dbiConn,$prop{dbUser},$prop{dbPwd});

      my $sqlSt="select FilesTransfered,transactionDate from CDProcessTransaction where processname = '$prop{process}'";

      my $recordSet=$db->prepare($sqlSt);

      $recordSet->execute( );

      while (my @rValue=$recordSet->fetchrow_array)

      {

      print OUT "Files: @rValue\n";

      }

      If length of field "FilesTransfered" is more than 255 characters, its truncated. This field contains the filenames processed (sometimes upto 20 filenames where it exceeds more than 255 chars)

      .
        What is the type of the field? (I.e. show us how the table is created.)
        f length of field "FilesTransfered" is more than 255 characters, its truncated.
        Sure, but not on retrieval. It means you're trying to stuff more than 255 characters in a field that doesn't allow more. It's like putting 100 pairs of socks in a drawer that only fits 20. You cannot get more than 20 pairs of socks out of them, the other 80 will have dropped on the ground.

        Change the type of column, and repopulate the table.

        Note that this isn't a Perl issue. It's a database issue, and you'll have this problem regardless of the language you're using to access the database.

Re: Unable to retrieve field which has more than 255 chars
by CountZero (Bishop) on Mar 07, 2012 at 10:37 UTC
    Did you double-check that indeed this field actually contains more than 255 chars?

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics

      I checked in backend and got the desired results. Actual length is 320 chars and I can retrieve them using the same query in mssql.

      Field datatype is defined as "nvarchar(2500)"