I need to calculate the runtime of a given query in Oracle - the result will eventually be written to a SQL table, so the code must be available to run as a procedure from SQL Server. Please se the script below:
`DECLARE startdate DATE; enddate DATE; runtime INT;
begin startdate := SYSDATE;
select distinct table0.ACCOUNT_RK as ACCOUNT_RK from CI_MART.MA_ACCOUNT_VIEW table0 left join CI_CDM.CI_VIEW_ACCT_RESPONSE_HISTORY table1 on table0.ACCOUNT_RK = table1.ACCOUNT_RK where table1.CAMPAIGN_NM like '%Funeral%' and ( table1.RESPONSE_NM in ('Declined - Call Center', 'Not Interested - Call Center', 'Opt Out - Call Center', 'Taken Up - Call Center'));
enddate := SYSDATE;
runtime := enddate - startdate; SELECT 1 as ServerID, 'SASGRPP2' as ServerName, 'SASGRPP2' as DatabaseName, runtime as RunTime, startdate as When from dual;
END; ` I am getting the error PLS-00428: an INTO clause is expected in this SELECT statement for both select queries. The first query is the query for which the runtime must be calculated and will not always necessarily return one row (in this case it definitely won't), so selecting INTO a variable won't work. Please note that I am NOT a SQL developer, so apologies if my question seems dumb :), but any advice will be greatly appreciated!