DB2
db2와 oracle에서 프로시저 호출하기
시반
2006. 6. 5. 19:47
======== oracle =========
try
{
int age = 39;
String poetName = "dylan thomas";
CallableStatement proc = connection.prepareCall("{ call set_death_age(?, ?) }");
proc.setString(1, poetName);
proc.setInt(2, age);
cs.execute();
}
catch (SQLException e)
{
// ....
}
{
int age = 39;
String poetName = "dylan thomas";
CallableStatement proc = connection.prepareCall("{ call set_death_age(?, ?) }");
proc.setString(1, poetName);
proc.setInt(2, age);
cs.execute();
}
catch (SQLException e)
{
// ....
}
======== DB2 =========
try
{
int age = 39;
String poetName = "dylan thomas";
CallableStatement proc =
{
int age = 39;
String poetName = "dylan thomas";
CallableStatement proc =
connection.prepareCall(" call set_death_age(cast(? as INT), cast(? as VARCHAR(20)) ");
proc.setString(1, poetName);
proc.setInt(2, age);
cs.execute();
}
catch (SQLException e)
{
// ....
}
오라클에서 잘 돌아가던 프로시저 호출 구문이 DB2에서 에러를 토해낼때
1. 파라미터 타입을 일치시켜라(예: cast(? as INT))
2. { } 부분을 삭제하라(그 이유는 아직도 잘.. 빼니 돌아갑니다.. (__ )a )