0% found this document useful (0 votes)
2K views

SQL Module 6 Assignment

This document contains instructions for creating a view that selects customers from San Jose, updating customer records within transactions using rollback, and using try/catch to handle a divide by zero error. It creates a view called "customer_san_jose" with customers from San Jose, updates a customer's first name to Francis within a transaction then rolls back, then updates the same customer's name to Alex within a transaction. It also includes a try/catch block to print the default error message when dividing a number by zero.

Uploaded by

Isha Karnalkar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

SQL Module 6 Assignment

This document contains instructions for creating a view that selects customers from San Jose, updating customer records within transactions using rollback, and using try/catch to handle a divide by zero error. It creates a view called "customer_san_jose" with customers from San Jose, updates a customer's first name to Francis within a transaction then rolls back, then updates the same customer's name to Alex within a transaction. It also includes a try/catch block to print the default error message when dividing a number by zero.

Uploaded by

Isha Karnalkar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Module 6

--1.Create a view named ‘customer_san_jose’ which comprises of only those customers


who are from san jose

create or alter view customer_San_Jose


as
select * from customer where city = 'San Jose'

select * from customer_San_Jose

/*2.2. Inside a transaction, update the first name of the customer to Francis, where
the last name is Jordan
a. Rollback the transaction
b. Set the first name of customer to Alex, where the last name is Jordan
*/

begin transaction
update customer set first_name ='Francis' where last_name='Ivan'
rollback transaction

begin transaction
update customer set first_name ='Alex' where last_name='Ivan'

select * from customer

--3.Inside a try catch block, divide 100 with 0, print the default error message

declare @var1 int


declare @var2 int
begin try
set @var1 = 100
set @var2 = @var1/0
end try
begin catch
print error_message()
end catch

You might also like