Oracle stored procedure Note --- DUAL

Source: Internet
Author: User

Oracle stored procedure Note-DUAL in oracle, we sometimes need to determine whether a string contains a string. First, oracle provides us with the instr function: instr (string1, string2 [, start_position [, nth_appearance]) parameter analysis: string1, source string, to be searched in this string. String2: string to be searched in string1. Start_position: Position of string1. This parameter is optional. If omitted, the default value is 1. The string index starts from 1. If this parameter is positive, it is retrieved from left to right. If this parameter is negative, from right to left, the start index of the string to be searched in the source string is returned. Nth_appearance: indicates the number of string2. this parameter is optional. If omitted, the default value is 1. If it is negative, an error is returned. NOTE: If String2 is not found in String1, The instr function returns 0. with this function, how can we use it? At this time, dual takes effect. We can do this: select instr ("xxxxxx", "xxx") from dual. so what is dual? Dual is a virtual table used to form the select syntax rule. oracle ensures that there will always be only one record in dual. We can use it to do many things. For example, we can use dual when we need a function. Dual is a virtual table used to form the select syntax rule. oracle ensures that there will always be only one record in dual. We can use it to do a lot of things, as shown below: 1. To view the current user, you can execute the following statement select user from dual in SQL Plus; 2. It is used to call the system function select to_char (sysdate, 'yyyy-mm-dd hh24: mi: ss') from dual; -- Obtain the current system time select SYS_CONTEXT ('userenv', 'terminal') from dual; -- Obtain the host name from dual; -- Obtain the current locale select dbms_random.random from dual; -- obtain a random number 3. Obtain the next value or current value of the sequence. Use the following statement to select your_sequence.nextval from dual; -- Obtain the next value of the sequence your_sequence select your_sequence.currval from dual; -- Obtain the current value of the sequence your_sequence. 4. You can use the calculator select 7*9 from dual;

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.