I have the following Function which I have compiled in SQL Developer without error on an Oracle 11gR2 DB. It's mostly just a test function which will be built upon later on but its purpose is to take in a text value and a category value where text might be Hello and category is French and the result should be Bonjour.
create or replace FUNCTION testTranslate
(
originaltext IN VARCHAR2,
fineoscategory IN VARCHAR2 DEFAULT NULL)
RETURN VARCHAR2
AS
translatedttext VARCHAR2(255) := '';
BEGIN
SELECT distinct tti.translatedtex
INTO translatedttext
FROM toctranslationitem tti,
todomaininstance tdi
WHERE tti.translationty = fineoscategory
AND tti.originaltext = originaltext;
RETURN translatedttext;
END;
I've never used SQL Developer before and I'm just getting to grips with creating functions so I'm not entirely sure how to run this.
I've tried the following:
testTranslate('Hello', 'French');
execute testTranslate('Hello', 'French');
Begin
testTranslate('Hello', 'French');
end;
The first two give me Error 900 invalid SQL Statement and the third one gives me error 6550 testTranslate is not a procedure or is undefined
When I try to debug it in SQL developer I get a separate problem. The script seems to run but I get error message 1422 exact fetch returns more than the requested number of rows. The select statement within the function when run by itself without the distinct after the select returns quite a few values but with the distinct it just returns the one so not sure what this is giving out about.
Any pointers ?