What is the syntax for creating a function?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

What is the syntax for creating a function?

Rating:

Following is the syntax for creating a function:

CREATE [OR REPLACE] FUNCTION function_name
[(parameter [mode] datatype, parameter [mode] datatype, ......)]
RETURN datatype
IS | AS
PL/SQL block;


where,

  • OR REPLACE option indicates that if the function already exists, it will be dropped and replaced with the new version created by the statement.

  • function_name specifies the name of the function.

  • parameter specifies the name of a PL/SQL variable whose value is passed to the function.

  • mode specifies the parameter mode. Only IN parameter mode should be declared.

  • datatype specifies the datatype of the parameter.

  • RETURN datatype specifies the datatype of the return value that must be outputted by the function. It must not include a size specification.

  • PL/SQL block is the procedural body that defines the action performed by the function. It starts with either BEGIN or the declaration of local variables and ends with either END or END function_name. There must be at least one RETURN (expression) statement in the PL/SQL block. Host or bind variables cannot be referenced in the PL/SQL block of a stored function.

  • Rating:



    Other articles

    Click here to Article home

     
    uCertify.com | Our Company | Articles | Privacy | Security | Contact Us | News and Press Release | uCertify India
    MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
    Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
    © 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.