Computer Science, asked by umeshgowda84471, 1 month ago

Create a PL/SQL block to insert a new record into department table.Fetch the maximum department id from the Department table and add 10 to ut,take this value for department id; TESTING is the value for department name and CHN-102 is the value for location ID.

Answers

Answered by SINSEHHUA
1

Answer:

Hope this is helpful

Explanation:

Please mark me as brainlist

Attachments:
Answered by sujan3006sl
1

Answer:

create or replace procedure p_ins_dept (par_dname in varchar2, par_loc in varchar2) is

l_deptno number;

begin

select max(deptno)

into l_deptno

from dept;

insert into dept (deptno, dname, loc)

values (nvl(l_deptno, 0) + 10, par_dname, par_loc);

end;

Explanation:

Keep in mind that a multi-user environment is where such a strategy is most likely to fail.

  • When two (or more) users use the process at once.
  • it fetches the MAX department number value
  • adds 10 to it.
  • Insert a row, however the second (and subsequent) users are unable to do so since the main key was violated by the first user, who successfully entered the row..

#SPJ3

Similar questions