私の知識不足を許してください。から挿入関数を呼び出そうとしていますsqlnavigator
。をキャプチャできますが、sqlnavigator のパッケージ仕様から (以下の SQL を参照)prm1.Value
を含める方法がわかりません。RETURN NUMBER
実行すると、ORACLE には何も追加されません。
Public Shared Function INSERT_CATEGORY()
Dim cmdOraCommand As New OracleCommand
Try
cmdOraCommand.CommandType = CommandType.StoredProcedure
cmdOraCommand.CommandText = "SF_ALEX_TEST.insertCategory"
Dim prm1 As OracleParameter = cmdOraCommand.Parameters.Add( _
"inCategory", OracleType.VarChar)
prm1.Direction = ParameterDirection.Input
prm1.Value = strCategory
Catch ex As Exception
MsgBox(ex.Message)
Finally
cmdOraCommand.Dispose()
End Try
End Function
SQL/オラクル
FUNCTION insertCategory(inCategory IN VARCHAR2) RETURN NUMBER
IS
vReturnedValue NUMBER;
vID NUMBER;
vExist NUMBER;
BEGIN
IF inCategory IS NULL THEN
vReturnedValue := 0;
RETURN vReturnedValue;
ELSE
BEGIN
SELECT COUNT(MNT_CATEGORY) INTO vExist
FROM MNT_CATEGORIES
WHERE MNT_CATEGORIES.MNT_CATEGORY = upper(inCategory);
END;
IF vExist = 0 THEN
BEGIN
SELECT SEQ_MNT_LOG.NEXTVAL INTO vID FROM DUAL;
INSERT INTO MNT_CATEGORIES(MNT_CATEGORY_ID, MNT_CATEGORY)
VALUES (vID, UPPER(inCategory));
COMMIT;
vReturnedValue := vID;
RETURN vReturnedValue;
EXCEPTION
WHEN OTHERS THEN
vReturnedValue := SQLCODE;
RETURN vReturnedValue;
END;
ELSE
vReturnedValue := vExist * -1;
RETURN vReturnedValue;
END IF;
END IF;
END;