Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7554011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:13:15+00:00 2026-05-30T11:13:15+00:00

I need some advice on a DB I’m working in. I have the DB,

  • 0

I need some advice on a DB I’m working in.

I have the DB, and now I’m working on procedures, functions and triggers (PL/SQL). There are three entities, two of which inherit from the third one (as per the conceptual data model), so that means there are two tables referencing to the third one. I have to simultaneously insert data in the “parent” table and the “children” table, so I thought on making a procedure that inserted in the parent table, and another one that inserted in the child one, which can call the former one.

My problem is, what would happen if I tried to insert to the parent table, and then to the child one, and for some reason I’m inserting data in the child table that doesn’t satisfy the constraints? In other words, despite the constraints, do I still have to verify the input data in the function? What are your suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:13:16+00:00Added an answer on May 30, 2026 at 11:13 am

    It depends.

    Assuming there is a foreign key constraint between the child table and the parent table, if you try to insert a row in the child table using a key that does not exist in the parent table, the INSERT will throw an exception indicating that the constraint was violated. You don’t need to check anything if you simply want the INSERT operation to fail with a constraint violation exception.

    On the other hand, you may want to code validations in order to provide better exceptions to the caller. For example, it’s relatively common that a table will have multiple foreign keys that reference various other tables. It may be beneficial to check whether the parameters are valid so that you can tell the caller more specifically which parameter was invalid.

    If you are asking how to ensure that either both the insert into the parent table and the insert into the child table succeed or that both fail, then you’re talking about how to establish proper transactional boundaries. You’d do something like

    BEGIN
      insert_into_parent( <<list of parameters>> );
      insert_into_child(  <<list of parameters>> );
      commit;
    EXCEPTION
      WHEN others 
      THEN
        rollback;
        RAISE;
    END;
    

    Note that your PL/SQL applications always have to explicitly either commit or rollback. And those transaction control statements should be at the highest level possible. You wouldn’t want to have transaction control statements in the insert_into_parent procedure, for example, because then you could never use the procedure if you wanted more extensive transaction scope.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on databases and now I need some advice's from you guys..
I am working on databases and now I need some advice's from you guys..
Experts - I need some advice in the following scenario. I have a configuration
I have been playing with Compact Framework lately and i need some advice. I
I need some expect advice on how to handle the following:- I have a
I need some advice. I have a web page and want to extend it's
I need some advice with the Java Print API. I have a program that
Need some advice, I'm after a decent process/task manager for Ubuntu. Basically I have
Need some advice again please. This is regarding a single developer shop. I have
I need some advice on a little project im doing. I have a database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.