简体   繁体   English

第一次使用存储过程

[英]First time working with Stored Procedures

This is my first time working directly with Stored Procedures and I need to know how to accommodate the params in a Node model. 这是我第一次直接使用存储过程,我需要知道如何在Node模型中容纳这些参数。

The DB guys send me this DB家伙给我发这个

USE [Some_Dev]
GO

DECLARE    @return_value int,
        @Authenticated bit,
        @CustomerId int,
        @LoginStatus tinyint

EXEC    @return_value = [theDB].[spLogin_Customer]
        @Login = N'wilsonTest2',
        @Password = N'xXx21458',
        @Authenticated = @Authenticated OUTPUT,
        @CustomerId = @CustomerId OUTPUT,
        @LoginStatus = @LoginStatus OUTPUT

SELECT    @Authenticated as N'@Authenticated',
        @CustomerId as N'@CustomerId',
        @LoginStatus as N'@LoginStatus'

SELECT    'Return Value' = @return_value

GO 

I am using mssql 我正在使用mssql

so, I am creating a login, the main requirement is to call this SP only in the model, anywhere else. 因此,我正在创建一个登录名,主要要求是仅在模型中的其他任何地方调用此SP。 But I don't have an idea where to start from. 但是我不知道从哪里开始。

Can someone gives me a hand? 有人可以帮我吗?

I am here because you can't see much information about SP in the internet. 我在这里是因为您在互联网上看不到有关SP的太多信息。 So I need to clarify this with your help. 因此,我需要在您的帮助下进行澄清。

EDIT here is what I have so far 到目前为止,我在这里编辑

import sql from 'mssql';

export default () => {
  cons config = {
    user: 'Marcelo',
    password: '54321@A',
    server: '111.111.111.1',
    database: 'Some_Dev'
  }

  let connection = new sql.Connection(config, function(err) {
    let request = connection.request();
    if (err) {
      cb(err);
    }
    request.input('Login', sql.VarChar(100));
    request.input('Password', sql.VarChar(100));
    request.output('Authenticated');
    request.output('CustomerId', sql.Int);
    request.output('LoginStatus', sql.Int);
    request.execute('[dbo].[spLogin_Customer]', function(err) {
      if (err) {
        cb(err);
      }
      connection.close();
      cb(null);
    })
  });
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM