Editorial / Best Answer
Answered by:
Jayakumar M
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 functioncannot query or modify any database tables modified by that statement.
When called from a SELECT, INSERT, UPDATE, or DELETE statement, thefunction 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 asCREAT
E) because they are followed by an automatic commit.
Can we call a function in sql query and what are the pre requisites to call a function in sql query?
Editorial / Best Answer
Answered by: Jayakumar M
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:
DELETE
statement, the function cannot modify any database tables.cannot query or modify any database tables modified by that statement.
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 asCREAT
E) because they are followed by an automatic commit.Related Answered Questions
Related Open Questions