layed in the results as in the following figure.
GenrelD
GenreName
NumberOfMaleMembers NumberOfFemaleMembers
1
1
Science Fiction
6
2
2
2
Fantasy
4
1
3
3
Mystery
3
2
4
4
Thriller
0
0
5
5
Romance
9
7
6
6
Historical Fiction 1
4
7
7
Biography
2
1
8 8
Horror
2
1
9
9
Adventure
4
3
10 10
Poetry
4
2
Picture 7.1
Question 8:
Create a stored procedure named insertMember with @memberID int, @memberNamenvarchar(100), @address nvarchar(200), @email nvarchar(100), @sex nvarchar(20),@birthDate date as input parameters of the procedure. The stored procedure attempts to insert a new member into the table Members, but only if a member with the same MemberID does not already exists:
- if a member with MemberID = @memberID already exists, the procedure does nothing.
- if there is no member with MemberID = @memberID, the procedure will insert into the table Members a new row with @memberID, @memberName, @address, @email, @sex and @birthDate as values for its attributes.
For example, when we execute the insertMember procedure with input values as in the following statement, a new member with the corresponding values will be inserted into the table Members:
execute insertMember
@memberID = 50,
@memberName='John Smith',
@address=null,
@email='
[email protected]",
@sex='Male',
@birthDate='1989-10-14';
But when we run the following statement to execute the insertMember procedure, the command completed successfully but no row will be inserted into the table Members because a member with MemberID = 2 already exists in the table.
Zoom
+ 75%
Close