Skip to content
Advertisement

ORA-10400 error in PL/SQL, cannot auto generate tran_no field in table using procedure

T_Acc_Details is a table for storing the account number details of a person with the given fields.

I have also inputted values into the field like the following:

Secondly, I created the Transaction details table in which the values are to be inserted on the basis of it being deposit or withdrawal. The table query is as follows:

Furthur, this is my procedure. Here, I have taken acc_no, amount, tran_type as paramters and taken current balance from balance amount and tran_no as variables. I am trying to write the logic for deposit portion. Also, autogenerating value for tran_no.

As soon as I try to test the code and run, the insert into T_Tran_Details(.. gives rise to this error. How are the values even null? I have taken tran_no as primary key.

error

Advertisement

Answer

I have found your problem, so this line:

generates a null value bcs your table is empty, when u simply write:

u get a null value in the max column.

To generate new tran_no try using a sequence or like this:

So your whole code would look like this:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement