Knowee
Questions
Features
Study Tools

Create a procedure named 'displayTeamStrength' which accepts an input parameter. The input parameter is 'teamid' with number as its data type. This procedure should display the number of players in that team, number of players got the skill named 'Batsmen' for the given 'teamid'.If the teamid passed as an argument matches with the id of the team in the team table then display the output in the following format:Team Strength------------------------NUMBER of PLAYERS : 13NUMBER of BATSMEN : 6If the teamid given does not matches with the id in the team table,then it throws an 'no_data_found' exception and display 'No Such Team'.Hints:Procedure name : displayTeamStrengthInput parameter : teamidOutput parameter : NA

Question

Create a procedure named 'displayTeamStrength' which accepts an input parameter. The input parameter is 'teamid' with number as its data type. This procedure should display the number of players in that team, number of players got the skill named 'Batsmen' for the given 'teamid'.If the teamid passed as an argument matches with the id of the team in the team table then display the output in the following format:Team Strength------------------------NUMBER of PLAYERS : 13NUMBER of BATSMEN : 6If the teamid given does not matches with the id in the team table,then it throws an 'no_data_found' exception and display 'No Such Team'.Hints:Procedure name : displayTeamStrengthInput parameter : teamidOutput parameter : NA

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution 1

Here is the PL/SQL procedure that you requested:

CREATE OR REPLACE PROCEDURE displayTeamStrength (teamid IN NUMBER) IS
  total_players NUMBER;
  total_batsmen NUMBER;
BEGIN
  SELECT COUNT(*) INTO total_players FROM players WHERE team_id = teamid;
  
  SELECT COUNT(*) INTO total_batsmen FROM players WHERE team_id = teamid AND skill = 'Batsmen';
  
  DBMS_OUTPUT.PUT_LINE('Team Strength');
  DBMS_OUTPUT.PUT_LINE('------------------------');
  DBMS_OUTPUT.PUT_LINE('NUMBER of PLAYERS : ' || total_players);
  DBMS_OUTPUT.PUT_LINE('NUMBER of BATSMEN : ' || total_batsmen);
  
EXCEPTION
  WHEN NO_DATA_FOUND THEN
    DBMS_OUTPUT.PUT_LINE('No Such Team');
END displayTeamStrength;
/

This procedure will first try to count the total number of players in the team with the given teamid. Then it will count the number of players in the same team who have the skill 'Batsmen'. If the teamid does not exist in the players table, the SELECT statements will not return any rows, causing a NO_DATA_FOUND exception to be raised. In this case, the procedure will catch the exception and output 'No Such Team'.

This problem has been solved

Solution 2

Here is the PL/SQL procedure that you requested:

CREATE OR REPLACE PROCEDURE displayTeamStrength (teamid IN NUMBER) IS
  total_players NUMBER;
  total_batsmen NUMBER;
BEGIN
  SELECT COUNT(*) INTO total_players FROM players WHERE team_id = teamid;
  
  SELECT COUNT(*) INTO total_batsmen FROM players WHERE team_id = teamid AND skill = 'Batsmen';
  
  DBMS_OUTPUT.PUT_LINE('Team Strength');
  DBMS_OUTPUT.PUT_LINE('------------------------');
  DBMS_OUTPUT.PUT_LINE('NUMBER of PLAYERS : ' || total_players);
  DBMS_OUTPUT.PUT_LINE('NUMBER of BATSMEN : ' || total_batsmen);
  
EXCEPTION
  WHEN NO_DATA_FOUND THEN
    DBMS_OUTPUT.PUT_LINE('No Such Team');
END displayTeamStrength;
/

This procedure will first try to count the total number of players in the team with the given teamid. Then it will count the number of players in the same team who have the skill 'Batsmen'. If the teamid does not exist in the players table, the SELECT statements will not return any rows, causing a NO_DATA_FOUND exception to be raised. In this case, the procedure will catch the exception and output 'No Such Team'.

This problem has been solved

Similar Questions

The HR department needs to assess the distribution of skills among employees. Write a query to count the number of skills each employee possesses.Table details are given below:The table is created, and the records are already inserted at the backend. The sample records are given below.EMPLOYEE EMPLOYEE SKILLNote:Table names and Field Names are case-sensitive.Input format :The input records are already prepopulated, as given in the problem statement.Output format :The output displays the details of the employee id, employee Name and the number of skills as shown below.Employee_id Employee_Name Number_of_Skills1 John Doe 32 Jane Smith 13 Alice Johnson 04 Bob Miller 05 Eva Davis 16 Michael Clark 07 Sophie Wilson 18 David Lee 19 Megan White 010 Alex Turner 011 Olivia Harris 012 Daniel Brown 0

Write a query that displays the number of players in each state, with FR, SO, JR, and SR players in separate columns and another column for the total number of players. Order results such that states with the most players come first.

Sports Craft Company has organized tournaments in multiple individual sports and invited top ranked players to play. Each tournament comprises of multiple matches in knock out format. Each match is played between two players.Problem Statement: Create the Player table as per information provided below:Column Name Data Type Constraint DescriptionPId INTEGER PRIMARY KEY Unique player Id is mandatory for every playerPName VARCHAR2(20) NOT NULL Player NameRanking INTEGER Player's ranking

There are 2 teams, each having N players. There will be N rounds played between the 2 teams. In every round, a player from team A plays against a player from team B. The more powerful player wins the game. Given the strength of the players of both the teams, you have to find the maximum number of rounds team A can win. Note that a player cannot play more than 1 round.Input FormatFirst line of input contains T - number of test cases. Its followed by 3T lines. The first line contains N - size of the team. The next 2 lines contains N numbers each - strength of the players of team A and team B respectively.Constraints1 <= T <= 5001 <= N <= 100000 <= A[i], B[i] <= 10000Output FormatFor each test case, print the maximum number of rounds team A can win, separated by newline.Sample Input 0341 5 7 4 3 8 2 10 22 3 10 5 33 7 10 5 20 15 Sample Output 0201Explanation 0Test Case 1Player with strength 5 in team A can defeat player with strength 3 in team B.Player with strength 7 in team A can defeat player with strength 2 in team B.Test Case 2No Player in team A can defeat any player in team B.Test Case 3Player with strength 7 in team A can defeat player with strength 5 in team B.

create a structure name teams in the attribute team names and n scores. sort the scores in ascending order

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.