0% found this document useful (0 votes)
12 views1 page

PLSQL Assignment 1

The document provides a series of PL/SQL block exercises that involve variable declaration, user input, and data manipulation. Tasks include displaying a salary, calculating the area of a rectangle, handling user messages, swapping variable values, retrieving employee counts, and updating employee salaries. Each exercise emphasizes basic PL/SQL syntax and operations within the HR schema's database tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

PLSQL Assignment 1

The document provides a series of PL/SQL block exercises that involve variable declaration, user input, and data manipulation. Tasks include displaying a salary, calculating the area of a rectangle, handling user messages, swapping variable values, retrieving employee counts, and updating employee salaries. Each exercise emphasizes basic PL/SQL syntax and operations within the HR schema's database tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

Write a PL/SQL block to declare a variable named "salary" of type NUMBER and
assign a value of 5000 to it. Display the value of the salary variable.

2. Write a PL/SQL block to declare two variables, "length" and "width", both of
type NUMBER. Assign values of 10 and 5 to the variables, respectively. Calculate
and display the area of a rectangle using these variables.

3. Write a PL/SQL block to declare a variable named "message" of type


VARCHAR2(100). Prompt the user to enter a message and assign it to the variable.
Display the message in uppercase letters.

4. Write a PL/SQL block to declare two variables, "num1" and "num2", both of type
NUMBER. Prompt the user to enter values for num1 and num2. Swap the values of the
variables and display the new values.

5. Write a PL/SQL block to declare a variable named "emp_count" of type NUMBER and
initialize it to 0. Retrieve the count of employees from the HR schema's
"employees" table and assign it to the "emp_count" variable. Display the value of
"emp_count".

6. Create a PL/SQL block to declare a variable named "dept_name" of type


VARCHAR2(50). Prompt the user to enter a department name and assign it to the
"dept_name" variable. Use the HR schema's "departments" table and display the
details of the department entered.

7. Write a PL/SQL block to declare a variable named "avg_salary" of type


NUMBER(10,2). Calculate the average salary of all employees in the HR schema's
"employees" table and assign it to the "avg_salary" variable. Display the value of
"avg_salary".

8. Create a PL/SQL block to declare a variable named "employee_name" of type


VARCHAR2(100). Prompt the user to enter an employee ID and assign it to a bind
variable ":emp_id". Retrieve the name of the employee with the entered ID from the
HR schema's "employees" table and assign it to the "employee_name" variable.
Display the value of "employee_name".

9. Write a PL/SQL block to declare a variable named "new_salary" of type


NUMBER(8,2). Prompt the user to enter an employee ID and a new salary value. Assign
the new salary value to the employee with the entered ID in the HR schema's
"employees" table. Use bind variables ":emp_id" and ":salary". Display a message
indicating the successful update.

You might also like