Создать таблицу
Вы могли бы предоставить это;)
CREATE TABLE TABLETEST
(
QUERY1 VARCHAR2(2000 CHAR),
RESULT1 NUMBER,
QUERY2 VARCHAR2(2000 CHAR),
RESULT2 NUMBER
);
Sample-Data
Вы должны были предоставить это;)
INSERT INTO TABLETEST VALUES('SELECT 1 FROM DUAL', 0, 'SELECT 2 FROM DUAL', 0);
INSERT INTO TABLETEST VALUES('SELECT 3 FROM DUAL', 0, 'SELECT 4 FROM DUAL', 0);
Выполнить запросы
declare
tmpResult1 NUMBER;
tmpResult2 NUMBER;
begin
FOR i IN (SELECT query1, query2 FROM TABLETEST) -- loop through every row
LOOP
dbms_output.put_line('query1: "' || i.query1 || '"'); -- let's have a look, what we got back from our select
dbms_output.put_line('query2: "' || i.query2 || '"');
EXECUTE IMMEDIATE i.query1 INTO tmpResult1; -- executor out select-statement
EXECUTE IMMEDIATE i.query2 INTO tmpResult2;
dbms_output.put_line('tmpResult1: ' || tmpResult1); -- let's have a look at our results
dbms_output.put_line('tmpResult2: ' || tmpResult2);
UPDATE TABLETEST SET RESULT1 = tmpResult1, RESULT2 = tmpResult2 WHERE QUERY1 = i.query1 AND QUERY2 = i.query2; -- Store the results into the table.
END LOOP;
end;
Результат проверки
SELECT * FROM TABLETEST;