i want to delcare a variable and use it in the same oracle sql
suppose we have the following script which is working fine
select id
,NAME
,ADDRESS
,DATE
FROM MYTABLE
WHERE COMPANY= 'LENOVO'
AND DATEBETWEEN systimestamp - INTERVAL '10' MINUTE
AND SYSTIMESTAMP
At the end of this code i want to store the value of ID in a variable and then it to delete the record, i tried this but it's not working
declare
_name varchar(100);
select id
,NAME
,ADDRESS
,DATE
FROM MYTABLE
WHERE COMPANY= 'LENOVO'
AND DATEBETWEEN systimestamp - INTERVAL '10' MINUTE
AND SYSTIMESTAMP
Returning to _name;
delete _name;
Any help please, thank you
whereclause. Thedeclareimplies you want to do this in a PL/SQL block, possibly looping around a cursor to display and delete each matching record; is that the case? It's all a bit unclear at the moment.