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:

    n NUMBER;

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

    IF n > 0 THEN
        RETURN TRUE;
    END IF;

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

closed as unclear what you're asking by Colin 't Hart, Vérace, RolandoMySQLDBA, Paul White, Max Vernon Jun 22 at 17:31

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the 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

Browse other questions tagged or ask your own question.