Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- postAsignarUsuario: function(req, res, next) {
- var config = {
- user: 'xx',
- password: 'xx.$',
- server: 'xx', // You can use 'localhost\instance' to connect to named instance
- database: 'xxxc',
- options: {
- encrypt: true, // Use this if you're on Windows Azure
- tdsVersion: '7_1'
- }
- }
- var connection1 = new sql.Connection(config, function(err) {
- // ... error checks
- if (err) throw err;
- // Query
- var request = new sql.Request(connection1); // or: var request = connection1.request();
- 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) {
- // ... error checks
- if (err) throw err;
- console.dir(recordset);
- });
- });
- connection1.on('error', function(err) {
- // ... error handler
- console.log('Error');
- console.error(err.stack);
- console.log(err);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement