|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Situation : Need to delete first 10 rows at a time from a set of rows that are returned
Solutions available : 1) Fetch first as part of select subquery 2) Using ROW_NUMBER OVER...some column name 3) Select partial reocrd usign subquery Analysis : I can't use (3) Looking for solution for deleting the records using "fetch first N rows only" clause DELETE FROM TABLE_NAME WHERE COL_NAME IN (SELECT COL_NAME FROM TABLE_NAME FETCH FIRST 'N' ROWS ONLY) ERROR: db2 => delete * from staff where id in (select id from staff order by id fetch f irst 1 row only) DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0104N An unexpected token "delete" was found following "BEGIN-OF-STATEMENT". Expected tokens may include: "SELECT". SQLSTATE=42601 |
|
#2
|
|||
|
|||
|
I believe the asterisk is not supposed to be there. Try
delete from staff where id in (select id from staff order by id fetch first 1 row only) |
|
#3
|
|||
|
|||
|
DB2: How to delete using fetch first
Yeah, i tried without "*" symbol only...in first place..(typo)
The problem I found is that its availabel only in version higher than 8+ ..so its solved. By the way, do u knwo how to use Block Cursors for deletion? |
|
#4
|
|||
|
|||
|
Nope, sorry.
|
|
#5
|
|||
|
|||
|
Deletion using Cursors
Is there any BEST way to delete set of records at a time using cursors?
DB2 Version = 7.2.5 on AIX Embedded SQL on C++ |
![]() |
| Viewing: Dev Shed Forums > Databases > DB2 Development > DB2: How to delete using fetch first |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|