diff --git a/DBMS/SQL/Week6/writeup.md b/DBMS/SQL/Week6/writeup.md index 36ce1ac..bc390fa 100644 --- a/DBMS/SQL/Week6/writeup.md +++ b/DBMS/SQL/Week6/writeup.md @@ -77,4 +77,24 @@ SQL> execute tot_damage('1236',2024); Total damage: 150 PL/SQL procedure successfully completed. -``` \ No newline at end of file +``` + +### 5. Create a procedure to display accident information which took place in a particular location. + +```SQL +SQL> create or replace procedure accident_info(location_value in varchar) IS + begin + for accident_rec in + (select * from accident where location = location_value) loop + dbms_output.put_line('Report Number: ' || accident_rec.report_number || ', Date: ' || accident_rec.accd_date || ', Location: ' || accident_rec.location); + end loop; + end; + / +``` +```sql +SQL> execute accident_info('Delhi India'); +Report Number: 1, Date: 01-JAN-24, Location: Delhi India + +PL/SQL procedure successfully completed. +``` +