CC: | gorni.henrique [...] gmail.com |
Subject: | BCP REORDER bug |
Date: | Tue, 20 Jul 2010 21:09:24 -0300 |
To: | bug-sybperl [...] rt.cpan.org |
From: | Henrique C GORNI <henrique.c.gorni [...] hsbcglt.com.br> |
Hi,
I'm using this excellent library but I was having some difficult in using
the REORDER option in the BCP API when issuing source column
position/table column name pairs.
I have found out that the bug is in the SELECT statement BCP.pm uses to
retrieve column info. Sometimes the column order will not be retrieved in
the correct order by the following statement used in BCP.pm:
select c.name, t.name
from $db.dbo.syscolumns c, $db.dbo.systypes t
where c.id = object_id('$table')
and c.usertype *= t.usertype
Therefore, when I use REORDER = { 1=> 'COL_NAME1', 2=>'COL_NAME2', ... }
the column indexes will most of the times be replaced with the wrong
indexes. To fix that I just added the "order by c.colid asc" clause to
this statement as follows:
select c.name, t.name
from $db.dbo.syscolumns c, $db.dbo.systypes t
where c.id = object_id('$table')
and c.usertype *= t.usertype
order by c.colid asc
Hope this helps correcting this small bug in such a great tool :-)
Please, if you need to return the e-mail, return to my personal address
(gorni.henrique@gmail.com) because this one I'm using to write to you is
my office's e-mail.
Thank you very much!
Best regards,
Henrique Cesar Gorni
-----------------------------------------
This E-mail is confidential. It may also be legally
privileged. If you are not the addressee you may not
copy, forward, disclose or use any part of it. If
you have received this message in error, please delete
it and all copies from your system and notify the sender
immediately by return E-mail.
Internet communications cannot be guaranteed to be timely,
secure, error or virus-free. The sender does not accept
liability for any errors or omissions.
"SAVE PAPER - THINK BEFORE YOU PRINT!"
Esta mensagem pode conter informações confidenciais e/ou
privilegiadas. Se você não for o destinatário ou a pessoa
autorizada a recebê-la, não pode usar, copiar ou divulgar
as informações nela contidas ou tomar qualquer ação baseada
nelas. Se você recebeu esta mensagem por engano, por favor,
avise imediatamente o remetente, e em seguida, apague-a.
Comunicações pela Internet não podem ser garantidas quanto
à segurança ou inexistência de erros ou de vírus.
O remetente, por esta razão, não aceita responsabilidade por
qualquer erro ou omissão no contexto da mensagem decorrente
da transmissão via Internet.
"ECONOMIZE PAPEL - PENSE ANTES DE IMPRIMIR!"