Can we call dml statement in function?



Can we call dml statement in function?..

Answer / Dheeraj Kumar Jha

Yes, DML (Data Manipulation Language) statements can be called inside functions in PL/SQL. Here's an example of a simple function that performs an INSERT statement:

CREATE OR REPLACE FUNCTION insert_record(p_column1 VARCHAR2, p_column2 NUMBER) RETURN NUMBER AS
v_return NUMBER;
BEGIN
INSERT INTO table_name (column1, column2) VALUES (p_column1, p_column2);
COMMIT; -- Assuming AUTOCOMMIT is OFF.
SELECT LAST_INSERT_ID INTO v_return FROM dual;
RETURN v_return;
END;/

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

What is PL/SQL Records?

1 Answers  


how to drop an existing table in mysql? : Sql dba

1 Answers  


Mention what does plvtab enables you to do when you showthe contents of pl/sql tables?

1 Answers  


What is rtm in testing?

1 Answers  


package specification-3 procedures package body-4 procedures how can i write for other procedure in package body

2 Answers   Reliance,


Describe the Index, Types of index, At what situation we have used? Which one s better than others?

1 Answers   IBM, TCS,


What is oracle sql called?

1 Answers  


What is the difference between UNIQUE CONSTRAINT and PRIMARY KEY? 1. There is no difference. 2. A PRIMARY KEY cannot be declared on multiple columns. 3. A UNIQUE CONSTRAINT cannot be declared on multiple columns. 4. A table can have multiple PRIMARY KEYS but only one UNIQUE CONSTRAINT. 5. A table can have multiple UNIQUE CONSTRAINTs but only one PRIMARY KEY.

7 Answers   Satyam,


Which join is like an inner join?

1 Answers  


what is a join? : Sql dba

1 Answers  


What is a loop in sql?

1 Answers  


How to display the contents of a current record fetched in a reference cursor?

2 Answers  


Categories