Oracle
 sql >> Teknologi Basis Data >  >> RDS >> Oracle

Melewati array ke prosedur Oracle dari c #

  1. Tentukan tipe array dan prosedur:

    CREATE or replace PACKAGE Testpackage AS 
      TYPE Areas_t is table of VARCHAR(100) index by BINARY_INTEGER;
      PROCEDURE TESTPROCEDURE(Areas IN Areas_t);       
    END Testpackage; 
    
  2. C# rutin:

    public void InsertQuestion(IEnumerable<string> area_list)
    {
        var connect = new OracleConnection("YOUR CONNECTION STRING");
    
        var command = new OracleCommand("BEGIN Testpackage.Testprocedure(:Areas); END;", connect);
    
        connect.Open();
    
        var arry = command.Parameters.Add("Areas", OracleDbType.Varchar2);
    
        arry.Direction = ParameterDirection.Input;
        arry.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
        arry.Value = area_list.ToArray();
        arry.Size = area_list.Count();
        arry.ArrayBindSize = area_list.Select(_ => _.Length).ToArray();
        arry.ArrayBindStatus = Enumerable.Repeat(OracleParameterStatus.Success, area_list.Count()).ToArray();
    
        command.ExecuteNonQuery();
    
        connect.Close();
    }
    



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Bagaimana cara mengecilkan tablespace temp di Oracle?

  2. RTRIM() Fungsi di Oracle

  3. Fungsi TO_CHAR(angka) di Oracle

  4. Memparalelkan panggilan dalam PL/SQL

  5. Bagaimana cara meningkatkan buffer dbms_output?