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

Nilai Pengembalian Oracle.DataAccess mengeksekusi non-query (proc tersimpan)

ia mengembalikan -1 untuk prosedur tersimpan terlepas dari tindakan yang dilakukan sp (cukup mudah untuk diuji)

create procedure test1 as 
begin
    null ; --do nothing
end test1 ;
/

create table testtable(a number);
/

create procedure test2 as
begin
    insert into testtable(a) select level from dual connect by level < 5;
end test2  ;
/

create procedure test3 as
begin
    update testtable set a = a-1;
end test3;
/

create procedure test4 as
begin
    delete testtable;
end test4;
/
        static int executeProc(string procName,OracleConnection connection ){
                OracleCommand cmd= new OracleCommand(procName, connection);
                cmd.CommandType = CommandType.StoredProcedure;
                return cmd.ExecuteNonQuery();                   
        }
        static void Main(string[] args)
        {
            Console.WriteLine("what does ExecuteNonQuery return?");
            // Connect
            string connectStr = getConnection();
            OracleConnection connection = new OracleConnection(connectStr);
            connection.Open();
            try{
            Console.WriteLine("test1 =>" + executeProc("test1",connection));
            Console.WriteLine("test2 =>" + executeProc("test2",connection));
            Console.WriteLine("test3 =>" + executeProc("test3",connection));
            Console.WriteLine("test4 =>" + executeProc("test4",connection));
            }
            catch (Exception e){
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("Done");
        }
what does ExecuteNonQuery return?
test1 =>-1
test2 =>-1
test3 =>-1
test4 =>-1
/*
drop table testtable;
drop procedure test1;
drop procedure test2;
drop procedure test3;
drop procedure test4;
*/

referensi:http://download.Oracle .com/docs/cd/E11882_01/win.112/e18754/OracleCommandClass.htm#i998363 http://forums.Oracle.com/forums/thread.jspa?threadID =636182




  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 menyalin atau memperbarui indeks dan batasan tabel dari database yang berbeda?

  2. Menampilkan beberapa nilai kolom dalam satu baris (SQL Oracle)

  3. 6 Cara Memilih Baris Duplikat di Oracle

  4. Selisih Kumulatif

  5. Bagaimana menghubungkan database Oracle 11G menggunakan pengembang SQL dari komputer lain dalam koneksi LAN