views:

1367

answers:

2

Hi, I want to add a security on a sensitive table when I delete lines with an SQL request on a DB2 table.

I want to mimic the way MySQL allows you to limit the numbers of rows deleted in an SQL request.

Basically I want to do this with DB2 :

DELETE FROM table WHERE info = '1' LIMIT 1

Is there a way to do that with DB2 ?

+2  A: 
delete from table where id in (select id from table where info = '1' order by id fetch first 1 rows only)
Konstantinos
Thanks but I have a weird schema in which I don't have a single identifier for a line.I identify lines with a primary key composed of 2 columns.
kevin
what about using row_number() instead? ie where row_number() in ( select row_number( ...
Konstantinos
Konstantinos, it should be 'fetch first 1 rows only'. Word used should be rows and not row even if you are fetching a single row :)
Rashmi Pandit
thx for the correction, edited :)
Konstantinos
A: 
DELETE FROM table
WHERE info = '1'
FETCH FIRST 1 ROWS ONLY
elcool
Unfortunately this doesn't work for me.
kevin