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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:21:08+00:00 2026-05-23T22:21:08+00:00

Assume you have the following update: Update table set col1 = func(col2) where col1<>func(col2)

  • 0

Assume you have the following update:

Update table set col1 = func(col2)
where col1<>func(col2)

The func function is evaluated two times for every row, or once for every row?

Thanks,

  • 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-23T22:21:09+00:00Added an answer on May 23, 2026 at 10:21 pm

    This is the kind of situation where some experimentation is useful (this was conducted on 10g). Using the following query, we can tell that normal functions, using the same parameters (in this case, none) will be executed each time they are called:

    select dbms_random.value() from all_tables
    

    This is because Oracle assumes that a function will not return the same value consistently unless you tell it otherwise. We can do that by creating a function using the deterministic keyword:

    CREATE FUNCTION rand_det
       RETURN NUMBER
       DETERMINISTIC AS
    BEGIN
       RETURN DBMS_RANDOM.VALUE ();
    END;
    

    Using this function instead of dbms_random in the first query tells us that the query is being executed only once, despite the many calls. But this only clarifies the select section. What if we use the same deterministic function in both a select and a where clause. We can test that using the following query:

    SELECT rand_det
    FROM   all_tables
    WHERE  rand_det > .5;
    

    You may have to run this several times to see our proof, but, eventually, you’ll see a list of values less than 0.5. This provides us with evidence that even the deterministic function is being executed twice: once for each section it appears in. As an alternative, you can modify our deterministic function as follows, then run the subsequent query, which will reveal 2 lines written to DBMS_OUTPUT.

    CREATE OR REPLACE FUNCTION rand_det
       RETURN NUMBER
       DETERMINISTIC AS
    BEGIN
       DBMS_OUTPUT.put_line ('Called!');
       RETURN DBMS_RANDOM.VALUE ();
    END;
    
    SELECT rand_det
    FROM   all_tables;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume I have the following style table, col1 col2 and col3 have same value
I have an update query like following: update table TABLE1 set COL1 = 'X'
Assume I have the following query: Update LPMBonusReport Set BoxID = (Select ContainerSerialNumber From
Imagine the following sql query: UPDATE MYTABLE SET COL2 = (SELECT COL2 + 1
Let's assume I have the following structure <table> <tr> <td> <input type=text name=name />
I need to perform the following on MySQL/InnoDB. Assume I have a table consists
What is the best way to model the following... Assume I have two objects:
Assume two tables in Oracle 10G TableA (Parent) --> TableB (Child) Every row in
Assume I have the following ; def test(): while 1: a = b time.sleep(60)
Assume I have the following arrays: N = 8 M = 4 a =

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.