Welcome Guest, Not a member yet? Register   Sign In
How can I run a committed sql-statement (as a parameter) in a procedure and get the e
#1

I'd want to build a PL/SQL function using a SQL-statement as a parameter. The statement may be DDL, DML, or DCL.
In the console, I want to print the time from the executed statement.

I've got the following code:
Code:
create or replace procedure measureTime (statement  IN varchar2 )AS
--declarations
neededTime INTEGER;
  BEGIN
    dbms_output.enable;
    EXECUTE IMMEDIATE statement
COMMIT;
SELECT ELAPSED_TIME AS neededTime FROM V_$SQL WHERE SQL_TEXT=statement
    dbms_output.put_line('executeTime '|| neededTime);
END measureTime;

I saw an article that says to modify systimestamp - l_start_time to trunc((systimestamp - l_start_time) * 24 * 60 * 60) in seconds. But I'm looking forward to a more straightforward method.
However, it does not work. What's the problem?
Reply


Messages In This Thread
How can I run a committed sql-statement (as a parameter) in a procedure and get the e - by leusiam - 04-30-2023, 09:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB