MySQL Forums
Forum List  »  Spanish

Re: Importar datos desde csv a campos varchar
Posted by: Juan Carlos Tirado
Date: June 14, 2007 02:45PM

Claro, mira:

esta es la estructura original de la tabla donde se deben importar los registros:

Field Type Collation
----------- ----------- ---------------
COMPROBANTE int(11)
FECHA datetime
NIT int(20)
TIPO varchar(20) utf8_general_ci
NOMBRE varchar(40) utf8_general_ci
AGENCIA varchar(20) utf8_general_ci
VALOR int(20)
FACTURA varchar(20) utf8_general_ci
ENLACE int(11)
PAQUETE int(11)

el import del csv lo estoy haciendo con el programa mysqlyog, el problema es con los campos nombre y factura (en ambos se debe importar informacion que contiene caracteres especiales), si los convierto en tipo blob la informacion me carga, si no me la trunca; el problema con el tipo blob es que despues al hacer el update para la otra tabla no pasan bien.

la tabla de destino tiene esta estructura:

Field Type Collation
-------------------- ----------- --------------- ------
DWDOCID int(11)
DWPAGECOUNT int(11)
DWDISKNO int(11)
DWFLAGS int(11)
DWOFFSET int(11)
DWSTOREDATETIME datetime
DWSTOREUSER varchar(20) utf8_general_ci
DWMODDATETIME datetime
DWMODUSER varchar(20) utf8_general_ci
DWLASTACCESSDATETIME datetime
DWLASTACCESSUSER varchar(20) utf8_general_ci
DWSTORAGEACCESS longtext utf8_general_ci
COMPROBANTE int(11)
FECHA datetime
NIT int(11)
TIPO varchar(20) utf8_general_ci
NOMBRE varchar(40) utf8_general_ci
AGENCIA varchar(20) utf8_general_ci
VALOR int(11)
FACTURA varchar(20) utf8_general_ci
ENLACE int(11)
PAQUETE int(11)

la sintaxis del update es esta:

UPDATE
ccon2000_new as a,1index as b
SET
a.FECHA = b.FECHA,
a.NIT = b.NIT,
a.TIPO = b.TIPO,
a.NOMBRE = b.NOMBRE,
a.AGENCIA = b.AGENCIA,
a.VALOR = b.VALOR,
a.FACTURA = b.FACTURA,
a.ENLACE = b.ENLACE,
a.PAQUETE = b.PAQUETE
WHERE
a.enlace = 1
and a.comprobante = b.comprobante

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.