【问题标题】:First time working with Stored Procedures第一次使用存储过程
【发布时间】:2015-11-25 18:37:20
【问题描述】:

这是我第一次直接使用存储过程,我需要知道如何在节点模型中容纳参数。

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 

我正在使用mssql

所以,我正在创建一个登录,主要要求是仅在模型中调用此 SP,其他任何地方。但我不知道从哪里开始。

有人可以帮帮我吗?

我在这里是因为您在互联网上看不到太多关于 SP 的信息。所以我需要在你的帮助下澄清这一点。

编辑 这是我到目前为止所拥有的

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);
    })
  });
};

【问题讨论】:

  • 你能提供你的模型吗?
  • @ibiza 查看更新

标签: javascript node.js stored-procedures


【解决方案1】:
猜你喜欢
  • 2014-03-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-14
  • 1970-01-01
  • 1970-01-01
  • 2011-05-16
相关资源
最近更新 更多