Powered by Jitbit .Net Forum free trial version. dismiss

HomeProblems and issues

Post bug reports here. The forum is pre-moderated, your message will appear after being checked by us.

Using a Report to Delete rows by SQL statement Messages in this topic - RSS

falloutphil
falloutphil
Posts: 29


7/13/2017
falloutphil
falloutphil
Posts: 29
Hi,

I've tried adding the following to a report's SQL:

DELETE
FROM summary ims
USING dataload d
WHERE
d.id = ims.dataload_id AND
ims.dataload_id=$dataload_id AND
d.batch=$batch_date

I get the following error - I was hoping it might return number of rows deleted or similar?
Object reference not set to an instance of an object.

For now I think I can get around it by wrapping the DELETE in a funciton.

I confess some might say that a report that deletes is counter intuitive, but it would be useful :-)
0 link
Gleb
Gleb
Administrator
Posts: 48


7/13/2017
Gleb
Gleb
Administrator
Posts: 48
Try to add some dummy select after your delete.

For example

SELECT 'Deleted Successfully';
0 link
falloutphil
falloutphil
Posts: 29


7/13/2017
falloutphil
falloutphil
Posts: 29
Thanks - yes, as long as the last line is a select it works, so you can even do:

WITH deleted AS (DELETE FROM table WHERE condition IS TRUE RETURNING *) SELECT count(*) as rows_deleted FROM deleted;
0 link






Powered by Jitbit Forum 8.3.8.0 © 2006-2013 Jitbit Software