zoukankan      html  css  js  c++  java
  • .Net Core 调用Oracle 存储过程

    安装nuget包

    Oracle.ManagedDataAccess.Core

    注意

    ParameterDirection.InputOutput 输入输出参数
    参数最好指定长度
                try
                {
                    var constr = GetConfig("OracleConn");
                    using var con = new OracleConnection(constr);
                    con.Open();
    
                    // Call stored procedure
                    var odbcCommand = con.CreateCommand();
                    odbcCommand.CommandText = "SP_";
                    odbcCommand.CommandType = CommandType.StoredProcedure;
    
                    var codePara = new OracleParameter("Code", OracleDbType.Varchar2, ParameterDirection.InputOutput)
                    {
                        Value = Code
                    };
                    var TypePara = new OracleParameter("Type", OracleDbType.NVarchar2, 20, null, ParameterDirection.Output);
    
                    odbcCommand.Parameters.Add(codePara);
                    odbcCommand.Parameters.Add(TypePara);
    
                    odbcCommand.ExecuteNonQuery();
    
                    Code = codePara.Value;
                    Type = TypePara.Value;
    
                    // Close and Dispose OracleConnection
                    con.Close();
                }
                catch (OracleException oex)
                {
                    Code = "";
                    Type = "";
                }
    

      

  • 相关阅读:
    bzoj1711
    bzoj1458
    bzoj1433
    hdu2732
    bzoj1066
    hdu3549
    poj1698
    [ZJOI2007]时态同步
    SA 学习笔记
    [LUOGU]2016 Sam数
  • 原文地址:https://www.cnblogs.com/jhlong/p/14272837.html
Copyright © 2011-2022 走看看