나는 어떻게이 일을하는지, 나는 전에 그것을 실제로 해냈다. 그러나 다음 코드는 아래의이 update 문에서 예외를 던지지 않는다. 그리고 나는 그 이유를 알지 못한다. 왜 누군가는 볼 수 있습니까?업데이트 쿼리를 실행하는 방법?
나는 중요하다고 생각하지 않지만 id
은 Person
의 기본 키이고 belongs
은 외래 키입니다.
가장 좋은 동시성 문제가 발생하기 전에 나는 해당 테이블에서 작업하는 유일한 사람입니다. 명령의 생성은 그렇게이다
는public static String upDatePersonBelonging(Int32 personId,Int32 groupId)
{
String error;
if ((error = openConnection()) != "")
return error;
OracleCommand command =
new OracleCommand("UPDATE person SET belongs = :belongs where id = :id ",
connection);
addParameter(command, "belongs", OracleDbType.Int32, groupId);
addParameter(command, "id", OracleDbType.Int32, personId);
return runCommand(command);
}
실행 그래서이다
private static String openConnection()
{
try
{
// create an open the connection
connection = new OracleConnection(_connStr);
// open the connection
connection.Open();
}
catch(Exception e)
{
return e.Message;
}
return "";
}
추가 파라미터 코드 :
private static void addParameter(OracleCommand command, String name, OracleDbType type, Object value)
{
command.Parameters.Add(name, type);
command.Parameters[command.Parameters.Count-1] = new OracleParameter(name, value);
}
private static String runCommand(OracleCommand command)
{
String error = "";
try
{
command.ExecuteNonQuery(); // here it hangs
}
catch (Exception e)
{
error = e.Message;
}
finally
{
connection.Close();
}
return error;
}
개구 함수는 다음과 같다
당신이 (당신의 연결 문자열에서와 동일한 사용자로 로그온) SQLPLUS를 사용하여 테이블을 업데이트 할 수 있습니다 : - 차라리 이런 걸 (I가 가능성이 없어 테스트)를 시도 할 것이다? – paul
코드를 디버깅 했습니까? –
예 SQLDevloper 및 SQL Plus에서 테이블을 업데이트 할 수 있습니다. 그리고 네, 디버깅을하고 거기에 매달려, 더 이상 보여주지 않습니다. 마치 무한 루프에 빠지듯이. –