adspace


Can we call dml statement in function?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

what are all the common sql function? : Sql dba

1131


how to use regular expression in pattern match conditions? : Sql dba

1113


what is collation? : Sql dba

1229


define sql insert statement ? : Sql dba

1098


what is dbms? : Sql dba

1061


how to escape special characters in sql statements? : Sql dba

1114


Do we need to rebuild index after truncate?

1138


What is your daily office routine?

2346


what are aggregate and scalar functions? : Sql dba

1129


what is sql server agent? : Sql dba

1182


Can we use distinct and group by together?

1133


Does group by remove duplicates?

1112


how to start mysql server? : Sql dba

1267


what are the advantages of sql ? : Sql dba

1142


Is primary key clustered index?

1019