Oracle Deterministic Keywords

Source: Internet
Author: User

See deterministic many times, have been very puzzled, today did an experiment. We cheat Oracle to say it is a deterministic function, which is called only once in SQL. If you do not use deterministic, you can see that the values are different. After using deterministic, different sessions come out with the same value.

sql> Create or Replace function f_t (i_p int) return number deterministic is
I_RTN number;
Begin
I_RTN: = i_p * Dbms_random.value (1,10);
return I_RTN;
End
/
The function has been created.

Sql> Select level,f_t (1) from DUAL CONNECT by level<=10;
Level f_t (1)
---------- ----------
1 2.55732959
2 2.55732959
3 2.55732959
4 2.55732959
5 2.55732959
6 2.55732959
7 2.55732959
8 2.55732959
9 2.55732959
10 2.55732959
10 rows have been selected.

sql> Create or Replace function f_t (i_p int) return number is
I_RTN number;
Begin
I_RTN: = i_p * Dbms_random.value (1,10);
return I_RTN;
End
/
The function has been created.

Sql> Select level,f_t (1) from DUAL CONNECT by level<=10;
Level f_t (1)
---------- ----------
1 8.48649118
2 8.9396978
3 2.2786135
4 5.29205905
5 5.32847713
6 8.70095819
7 6.20471031
8 2.00101537
9 3.53814265
10 3.64991086
10 rows have been selected.

Oracle Deterministic Keywords

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.