Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8645099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:27:45+00:00 2026-06-12T12:27:45+00:00

I need to do the following problem, Write a procedure that decreases the salary

  • 0

I need to do the following problem,

Write a procedure that decreases the salary by a 10% for all employees who earn
less than the current average salary.
Treat the content of table EMP as “all employees”. Have your procedure print the name and salary of the first
person whose salary is just below the average.

What should be the approach to solve the problem?

Write a procedure that decreases the salary by a 10% for all employees who earn less than the current average salary.

CREATE OR REPLACE PROCEDURE UPDATE_EMP IS
BEGIN
UPDATE EMP
SET SAL= SAL-(SAL*0.1) 
WHERE SAL<(SELECT AVG(SAL) FROM EMP);
END;

AND THE OTHER ONE :
Have your procedure print the name and salary of the first person whose salary is just below the average.

SELECT e.ename
     , e.sal
 from 
    (select ename
            , sal 
      from emp 
      where sal < (select avg(sal)  
                     from emp
                   ) 
     order by sal desc 
     )e  
  where ROWNUM =1;

Now I need to connect both.. How could I do that …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:27:47+00:00Added an answer on June 12, 2026 at 12:27 pm

    It sounds like you are a bit fuzzy on what a stored procedure is and how it can help you do complicated tasks involving many SQL statements.

    You follow these directions on how a construct a stored procedure.

    http://www.devshed.com/c/a/Oracle/Oracle-Stored-Procedures/

    Stored procedures are wonderful structures that allow you to put multiple SQL statements into one structure, saving out variables for use in the next SQL statement. So all you have to do is invoke the stored procedure, and all the sql statements are run, and your answer is returned or table modification is committed.

    You need something like this:

    CREATE OR REPLACE PROCEDURE UPDATE_EMP RETURN name, value IS
    BEGIN
    
        UPDATE EMP
        SET SAL= SAL-(SAL*0.1) 
        WHERE SAL<(SELECT AVG(SAL) FROM EMP);
    
        SELECT e.ename INTO name_to_return, e.sal INTO sal_to_return from 
        (select ename, sal from emp where sal < (select 
         avg(sal)from emp) order by sal desc)e   where ROWNUM =1;
    
        RETURN name_to_return, sal_to_return;
    END;
    

    The syntax may be a bit off, when you get it working, post your answer here as a new answer, and check mark it as the answer, and you are much more likely to get help like this in the future.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following problem: I need to write a decorator that would be
Hi i have following Problem. I write a Mediawiki Extension where i need some
I need to write a procedure in assembler, that calculates the value of a
Basically my problem is that I need to write a script that automatically creates
I have the following problem, in near future I will need to write a
I need to perform following steps: Let user write own code - no problem,
I need a regular expression to solve the following problem (links to similar problems
I have the following problem: I need to use XSLFO to generate a 2-column
I'm facing the following problem: in the controller I select the data I need
I would really appreciate any help with the following problem: I need to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.