Hi,
what's the way (are the ways) to execute an SQL update statement and show how many rows are affected.
update table show results
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 118
- Joined: Tue Oct 23, 2012 7:01 am
- Location: The Netherlands
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
Harry,
In SQL: select count(*) from xxx where...
If using a database resource you need to assign an alias i.e. select count(*) as count from xxx where...
If reading the data into an Ebase table you can use the rowCount variable:
Regards
Jon
In SQL: select count(*) from xxx where...
If using a database resource you need to assign an alias i.e. select count(*) as count from xxx where...
If reading the data into an Ebase table you can use the rowCount variable:
Code: Select all
tables.T1.fetchTable();
var count = tables.T1.rowCount;
Jon
0 x
-
- Ebase User
- Posts: 118
- Joined: Tue Oct 23, 2012 7:01 am
- Location: The Netherlands
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
Harry,
You can't get this information from updateTable(). You could check if there are any modified rows before issuing updatetable i.e. something like:
The isModified() only checks for an altered row and doesn't include insertions or deletions - there are additional methods for these if you need them. After updatetable has been issued all rows will return false to isModified().
Regards
Jon
You can't get this information from updateTable(). You could check if there are any modified rows before issuing updatetable i.e. something like:
Code: Select all
var t = tables.T1;
var rows = t.rows;
while (rows.next())
{
if (t.isRowModified())
{
...
}
}
Regards
Jon
0 x
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
-
- Ebase User
- Posts: 118
- Joined: Tue Oct 23, 2012 7:01 am
- Location: The Netherlands
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
-
- Ebase Staff
- Posts: 89
- Joined: Mon Sep 10, 2007 11:48 am
...or just run a select statement first using the same where clause, e.g.
Obviously there's a small overhead in doing this.
Dave
Code: Select all
select count(*) cnt from ... where....
Dave
0 x
Who is online
Users browsing this forum: No registered users and 5 guests