A blog on SQL , PLSQL , Linux concepts. Interview Questions from different companies. For suggestions and contributions, reach me at sivak36@gmail.com
Sunday, September 25, 2016
Restrictions on Calling Functions from SQL Expressions
Restrictions on Calling Functions from SQL Expressions:
The user-defined PL/SQL functions that are callable from SQL expressions must meet the following
requirements:
• The function must be stored in the database.
• The function parameters must be input parameters and should be valid SQL data types.
• The functions must return data types that are valid SQL data types. They cannot be PL/SQLspecific
data types such as BOOLEAN, RECORD, or TABLE. The same restriction applies to the
parameters of the function.
The following restrictions apply when calling a function in a SQL statement:
• Parameters must use positional notation. Named notation is not supported.
• You must own or have the EXECUTE privilege on the function.
Other restrictions on a user-defined function include the following:
• It cannot be called from the CHECK constraint clause of a CREATE TABLE or ALTER TABLE
statement.
• It cannot be used to specify a default value for a column.
Note: Only stored functions are callable from SQL statements. Stored procedures cannot be called
unless invoked from a function that meets the preceding requirements.
To execute a SQL statement that calls a stored function, the Oracle server must know whether the
function is free of specific side effects. Side effects are unacceptable changes to database tables.
Additional restrictions also apply when a function is called in expressions of SQL statements. In
particular, when a function is called from:
• A SELECT statement or a parallel UPDATE or DELETE statement, the function cannot modify a
database table, unless the modification occurs in an autonomous transaction
• An INSERT... SELECT (but not an INSERT... VALUES), an UPDATE, or a DELETE statement,
the function cannot query or modify a database table that was modified by that statement
• A SELECT, INSERT, UPDATE, or DELETE statement, the function cannot execute directly or
indirectly through another subprogram or through a SQL transaction control statement such as:
- A COMMIT or ROLLBACK statement
- A session control statement (such as SET ROLE)
- A system control statement (such as ALTER SYSTEM)
- Any data definition language (DDL) statements (such as CREATE), because they are
followed by an automatic commit
Note: The function can execute a transaction control statement if the transaction being controlled is
autonomous.
Featured Post
Will the data from Oracle Database be lost after formatting the system in which it is installed?
So Someone asked me a question, Will the data from Oracle Database be lost after formatting the system in which it is installed? Since the ...
Popular Posts
-
Experience Level - 3- 5 Years SQL Questions: Brief about your experience, skills and projects you worked on. 1.Differenfe betw...
-
Data Dictionary tables/Views contain information about the database and its objects. These are automatically created and maintained by oracl...
-
E 1st round Queries on joins, group by , not in, rank , dense rank, decode, case. (for half an hour to write queries ,given different ta...
-
Select * from a where hiredate+60 < sysdate; (here hiredate is non-unique index, so query scanning index range or full table scanning. ...
-
Generate Sequence of Numbers from 1 to N using SQL Query SELECT LEVEL AS ID FROM DUAL CONNECT BY LEVEL <= 20; ...
-
Stages of Processing SQL Statement: SQL statements pass through several stages during their processing: Parsing Binding Executing O...
-
Introduction Both LAG and LEAD functions have the same usage, as shown below. LAG (value_expression [,offset] [,default]) OVER ([quer...
-
About Temporary Tables : Temporary tables are database tables that hold session specific data Each session can only see and modify its o...
-
Parameter Modes in PLSQL procedures and functions are IN , OUT, IN OUT. The differences are as follows.