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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:51:58+00:00 2026-05-14T22:51:58+00:00

I have stored-procedure in Oracle database like this: create or replace PROCEDURE EDYTUJ_PRACOWNIKA (PR_IMIE

  • 0

I have stored-procedure in Oracle database like this:

create or replace
PROCEDURE EDYTUJ_PRACOWNIKA
  (PR_IMIE IN VARCHAR2, PR_NAZWISKO IN VARCHAR2, PR_PENSJA IN FLOAT,
  PR_PRZELOZONY IN NUMBER, PR_ODDZIAL IN NUMBER, PRAC_ID IN NUMBER)
AS
tmpPensja FLOAT := 0;
tmpPrzel NUMBER := 0;
BEGIN
  select przelozony into tmpPrzel from pracownik where id = PRAC_ID;
  IF(tmpPrzel IS NOT NULL) THEN
    select pensja into tmpPensja from pracownik where id = tmpPrzel;
    IF(tmpPensja < 1150) THEN
      UPDATE PRACOWNIK SET pensja = 1000 WHERE id = tmpPrzel;
    ELSE
      UPDATE PRACOWNIK SET pensja = pensja - 150 WHERE id = tmpPrzel; (4)
    END IF;
  END IF;

  IF(PR_PRZELOZONY > 0) THEN 
    UPDATE PRACOWNIK SET imie = PR_IMIE, nazwisko = PR_NAZWISKO, pensja = PR_PENSJA, przelozony = PR_PRZELOZONY,
      oddzial = PR_ODDZIAL WHERE id = PRAC_ID; (2)
    select pensja into tmpPensja from pracownik where id = PR_PRZELOZONY;

    IF(tmpPensja > 4850) THEN
      UPDATE PRACOWNIK SET pensja = 5000 WHERE id = PR_PRZELOZONY;
    ELSE
      UPDATE PRACOWNIK SET pensja = pensja + 150 WHERE id = PR_PRZELOZONY; (1)
    END IF;
  ELSE
    UPDATE PRACOWNIK SET imie = PR_IMIE, nazwisko = PR_NAZWISKO, pensja = PR_PENSJA, przelozony = NULL,
      oddzial = PR_ODDZIAL WHERE ID = PRAC_ID; (3)
  END IF;
END;

where przelozony and pensja are columns in pracownik table.

And I have problem that when running procedure with parameters that provide that line marked with “(1)” (there is the same problem with line marked with “(4)”) should be executed that update statement don’t have any effect. What’s more statements in lines marked with “(2)” and “(3)” works fine.

I have no ideas how to fix it. Thank you in advance for your help.

  • 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-14T22:51:59+00:00Added an answer on May 14, 2026 at 10:51 pm

    It’s difficult to read code with foreign table and column names, so I hope I got it right (no offense) – make sure to review carefully though.

    As far as I understand your code, you should be able to remove your temporary variables and do everything in three subsequent update statements (updating different rows). I don’t know what exactly does not work, but if it still does not work after, try to execute the single SQL statements manually and check the results.


    Update pracownik, reduce pensja by 150 but not below 1000 where id = przelozony (prac_id)

    UPDATE pracownik
    SET pensja = LEAST( pensja-150, 1000 )
    WHERE id = ( SELECT przelozony FROM pracownik where id = PRAC_ID );
    

    Update pracownik, set some values, and przelozony.

    UPDATE pracownik
    SET imie = PR_IMIE,
        nazwisko = PR_NAZWISKO,
        pensja = PR_PENSJA,
        przelozony = CASE WHEN PR_PRZELOZONY > 0 THEN PR_PRZELOZONY ELSE NULL END,
        oddzial = PR_ODDZIAL
    WHERE id = PRAC_ID;
    

    Update pracownik if PR_PRZELOZONY > 0, increase pensja by 15, but not above 5000.

    IF(PR_PRZELOZONY > 0) THEN 
        UPDATE pracownik
        SET pensja = GREATEST( pensja + 150, 5000 )
        WHERE id = pr_przelozony;
    END IF;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure that looks like: CREATE PROCEDURE dbo.usp_TestFilter @AdditionalFilter BIT =
I have a stored procedure call that goes like this: using (OracleConnection con =
I have a stored procedure that goes something like this (pseudo code) storedprocedure param1,
I have a stored procedure in Oracle Database 10g where my input is a
I have a stored procedure with parameters in an Oracle database. How do I
I have the following iBatis mapping for an Oracle Stored Procedure that returns a
We have an Oracle database that contains IP addresses stored as decimal integers -
I'm using an Oracle database(10g) which contains a stored procedure called Foo. Foo takes
Referring to How to execute an Oracle stored procedure via a database link ,
I have a JDBC connection to an Oracle database. I create a Statement. The

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.