Changes between Version 11 and Version 12 of DatabaseProgramming
- Timestamp:
- 05/23/26 22:07:30 (2 days ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DatabaseProgramming
v11 v12 31 31 $$; 32 32 }}} 33 33 {{{ 34 create or replace procedure finish_shift( 35 in driver_id int4 36 ) 37 language plpgsql as 38 $$ 39 declare 40 num_of_shifts int4; 41 begin 42 if not exists(select user_id from driver where user_id = driver_id) then 43 raise exception 'Driver with id % does not exist', driver_id; 44 end if; 45 46 num_of_shifts := (select count(*) from driver_vehicle where id_driver = driver_id and time_to is null); 47 48 if (num_of_shifts != 1) then 49 raise exception 'Driver has not started a shift'; 50 end if; 51 52 update driver_vehicle 53 set time_to=now() 54 where id_driver = driver_id 55 and time_to is null; 56 commit; 57 end; 58 $$; 59 }}} 34 60 **Процедура за вработување на возач во компанија** 35 61 … … 401 427 402 428 {{{ 403 create or replace procedure public_schema.finish_shift(404 in driver_id int4405 )406 language plpgsql as407 $$408 declare409 num_of_shifts int4;410 begin411 if not exists(select user_id from driver where user_id = driver_id) then412 raise exception 'Driver with id % does not exist', driver_id;413 end if;414 415 num_of_shifts := (select count(*) from driver_vehicle where id_driver = driver_id and time_to is null);416 417 if (num_of_shifts != 1) then418 raise exception 'Driver has not started a shift';419 end if;420 421 update driver_vehicle422 set time_to=now()423 where id_driver = driver_id424 and time_to is null;425 commit;426 end;427 $$;428 }}}429 430 {{{431 429 create or replace procedure create_offer( 432 430 request_id int4, … … 488 486 $$; 489 487 }}} 490 {{{491 create or replace procedure public_schema.finish_shift(492 in driver_id int4493 )494 language plpgsql as495 $$496 declare497 num_of_shifts int4;498 begin499 if not exists(select user_id from driver where user_id = driver_id) then500 raise exception 'Driver with id % does not exist', driver_id;501 end if;502 503 num_of_shifts := (select count(*) from driver_vehicle where id_driver = driver_id and time_to is null);504 505 if (num_of_shifts != 1) then506 raise exception 'Driver has not started a shift';507 end if;508 509 update driver_vehicle510 set time_to=now()511 where id_driver = driver_id512 and time_to is null;513 commit;514 end;515 $$;516 }}}517 488 == Функции и тригери 518 489
