onhax
onhax

Reputation: 339

Returning a static CLOB from an Oracle Stored Function

I am trying to return a long paragraph from an Oracle Stored Function. I can do this in SQL Server, but I am new to oracle. How do I return long texts, like a User Agreement long paragraphs.

Note that it is only static texts and requires no DMLs.

Upvotes: 0

Views: 1626

Answers (1)

EJ Egyed
EJ Egyed

Reputation: 6084

If your text is going to be over 32767 characters, then you will want to use the CLOB datatype. The DETERMINISTIC clause is added to help with performance since there is no queries in the function, just string concatenation.

CREATE OR REPLACE FUNCTION return_clob
    RETURN CLOB
    DETERMINISTIC
IS
    l_return_value   CLOB;
BEGIN
    l_return_value := 'Some text.';
    l_return_value := l_return_value || ' Some more text.';
    RETURN l_return_value;
END;
/

Upvotes: 1

Related Questions