Oracle Custom Functions function

Source: Internet
Author: User

Example code:

[SQL]View PlainCopy
  1. CREATE OR REPLACE FUNCTION "My_database"." F_get_user_count_by_depart "
  2. (
  3. Depart_id_val in long
  4. )
  5. return VARCHAR2
  6. Is
  7. User_state varchar (16);
  8. User_count number;
  9. Begin
  10. Select Count (*) into user_count from tb_user_info where depart_id=depart_id_val;
  11. If User_count > 0 Then
  12. user_state:=' users ' under the Department;
  13. Else
  14. user_state:=' No user in the department ';
  15. End If;
  16. return (user_state);
  17. End

Explain:

[SQL]View PlainCopy
  1. CREATE OR REPLACE FUNCTION "database name"." Function name "
  2. (
  3. Parameter one [in, out] type,
  4. Parameter two [in, out] type,
  5. ...
  6. )
  7. return value type
  8. Is
  9. variable one type;
  10. Variable two types;
  11. ... ;
  12. Begin
  13. /* The process of assigning a value to a variable */
  14. return (variable one or variable two or ...);
  15. End

    1. There are two types of arguments, in or out, and you can create functions without parameters;
    2. Multiple parameters are separated by ",", with ";" between multiple variables; Separated

Oracle Custom Functions function

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.