Furkan Ayık Furkan Ayık - 3 months ago 6
SQL Question

Pl-Sql About getting and inserting data with Using Loop

I have created a procedure but i couldnt do what i want to do. I want to use 2 loop nested.

FOR i IN (SELECT *
FROM AUDITCONFG_RANDOMQUESTIONS
WHERE AUDIT_ID=audit_id)
LOOP


This one for getting specific data(for ex. Audit_id=51 's data) I want to get that querys column for each row. How could i do?

-I'm trying to do something like that:

FOR j IN (SELECT Q_COUNT,
Q_GROUP
FROM AUDITCONFG_RANDOMQUESTIONS
WHERE AUDIT_ID=i.audit_id )
LOOP
SELECT Q_COUNT,
Q_GROUP
INTO quest_count,
quest_group
FROM (SELECT Q_COUNT,
Q_GROUP
FROM AUDITCONFG_RANDOMQUESTIONS
WHERE AUDIT_ID=audit_id).Row(j)

Answer

show this:

DECLARE
    j RECORD;
BEGIN
FOR j IN (SELECT Q_COUNT, Q_GROUP FROM AUDITCONFG_RANDOMQUESTIONS WHERE AUDIT_ID=i.audit_id ) LOOP 

    DBMS_OUTPUT.PUT_LINE(j.Q_COUNT); 
    DBMS_OUTPUT.PUT_LINE(j.Q_GROUP);
END LOOP; 
Comments