我正在使用Store Procedure插入表FASEC
。我希望在调用Store Procedure后插入最后一个id。
如何在调用Store过程后插入最后一个id?
fasec.IDFASEC始终为0
控制器:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult CreateFASEC([Bind(Prefix = "Item1")] FASEC fasec)
{
if (ModelState.IsValid)
{
ObjectParameter p_Result = new ObjectParameter("p_Result", typeof(Int32));
db.SPINSFASEC(fasec.FECHAFASEC, fasec.DIAGNOSTICOFINAL, fasec.VIGENTE, fasec.IDCIE10,
fasec.IDPRESTADOR, fasec.HISTORIALMEDICO, fasec.FECHAINICIO, fasec.FECHATERMINO,
fasec.FECHARENOVACION, fasec.IDBENEFICIARIO, fasec.IDTIPOEVALUACION, fasec.IDESTADOFASEC,
fasec.RESOLUCION, fasec.OBSERVACION, fasec.RUTAUTORIZO, fasec.IDEMPRESA, p_Result);
if (p_Result.Value == DBNull.Value)
{
return RedirectToAction("Index", new { mostrarError = 1});
}
else
{
db.SaveChanges();
var lastId = fasec.IDFASEC;
}
}
return RedirectToAction("Index");
}
存储过程:
create or replace PROCEDURE spInsFasec
(p_FechaFasec IN FASEC.FECHAFASEC%TYPE,
p_DiagnosticoFinal IN FASEC.DIAGNOSTICOFINAL%TYPE,
p_Vigente IN FASEC.VIGENTE%TYPE,
p_IdCie10 IN FASEC.IDCIE10%TYPE,
p_IdPrestador IN FASEC.IDPRESTADOR%TYPE,
p_HistorialMedico IN FASEC.HISTORIALMEDICO%TYPE,
p_FechaInicio IN FASEC.FECHAINICIO%TYPE,
p_FechaTermino IN FASEC.FECHATERMINO%TYPE,
p_FechaRenovacion IN FASEC.FECHARENOVACION%TYPE,
p_IdBeneficiario IN FASEC.IDBENEFICIARIO%TYPE,
p_IdTipoEvaluacion IN FASEC.IDTIPOEVALUACION%TYPE,
p_IdEstadoFasec IN FASEC.IDESTADOFASEC%TYPE,
p_Resolucion IN FASEC.RESOLUCION%TYPE,
p_Observacion IN FASEC.OBSERVACION%TYPE,
p_RutAutorizo IN FASEC.RUTAUTORIZO%TYPE,
p_IdEmpresa IN FASEC.IDEMPRESA%TYPE,
p_result OUT NUMBER) IS
cCeroValor CONSTANT NUMBER := 0;
cUnoValor CONSTANT NUMBER := 1;
vCont NUMBER(10);
vIDFASEC NUMBER := 0;
BEGIN
SELECT COUNT(*) INTO vCont
FROM COBERTURA
WHERE ACTIVO = cUnoValor AND
IDEMPRESA = p_IdEmpresa;
IF vCont > 0 THEN
INSERT INTO FASEC(
FECHAFASEC,
DIAGNOSTICOFINAL,
VIGENTE,
IDCIE10,
IDPRESTADOR,
HISTORIALMEDICO,
FECHAINICIO,
FECHATERMINO,
FECHARENOVACION,
IDBENEFICIARIO,
IDTIPOEVALUACION,
IDESTADOFASEC,
RESOLUCION,
OBSERVACION,
RUTAUTORIZO,
IDEMPRESA)
VALUES
(p_FechaFasec,
p_DiagnosticoFinal,
p_Vigente,
p_IdCie10,
p_IdPrestador,
p_HistorialMedico,
p_FechaInicio,
p_FechaTermino,
p_FechaRenovacion,
p_IdBeneficiario,
p_IdTipoEvaluacion,
p_IdEstadoFasec,
p_Resolucion,
p_Observacion,
p_RutAutorizo,
p_IdEmpresa)
RETURNING IDFASEC INTO vIDFASEC;
INSERT INTO COBERTURAFASEC
(IDCOBERTURAFASEC,
IDFASEC,
IDCOBERTURA,
PORCENTAJEREEMBOSO)
SELECT SEQ_COBERTURAFASEC.NEXTVAL,
vIDFASEC,
IDCOBERTURA,
PORCENTAJEREEMBOSO
FROM COBERTURA
WHERE ACTIVO = cUnoValor AND
IDEMPRESA = p_IdEmpresa;
p_result := 1;
END IF;
END;
答案 0 :(得分:0)
您可以使用输出
从存储过程中获取插入值public int[][] sortMatrix(int matrix[][], int r, int c) {
for (int k = 0; k < r * c; k++) {
Integer current = null;
Integer previous = null;
Integer currentI = null;
Integer currentJ = null;
Integer previousI = null;
Integer previousJ = null;
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
current = matrix[i][j];
currentI = i;
currentJ = j;
if (previous != null) {
if (current < previous) {
matrix[currentI][currentJ] = previous;
matrix[previousI][previousJ] = current;
}
}
previous = matrix[i][j];
previousI = i;
previousJ = j;
}
}
}
return matrix;
}