sql >> Databáze >  >> RDS >> Oracle

Předání pole do procedury Oracle z c#

  1. Definujte typ pole a proceduru:

    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. Rutina C#:

    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. Importujte soubor CSV do tabulky Oracle pomocí uložené procedury

  2. Export dat ze serveru SQL do Excelu a textového souboru pomocí balíčku SSIS

  3. Časová priorita v Active Record Query

  4. Importujte 'xml' do SQL Serveru