Advertisement
Guest User

Untitled

a guest
Jul 31st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. postAsignarUsuario: function(req, res, next) {
  2.  
  3.  
  4.  
  5. var config = {
  6. user: 'xx',
  7. password: 'xx.$',
  8. server: 'xx', // You can use 'localhost\instance' to connect to named instance
  9. database: 'xxxc',
  10. options: {
  11. encrypt: true, // Use this if you're on Windows Azure
  12. tdsVersion: '7_1'
  13. }
  14. }
  15.  
  16. var connection1 = new sql.Connection(config, function(err) {
  17. // ... error checks
  18. if (err) throw err;
  19. // Query
  20.  
  21. var request = new sql.Request(connection1); // or: var request = connection1.request();
  22. request.query("INSERT INTO SI_Conteo(SI_Num_Inventario,SI_Ubicacion,SI_Ubicacion_Fisica,SI_Num_Articulo, SI_Cantidad,SI_Num_Conteo,SI_Fecha_Conteo,SI_Usuario,SI_OV) SELECT SI_Num_Inventario = COALESCE (t.SI_Num_Inventario,c.SI_Num_Inventario),(CASE WHEN c.SI_OV IS NULL OR c.SI_OV = '' THEN COALESCE(t.SI_Ubicacion, c.SI_Ubicacion) ELSE NULL END)AS SI_Ubicacion, (CASE WHEN c.SI_OV IS NOT NULL THEN COALESCE(t.SI_Ubicacion_Fisica, c.SI_Ubicacion_Fisica) ELSE NULL END)AS SI_Ubicacion_Fisica,SI_Num_Articulo = COALESCE(t.SI_Articulo, c.SI_Num_Articulo),NULL, SI_Num_Conteo = COALESCE(cs.SI_Num_Conteo,2),GETDATE(),'" + req.body.Usuario + "',c.SI_OV FROM SI_Inventario_Teorico_QAD t full JOIN SI_Conteo c ON t.SI_Articulo = c.SI_Num_Articulo AND t.SI_Ubicacion = c.SI_Ubicacion INNER JOIN SI_Maestro_Ref_QAD m ON t.SI_Articulo = m.SI_Num_Articulo OR c.SI_Num_Articulo = m.SI_Num_Articulo FULL JOIN SI_Consecutivo cs ON c.SI_Num_Inventario = cs.SI_Num_Inventario AND cs.SI_Estado = 0 WHERE c.SI_Num_Articulo ='" + req.body.idArticulo + "' OR t.SI_Articulo = '" + req.body.idArticulo + "'", function(err, recordset) {
  23. // ... error checks
  24. if (err) throw err;
  25. console.dir(recordset);
  26. });
  27.  
  28. });
  29.  
  30. connection1.on('error', function(err) {
  31. // ... error handler
  32. console.log('Error');
  33. console.error(err.stack);
  34. console.log(err);
  35. });
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement