Sorry, this is the first time I've ever done something like this, so please
don't judge me too harshly ;)

------------------------------------

# Insert into temp tables for each company
while(@companyColumns = $sthCompanyFields->fetchrow_array()) {

        my $companyID = $companyColumns[0];
        my $companyName = $companyColumns[1];
        my $xmlFilePath = "$dataPath\\$companyID";
        my $xmlAgents = XML::Simple->new();

        # Parse agents and insert into temp table
        my $agentDoc = $xmlAgents->XMLin("$xmlFilePath\\Agent.txt", forcearray =>
1);
        foreach my $agentRow (@{$agentDoc->{DATA}}) {
                chomp($agentRow);

                # Split fields on tab
                my @agentFields = split(/\t/,$agentRow);

                # Replace opening blank with company ID
                $agentFields[0] = $companyID;

                # Make sure there are 43 fields
                @agentFields = @agentFields[0..42];

                # Insert agent
                my %attr;
                $sthInsertAgents->execute_array(\%attr, @agentFields)
                        or die "Error: Unable to execute sthInsertAgents in 
$companyName.";
        }
}

------------------------------------

Lisa Homstad
Web Developer
Global Reach Internet Productions
[EMAIL PROTECTED]
515-296-0792
http://www.globalreach.com

-----Original Message-----
From: Hardy Merrill [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 13, 2004 2:42 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Truncation Issues with SQL Server Insert Statement


The problem with the original question/issue is that the poster did not
include any DBI code.  Gathering from Amonotod's comments below, the
issue may be the quoting (or lack of proper quoting) done.

Original poster: did you use either the "quote" method, or better yet
did you use placeholders??  If you could post some of the DBI code for
your inserts into SQL Server, that might help ;-)

Hardy Merrill

>>> amonotod <[EMAIL PROTECTED]> 07/13/04 03:36PM >>>
> From: Tim Bunce <[EMAIL PROTECTED]>
> Date: 2004/07/13 Tue PM 06:38:51 GMT

>    I have been writing a perl script that takes a row of 43 fields,
splits on a tab, and performs an
>    execute_array into an SQL Server database, all in a loop.  The
insert statement works fine, it doesn't
>    generate any errors as far as I can tell, and all the data gets
inserted into the database.  The only
>    problem is, a few of the fields are truncated.

I was having issues similar to this, until I switched to DBD::CSV to
parse
my input files and started using quote() instead of s///... Works great

now.  So, "Thanks, Jeff and Jochen!"...

HTH,
amonotod


--
    `\|||/         amonotod@    | subject line:
      (@@)         charter.net  | no perl, no read...
  ooO_(_)_Ooo________________________________
  _____|_____|_____|_____|_____|_____|_____|_____|


Reply via email to