How can I count the number of characters in a LONG data type field?

How can I count the number of characters in a LONG data type field?
Answer: It doesn't appear that you can find the length of a LONG field in SQL. However, you can use PLSQL code to determine the length of a LONG field.
Here is an example of a function that returns the length of the LONG field called SEARCH_CONDITION. This function accepts the primary key values (owner and constraint_name fields) and returns the length of the SEARCH_CONDITION field for the selected record.
CREATE or REPLACE function Find_Length
( av_owner varchar2, av_cname varchar2)
RETURN number
IS
long_var LONG;
BEGIN
SELECT SEARCH_CONDITION INTO long_var
FROM ALL_CONSTRAINTS
WHERE owner = av_owner
AND constraint_name = av_cname;
return length(long_var);
END;

No comments: