Steffen Goeldner wrote:
Mysterious! Looks like the first execute establishes a sticky max. length in SQL Server.
Indeed, I can reproduce it with pure ADO (see attached script). Unfortunately, I don't see a portable workaround for DBD::ADO. I think it would be best the SQL Server team buys a Shared Source License from the Access or FoxPro team - they know how to do it ;-)
Steffen
use Win32::OLE;
$Win32::OLE::Warn = 2;
$cxn = Win32::OLE->new('ADODB.Connection');
$cxn->Open('Provider=SQLOLEDB;Trusted_Connection=Yes');
$cxn->BeginTrans;
my $cmd = Win32::OLE->new('ADODB.Command');
$cmd->{ActiveConnection} = $cxn;
$cmd->{CommandText} = 'insert into trunctest( s ) values( ? )';
# $cmd->{CommandType} = $e->{CommandTypeEnum}{adCmdText};
$cmd->{Prepared} = 1;
$cmd->Parameters->Refresh;
print 'C: ', $cmd->Parameters->Count;
my $i = $cmd->Parameters->Item( 0 );
print 'T: ', $i->{Type};
print 'S: ', $i->{Size};
$i->{Size} = 4;
$i->{Value} = '1234';
$cmd->Execute;
$i->{Size} = 3;
$i->{Value} = '123';
$cmd->Execute;
$i->{Size} = 5;
$i->{Value} = '12345';
$cmd->Execute;
my $rs = $cxn->Execute('select * from trunctest');
while ( !$rs->{EOF} ) {
print ' : ', $_->Value for Win32::OLE::in( $rs->Fields );
$rs->MoveNext;
}
$rs->Close;
$cxn->RollbackTrans;
$cxn->Close;
=for test
C: 1
T: 200
S: 20
: 1234
: 123
: 1234 <=== truncated!
=cut
