Created
March 1, 2020 00:39
-
-
Save elyphas/dc9e4b682e892da7a5f50aeb22438500 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//case class GralDataPedido(no_pedido: String, compra: String, ejercicio: Int, fecha_pedido: java.sql.Date) | |
//case class Fechas(fecha: String) | |
implicit val dateGet: Get[Date] = Get[Fechas].tmap{ case date => | |
val format = new SimpleDateFormat("yyyy-MM-dd") | |
val parsed = format.parse(date.fecha) | |
new java.sql.Date(parsed.getTime()) | |
} | |
implicit val datePut: Put[Date] = Put[Fechas].tcontramap{ case date => | |
val df = new SimpleDateFormat("dd/MM/yyyy") | |
Fechas(df.format(date)) | |
} | |
val sql = """insert into tblpedi ( | |
| no_pedido, compra, ejercicio, fecha_pedido, tipo_compra, fecha_entrega, no_sol_compra, destino, elaboro, | |
| cve_depto, cve_provedor, cve_presup, cancelado, obsercancel, ejercicio_presupuesto, id_comparativo, rfc_dependencia, entrega | |
| ) | |
|values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""".stripMargin | |
Update[GralDataPedido](sql).updateMany(ps).transact(xa) | |
.attempt.map { | |
case Left(error) => Left(error.getMessage) | |
case Right(lst) => Right(lst) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment