I want to find a constraint in Oracle SQL that has a certain search_condition. Something like this:
SELECT constraint_name, constraint_type,search_condition
FROM USER_CONSTRAINTS
WHERE table_name ='MYTABLE' AND search_condition = '"myColumn" IS NOT NULL';
Problem is i get error "Ilegal use of datatype LONG".
I'd appreciate a working alternative. Thanks!
Amend the second half of your WHERE clause as follows
SUBSTR(search_condition, 1, 21) = 'whatever you're after'
search_condition is a LONG datatype and that rather limits what you can do with it. the last parameter of the SUBSTR gives the length of the string returned so amend that as needed.
Amended as I'd forgotten the restriction on WHERE clauses, basically create a PL/SQL function to do the above and use that in your WHERE clause,
For example
FUNCTION get_long_16(pFormID NUMBER, pSectionItemID NUMBER, pSequence NUMBER)
RETURN VARCHAR2
AS
l_data LONG;
BEGIN
SELECT far.text_answer
INTO l_data
FROM form_answers_repeating far
WHERE far.form_id = pFormID
AND far.section_item_id = pSectionItemID
AND far.sequence = pSequence;
RETURN SUBSTR(l_data, 1, 16);
END;
As used here....
use
describe USER_CONSTRAINTS ;
to see that search_condition is of type LONG.
On Oracle 12 :search_condition_vc would be the solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With