PL/SQL Insert

610 pts.
Tags:
INSERT statement
ORA-01400
Oracle development
Oracle error messages
PL/SQL
PL/SQL procedure
Hi Experts, I am trying to do 2 INSERT stms on 2 tables consecutively n same transaction and my first insert is successful while doing the insert on second table which is completely carry same set of attibutes and values of 1st table + 1 additional static value attribute,it gives ORA :01400 error for primary key attribute. Even in 1st table in Insert statement i did not include the primary key attibute and its value I did all trial and errors still showing the below error o nly i am wondering why this error s poping if the INSERT is successful for 1st table please guide me

Answer Wiki

Thanks. We'll let you know when a new response is added.

ORA-01400 is raised when you try to insert null into a column that is part of a primary key, or a column that was defined as NOT NULL when the table was created.

“Even in 1st table in Insert statement i did not include the primary key attibute and its value ”
That is not possible. Primary key columns cannot contain nulls.

Are you sure the primary key is constructed with the same columns in both tables ?
Can you post the results of a ‘describe’ for both tables here ?

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Inprise
    Hi, "Even in 1st table in Insert statement i did not include the primary key attibute and its value " this is true as hav trigger set to take next val.. each time before each row INSERT and same is not available in 2nd table However 2nd table inserting record after 1st table update statement as it reference the pk from 1st table ,howver the Insert on 2nd table failing after 1 st table insert ,it looks strange with latter case Still i am working on root cause-- yes primary key is constructed with the same columns in both tables . Please guide me what could be the reason for this behaviour.
    610 pointsBadges:
    report
  • carlosdl
    If the trigger is not available for the 2nd table, you need to include all non-nullable columns in your insert statement. Since the error is ora-01400, there is no relation between the insert to the 2nd table and any previous updates/inserts to the first table, unless you are doing an INSERT-SELECT. We would need to see your code and your table structure to be able to provide more help. I would recommend to add the necessary code to display the values of all of the variables corresponding to a non-nullable column in the insert statement (just before the insert), to see which is the one that is null, and thus causing the error.
    69,045 pointsBadges:
    report
  • Dwaltr
    The other thing I would look at, is that since the primary key is apparently being created via a trigger, look at that code and see how it is down. Use that methodology (ie. sequence, or calculation) put it in your procedure and store it in a variable. That way you can use the same value for the insert into both the first and second tables. Make sure the 1st table trigger only creates the primary key value if the primary key column is null.
    900 pointsBadges:
    report
  • Inprise
    i got this to work now by passing the primary key value in select statement before insert on 2nd table thanks for all your suggestions and answers
    610 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following