Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I would like to validate removing record from table checking its primary key for integrity constraint violation.

I've created a function returning boolean with the following code:

DECLARE
    n NUMBER;

BEGIN
    SELECT count(*) INTO n
    FROM table_name
    WHERE smth_id = :ID;

    IF n > 0 THEN
        RETURN FALSE;
    ELSE
        RETURN TRUE;
    END IF;
END;

The request is correct, I confirmed it putting real ID instead of :ID, like WHERE smth_id = 105. So it seems to me the problem is in the :ID expression exactly.

Can you advise, how to get the ID of the selected row in function? My code has condition "When Button Pressed - MULTI_ROW_DELETE" and I have ID column on table page.

share|improve this question
    
Can you please create an example page on apex.oracle.com ? It's really hard to help with APEX questions without a working example. –  Phil Jul 3 '12 at 9:32
    
Thank you replying, Phil. Can I create a schema with some tables there? –  Kremchik Jul 3 '12 at 10:07
    
I need to show an example of integrity constraint violation while removing a row from a table. –  Kremchik Jul 3 '12 at 10:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.