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 6890385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:16:31+00:00 2026-05-27T06:16:31+00:00

I have one requirement as shown below : Suppose we have EMP table with

  • 0

I have one requirement as shown below :

Suppose we have EMP table with 5 rows having deptno = 20 –Here i will get deptno i.e.20 from input paramter

EMPNO   ENAME   JOB       MGR   HIREDATE    SAL     COMM    DEPTNO 
--------------------------------------------------------------------------------
7566    JONES   MANAGER   7839  04/02/1981  2975    -   20 
7788    SCOTT   ANALYST   7566  12/09/1982  3000    -   20 
7902    FORD    ANALYST   7566  12/03/1981  3000    -   20 
7369    SMITH   CLERK     7902  12/17/1980  800     -   20 
7876    ADAMS   CLERK     7788  01/12/1983  1100    -   20 

Now I want to write one UPDATE query in procedure which will update EMP Table
set JOB = ‘MANAGER’ where empno in (7788,7902); — Here empno i.e. 7788 and 7902 i will get from input parameter

My update query Should update JOB = ‘MANAGER’ for 2 rows having deptno = 20
and for rest of 3 rows i want to update will Null values.

So that final output will be as shown below :

EMPNO   ENAME   JOB       MGR   HIREDATE    SAL     COMM    DEPTNO 
--------------------------------------------------------------------------------
7566    JONES             7839  04/02/1981  2975    -   20 
7788    SCOTT   MANAGER   7566  12/09/1982  3000    -   20 
7902    FORD    MANAGER   7566  12/03/1981  3000    -   20 
7369    SMITH             7902  12/17/1980  800     -   20 
7876    ADAMS             7788  01/12/1983  1100    -   20 

So what will be the best way to write this query

  • 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-05-27T06:16:31+00:00Added an answer on May 27, 2026 at 6:16 am

    Try:

    UPDATE emp
       SET job = (CASE empno
                     WHEN 7788
                     THEN 'MANAGER'
                     WHEN 7902
                     THEN 'MANAGER'
                     ELSE NULL
                   END)
     WHERE deptno = 20;
    

    Or

    UPDATE emp
       SET job = (CASE
                     WHEN empno IN (7788, 7902)
                     THEN 'MANAGER'
                     ELSE NULL
                   END)
     WHERE deptno = 20;
    

    Hope this is what you are after…

    EDIT: After your comments about the input coming from a number table type something like this should work:

    CREATE TYPE number_tab
    AS TABLE OF NUMBER
    /
    

    Type Created.

    CREATE OR REPLACE
    PROCEDURE upd_emp (
       p_deptno    IN emp.deptno%TYPE,
       p_empno_tab IN number_tab
    )
    IS
    BEGIN
       UPDATE emp e
          SET e.job = (SELECT (CASE 
                                 WHEN t.column_value IS NULL
                                 THEN NULL
                                 ELSE 'MANAGER'
                                END)
                         FROM TABLE(p_empno_tab) t
                        WHERE t.column_value(+) = e.empno)
        WHERE deptno = p_deptno;
    EXCEPTION
       WHEN others
       THEN
          ...Exception handling code
    END upd_emp;
    /
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one requirement in C. char abc[]=hello; char hello[]=world; Using abc whether we
I have one requirement that i have to place the log file in the
I am developing native iPhone app. I have one requirement that, there are 5
I have one portal with 3 modules inside it, now my requirement is i
i have one database, and it contains some columns. My requirement is that how
I have the requirement of generating UML Diagrams for one of my C++ assignments.
I have the requirement of generating UML Diagrams for one of my C++ assignments.
I have a table x that's like the one bellow: id | name |
In one of requirement we have to make available certain attributes through out the
I have .NET WPF application and one of requirement is that user may select

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.