Answered Questions

  • Can we call a function in sql query and what are the pre requisites to call a function in sql query?

    Star Read Best Answer

    Editorial / Best Answer

    Answered by: Jayakumar M

    • Nov 8th, 2005


    Yes. We can call Functions from SQL statements.

    To be callable from SQL statements, a stored function must obey the following

    "purity" rules, which are meant to control side effects:

     When called from a SELECT statement or a parallelized INSERT, UPDATE, or

    DELETE statement, the function cannot modify any database tables.

     When called from an INSERT, UPDATE, or DELETE statement, the function

    cannot query or modify any database tables modified by that statement.

     When called from a SELECT, INSERT, UPDATE, or DELETE statement, the

    function cannot execute SQL transaction control statements (such as COMMIT),

    session control statements (such as SET ROLE), or system control statements

    (such as ALTER SYSTEM). Also, it cannot execute DDL statements (such as

    CREATE) because they are followed by an automatic commit.