I am trying to make a query or a plsql that can give me an ID of a table using 2 table data but I want to change the data on each run
I mean, this is what i have
SET SERVEROUTPUT ON;
BEGIN
FOR c IN (SELECT ID_EMP FROM EMPLOYES WHERE NAME_EMP = 'data' AND LASNAME_EMP = 'data2')
LOOP
DBMS_OUTPUT.PUT_LINE ('EMPLOYE ID ' || c.ID_EMP);
END LOOP;
END;
But I want to change "data" and "data2" for each run, perhaps using something like a list where the query takes "data" and "data2"
There is a way? Thanks
If you want to run the given anonymous block as is, you can just put '&' in front of your input fields as shown below. It will always ask for your inputs before run.
Otherwise you should write a procedure with two input parameters ( first_name
and last_name
), and call the procedure as many times as you want.
SET SERVEROUTPUT ON;
BEGIN
FOR c IN (SELECT ID_EMP FROM EMPLOYES WHERE NAME_EMP = '&data' AND LASNAME_EMP = '&data2')
LOOP
DBMS_OUTPUT.PUT_LINE ('EMPLOYE ID ' || c.ID_EMP);
END LOOP;
END;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.