我尝试在apirest中使用存储过程但不起作用

时间:2017-01-17 16:07:15

标签: oracle entity-framework rest stored-procedures return-value

我需要你的帮助

我在C#中有一个程序 这有实体框架6.0.0.0 我在其中使用apiRest访问ORACLE数据库中的数据

那就是说,在数据库中,我的程序声明如下:

From: /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/pry-rescue-1.4.4/lib/pry-rescue.rb @ line 206 PryRescue.with_program_name:

   201: def with_program_name name
   202:   before = $PROGRAM_NAME
   203:   $PROGRAM_NAME = name
   204:   yield
   205: ensure
=> 206:   $PROGRAM_NAME = before
   207: end

在程序中我有一个我打电话的按钮

Create or replace PROCEDURE SP_INSERT_MATRIX
(
 V_matrixtype IN NUMBER DEFAULT 0,
 V_name IN NVARCHAR2 DEFAULT NULL,
 V_description IN NVARCHAR2 DEFAULT NULL,
 V_userid IN NVARCHAR2 DEFAULT 'user1',
 Retval out number
)
AS
BEGIN
INSERT INTO matrixcams (internalid, matrixtype, NAME, DESCRIPTION, USERID)
VALUES (MATRIXCAMS_INTERNALID_GEN.nextval, v_matrixtype, v_name, v_description, (SELECT internalId from users where username like v_userid));
Retval: = MATRIXCAMS_INTERNALID_GEN.currval;
END SP_INSERT_MATRIX;

控制器声明了如下函数:

<button ng-click="RealGetListMatrix()" style="padding-right: 1px;">Refrescar</button>

在api休息中:

$Scope.RealGetListMatrix = function () {
 Var id = 0;
 Var Username = Object.keys (sessionStorage) .toString ()
 Id = RealSetNameListMatrix (Username);
 RefreshMatrix ();
 Alert (id);
}

Var RealSetNameListMatrix = function (myUserId) {
Var nameList = document.getElementById ("NameListMatrix");
Var descList = document.getElementById ("DescListMatrix");
Var msgCams = "";
Var InternalId = 178;

MatrixRest.postMatrix (function (matrixes) {});
Return InternalId;
}

控制器调用管理器

PostMatrix: function (data, callback) {
 This.post (function (responseMatrixes) {
  If (responseMatrixes.success) {
   Callback (responseMatrixes.data.matrixes);
  } Else {
  $RootScope.$broadcast('alert', {type: 'error', msg: responseData.error.message});
  }
 },data);
},

在经理

Public IResponseMatrixes Post ()
{
 Return this.manager.PostResponseMatrixes ();
}

在存储库中

Public IResponseMatrixes PostResponseMatrixes ()
{
 Repository.PostMatrix ();
 Return responseToRequest;
}

最后在模型中

{
 Int myUserId = 0;
 ObjectParameter passMatrixInternalId = new ObjectParameter ("internalId", typeof (Int32));
 Using (CCTVConn context = new CCTVConn ())
 {
  Context.SP_INSERT_MATRIX (0, "test", "test", "user1", passMatrixInternalId);
 }
 Return Convert.ToInt32 (passMatrixInternalId.Value.ToString ());
}

数据流正确,但我想运行该功能的那一刻 SP_INSERT_MATRIX 随着ExecuteFunction的调用

我错过了错误:

Public virtual int SP_INSERT_MATRIX (Nullable <decimal> v_MATRIXTYPE, string v_NAME, string v_DESCRIPTION, string v_USERID, ObjectParameter rETVAL)
{
 Int step = 0;
 Var v_MATRIXTYPEParameter = v_MATRIXTYPE.HasValue?
  New ObjectParameter ("V_MATRIXTYPE", v_MATRIXTYPE):
  New ObjectParameter ("V_MATRIXTYPE", typeof (decimal));    
 Var v_NAMEParameter = v_NAME! = Null?
  New ObjectParameter ("V_NAME", v_NAME):
  New ObjectParameter ("V_NAME", typeof (string));    
 Var v_DESCRIPTIONParameter = v_DESCRIPTION! = Null?
  New ObjectParameter ("V_DESCRIPTION", v_DESCRIPTION):
  New ObjectParameter ("V_DESCRIPTION", typeof (string));    
 Var v_USERIDParameter = v_USERID! = Null?
  New ObjectParameter ("V_USERID", v_USERID):
  New ObjectParameter ("V_USERID", typeof (string));    
 Try
 {
  Step = (((IObjectContextAdapter) this) .ObjectContext.ExecuteFunction ("SP_INSERT_MATRIX", v_MATRIXTYPEParameter, v_NAMEParameter, v_DESCRIPTIONParameter, v_USERIDParameter, rETVAL);
 }
 Catch (Exception ex)
 {
  Var a = ex.Message;
 }
 Return step;
}

我整个上午都遇到过这个问题,你能告诉我我的错误在哪里吗?或者如何解决它,

非常感谢

0 个答案:

没有答案