내 저장 프로 시저에는 4 개의 매개 변수가 있습니다. 입력 문자열 3 개와 출력 문자열 1 개입니다.
using (OdbcConnection cn = ODBC.Instance.AmulibConnection)
{
cn.Open();
using (OdbcCommand cm = cn.CreateCommand())
{
cm.CommandText = "CALL RET_IMPL_STS('?','?','?','?')";
cm.CommandType = CommandType.StoredProcedure;
cm.Parameters.Add("@P1", OdbcType.Char).Value = "1";
cm.Parameters["@P1"].Size = 1;
cm.Parameters["@P1"].Direction = ParameterDirection.Input;
cm.Parameters.Add("@P2", OdbcType.Char).Value = "ABC";
cm.Parameters["@P2"].Size = 15;
cm.Parameters["@P2"].Direction = ParameterDirection.Input;
cm.Parameters.Add("@P3", OdbcType.Char).Value = "DEF";
cm.Parameters["@P3"].Size = 6;
cm.Parameters["@P3"].Direction = ParameterDirection.Input;
cm.Parameters.Add("@P4", OdbcType.Char);
cm.Parameters["@P4"].Size = 5;
cm.Parameters["@P4"].Direction = ParameterDirection.Output;
cm.Prepare();
cm.ExecuteNonQuery();
string result = cm.Parameters["@P4"].Value.ToString();
return result;
}
}
다음과 같은 오류가 발생합니다.
추가 정보 : 오류 [HY000] [IBM] [System i Access ODBC 드라이버] [i5 / OS 용 DB2] SQL0469-IN, OUT 또는 INOUT이 * N의 RET_IMPL_STS 프로 시저에서 매개 변수 4에 유효하지 않습니다.
출력 매개 변수의 올바른 구문은 무엇입니까?
다음은 두 가지 가능한 옵션입니다.
매개 변수가 문자열 인 경우에도 따옴표를 제거해야합니다.
cm.CommandText = "RET_IMPL_STS (?,?,?,?) 호출";
그런 다음 각 4 개의 매개 변수를 지정해야합니다.
다음 구문도 잘 작동합니다.
cm.CommandText = string.Format ( "CALL RET_IMPL_STS ( '{0}', '{1}', '{2}',?)", STIDAD, ITNOAD, ITRVAD);
이 경우 출력 매개 변수 만 지정하면됩니다. 이러한 형식에서는 문자열 매개 변수에 따옴표가 필요합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다