Oracle Custom Functions

Source: Internet
Author: User

One, custom function creation syntax format:Create [or replace] functionFunction_name/*Function Name*/(/*parameter Definition section*/parameter_name1 model1 dataType1, parameter_name2 model2 dataType2, Parameter_name3 model3 da     TaType3, ...) returnReturn_datatype/*defining return value types*/     is/ as    [local_declarations]/*declaring temporary variables*/    BEGINfunction_body/*function Body Part*/           returnScalar_expression/*Return Statement*/    ENDfunction_name; Parsing:or Replace: Overwrite, optional function_name: function namereturnpose: Specifies the return type of the function, cannot specify size local_declarations: local variable declaration, optional function_body: pl to be executed-There are 3 types of SQL statement parameters (if not noted, the default type of the parameter is in)inch: For read-only mode, in a function, the value of the parameter can only be referenced and cannot be changed out: write-only mode, can only be assigned, cannot be referencedinchOut: Readable and writable Example 1:--Query organization name by agency number    CREATE OR REPLACE FUNCTIONGet_org_name (p_org_idinch  Number)RETURN VARCHAR2  isV_org_nameVARCHAR2(4000); BEGIN         SELECTOrg_name intoV_org_name fromsys_orgWHEREorg_id=p_org_id; RETURN(V_org_name); ENDGet_org_name;
the calling method of the custom function call custom function is the same as the    call method of the system built-in function, can be called directly in the SELECT statement, or can be called    in the function as follows:Select get_org_name ( from sys_org;     str :=get_org_name (+); Delete Custom Function Delete    method similar to table delete, syntax format is as follows:     Dropfunction[schema. ]functionname;

Oracle Custom Functions

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.