What's that? the sound of ORA-00001: approaching...
...
FUNCTION key_not_in_table(pkey IN INT) RETURN BOOLEAN
IS
countkey INT;
BEGIN
SELECT count(key) INTO countkey
FROM key_values WHERE key = pkey;
IF countkey > 0 THEN
RETURN FALSE;
END IF;
RETURN TRUE;
END key_not_in_table;
PROCEDURE insert_or_update(pkey IN INT,
pval IN INT)
IS
BEGIN
IF key_not_in_table(pkey) THEN
INSERT INTO key_values
VALUES (key, value, 0);
ELSE
UPDATE key_values
SET value = pval
WHERE key = pkey;
END IF;
END insert_or_update;
No comments:
Post a Comment