Update DBMS/SQL/Week6/writeup.md
This commit is contained in:
		
							parent
							
								
									7fea142b7a
								
							
						
					
					
						commit
						f80463ae74
					
				
					 1 changed files with 5 additions and 30 deletions
				
			
		|  | @ -1,31 +1,4 @@ | |||
| ### 2. Generate a trigger displaying driver information, on participating in an accident | ||||
| 
 | ||||
| ```SQL | ||||
| SQL>    create or replace trigger driver_info | ||||
|         after insert on participated | ||||
|         for each row | ||||
|         declare | ||||
|             id varchar2(4);         | ||||
|             nam varchar2(10);       | ||||
|             addr varchar2(30);      | ||||
|         begin | ||||
|             select "driver_id#", name, address | ||||
|             into id, nam, addr | ||||
|             from person | ||||
|             where :new."driver_id#" = person."driver_id#";  | ||||
|             dbms_output.put_line('driver_id: ' || id || ' name: ' || nam || ' address: ' || addr); | ||||
|         exception | ||||
|             when no_data_found then | ||||
|                 dbms_output.put_line('no driver found for driver_id: ' || :new."driver_id#"); | ||||
|             when others then | ||||
|                 dbms_output.put_line('an error occurred: ' || sqlerrm); | ||||
|         end; | ||||
|         / | ||||
| 
 | ||||
| Trigger created. | ||||
| ``` | ||||
| 
 | ||||
| ### 3. Create a function to return total number of accidents happened in a particular year. | ||||
| ### 1. Create a function to return total number of accidents happened in a particular year. | ||||
| 
 | ||||
| ```SQL | ||||
| SQL> create or replace function total_accd | ||||
|  | @ -51,7 +24,7 @@ TOTAL_ACCD(2024) | |||
|                2 | ||||
| ``` | ||||
| 
 | ||||
| ### 4. Create a procedure to display total damage caused due to an accident for a particular driver on a specific year. | ||||
| ### 2. Create a procedure to display total damage caused due to an accident for a particular driver on a specific year. | ||||
| ```SQL | ||||
| create or replace procedure tot_damage | ||||
|   (driver in varchar2, year in number) is | ||||
|  | @ -79,7 +52,7 @@ Total damage: 150 | |||
| PL/SQL procedure successfully completed. | ||||
| ``` | ||||
| 
 | ||||
| ### 5. Create a procedure to display accident information which took place in a particular location. | ||||
| ### 3. 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 | ||||
|  | @ -98,3 +71,5 @@ Report Number: 1, Date: 01-JAN-24, Location: Delhi India | |||
| PL/SQL procedure successfully completed. | ||||
| ``` | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Aadit Agrawal
						Aadit Agrawal