First i created a simple function to get the next available dept_id.Then i created a procedure in order to insert the data in to emp and dept tables.
Below is my procedure:
create or replace procedure sampleSP
(ename in varchar2,
sal in number,
x:=getDept; //Function to get the deptid
insert into dept values(x,dname);
insert into emp values(ename,sal,x);
Procedure created successfully.
sampleSP('Admin','X',1500); //I am not inserting the dept value since i am using the function to get the id in the procedure
Getting an error fk violation error for employee deptid while running the procedure.Let me know where i am doing wrong.