Reputation: 97
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
Upvotes: 0
Views: 123
Reputation: 20600
You need to use a SELECT INTO
clause:
SELECT id
INTO _name
FROM MYTABLE;
Upvotes: 1