This function cannot be called from a SQL statement: cannot perform a DML operation inside a query : Function Call « Stored Procedure Function « Oracle PL / SQL

Home
Oracle PL / SQL
1.Aggregate Functions
2.Analytical Functions
3.Char Functions
4.Constraints
5.Conversion Functions
6.Cursor
7.Data Type
8.Date Timezone
9.Hierarchical Query
10.Index
11.Insert Delete Update
12.Large Objects
13.Numeric Math Functions
14.Object Oriented Database
15.PL SQL
16.Regular Expressions
17.Report Column Page
18.Result Set
19.Select Query
20.Sequence
21.SQL Plus
22.Stored Procedure Function
23.Subquery
24.System Packages
25.System Tables Views
26.Table
27.Table Joins
28.Trigger
29.User Previliege
30.View
31.XML
Oracle PL / SQL » Stored Procedure Function » Function Call 




This function cannot be called from a SQL statement: cannot perform a DML operation inside a query
 
SQL>
SQL> CREATE TABLE MyTable (
  2    num_col    NUMBER,
  3    char_col   VARCHAR2(60)
  4    );

Table created.

SQL>
SQL>
SQL> CREATE OR REPLACE FUNCTION InsertTemp(
  2    p_Num IN MyTable.num_col%TYPE,
  3    p_Char IN MyTable.char_col%type)
  4    RETURN NUMBER AS
  5  BEGIN
  6    INSERT INTO MyTable (num_col, char_col)
  7      VALUES (p_Num, p_Char);
  8    RETURN 0;
  9  END InsertTemp;
 10  /

Function created.

SQL>
SQL> REM Illegal query
SQL> SELECT InsertTemp(1'Hello')
  2    FROM dual;
SELECT InsertTemp(1'Hello')
       *
ERROR at line 1:
ORA-14551: cannot perform a DML operation inside a query
ORA-06512: at "JAVA2S.INSERTTEMP", line 6


SQL>
SQL>
SQL> drop table MyTable;

Table dropped.

SQL>

 














Related examples in the same category
1.Call function and store the return value to a variable
2.Call function in dbms_output.put_line
3.Use a user-defined function in stored procedure
4.Local Subprograms
5.Calling a Function
6.This function can be called from a SQL statement.
7.Function with insert statement can be called from a DML statement.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.