On 22-May-2002 Nebbe, Joelle wrote:
> Hello
>
> I'm experiencing odd problems using DBD::ODBC - Easysoft OOB to connect to
> an SQL server.
> I have seen on forums and mailing list archives that other people have
> experienced a similar
> problem on varied platforms but never found a solution outlined...
>
> I have just ported some scripts from a windows machine to a linux machine
> and am getting
> truncations when trying to set a text field.
>
> [Microsoft][ODBC SQL Server Driver]String data, right truncation
> (SQL-22001)(DBD: st_execute/SQLExecute err=-1)
>
> Trying to do the exact same thing on the windows machine will work without a
> hitch.
> The windows version used: $dbh->{LongReadLen} = 512 * 1024; and never had
> any problems
> I have upped the limit on the unix version of it and cranked it high, yet i
> still get
> truncation - and the amount of text in question is maybe 1000 words, so well
> below the
> size
>
> I have tried using:
> --------------
> [...]
> $dbh->{LongReadLen} = 512 * 1024;
> [...]
> eval
> {
> # add text article
> my $sqlstatement = "Update Article set Text=? where
> articleid = $articleid";
> my $sth = $dbh->prepare("$sqlstatement");
> $sth->bind_param(1, $cgitext, {SQL_LONGVARCHAR=>1});
> $sth->execute() || die("Can't execute SQL Statement:
> $DBI::errstr\n"."$sqlstatement");
> $dbh->commit();
> };
> [...]
> ---------------
>
> and:
> ---------------
> [...]
> $dbh->{odbc_default_bind_type} = 0;
> $dbh->{LongReadLen} = 1024 * 1024; # this is a lot!!!
> [...]
> eval
> {
> # add text article
> my $sqlstatement = "Update Article set Text=? where
> articleid = $articleid";
> my $sth = $dbh->prepare("$sqlstatement");
> $sth->bind_param(1, $cgitext); #, {SQL_LONGVARCHAR=>1}
> $sth->execute() || die("Can't execute SQL Statement:
> $DBI::errstr\n"."$sqlstatement");
> $dbh->commit();
> };
> [...]
> ---------------
>
> I tried increasing the LongReadLen limit and it does help a little, (even
> though it is only for read).
> Yet even when the size i put there is gigantic (1024 * 1024 * 1000) it still
> refuses a 3 page text... I can up it until the system complains it cannot
> allocate any more memory, yet it still truncates basic text.
>
> Any idea what I am missing?
>
> Joelle Nebbe
If you can provide and OOB log I will take a look at it.
To generate a log do the following:
[1] cd to dir where you run your perl script from.
[2] create an odbc.ini file in this dir containing ONLY the following:
{Settings}
Logging = 0xffffff
Note that those are curly braces around "Settings"
[3] Run you perl script (once)
[4] this should generate a file called /tmp/esoobclient.log_<PID> where <PID>
is the process ID.
Send that file along with the Perl script, a description of how long
$cgitext is and the schema for your Article table. You can get the schema
for your Article table from SQL Server enterprise manager, select the
Article table, hit CTRL/C, open a notepad and CTRL/V in it - it will paste
the SQL to create your Article table.
[5] delete odbc.ini file create in [2] or it will slow your perl script down
massivley (all that logging).
Martin
--
Martin J. Evans
Easysoft Ltd, UK
Development