update table show results

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

HarryDeBoer
Ebase User
Posts: 118
Joined: Tue Oct 23, 2012 7:01 am
Location: The Netherlands

update table show results

#1

Postby HarryDeBoer » Mon May 19, 2014 4:12 am

Hi,

what's the way (are the ways) to execute an SQL update statement and show how many rows are affected.
0 x
Kind regards,

Harry

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Mon May 19, 2014 7:14 am

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:

Code: Select all

tables.T1.fetchTable();
var count = tables.T1.rowCount;
Regards
Jon
0 x

HarryDeBoer
Ebase User
Posts: 118
Joined: Tue Oct 23, 2012 7:01 am
Location: The Netherlands

#3

Postby HarryDeBoer » Mon May 19, 2014 2:04 pm

Jon,

it's not a SELECT, it's an update 'UPDATE tTable WHERE ...' statement. I wondered what was the way to execute it and return the affected rows after execution (and show it).
0 x
Kind regards,

Harry

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#4

Postby Jon » Mon May 19, 2014 2:27 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:

Code: Select all

var t = tables.T1;
var rows = t.rows;
while (rows.next())
{
  if (t.isRowModified())
  { 
     ...
  }
}
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
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#5

Postby Jon » Mon May 19, 2014 2:38 pm

Harry,

Not sure I've answered your question. A sql update statement executed via JDBC returns the number of updated records, but doesn't tell you which ones have been changed.

Regards
Jon
0 x

HarryDeBoer
Ebase User
Posts: 118
Joined: Tue Oct 23, 2012 7:01 am
Location: The Netherlands

#6

Postby HarryDeBoer » Tue May 20, 2014 4:50 am

Hi Jon,

Thanks. isRowModified() may do the trick. Is there also a way to do this with a stored proc resource?
0 x
Kind regards,

Harry

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#7

Postby Jon » Tue May 20, 2014 7:09 am

No, at the moment Stored Procedure Resources do not support reading/writing data to or from Ebase tables. So you would need to execute your stored procedure using JDBC then loop through the result set and insert data into the table.
0 x

Dave
Ebase Staff
Posts: 89
Joined: Mon Sep 10, 2007 11:48 am

#8

Postby Dave » Tue May 20, 2014 9:04 am

...or just run a select statement first using the same where clause, e.g.

Code: Select all

select count(*) cnt from ... where....
Obviously there's a small overhead in doing this.

Dave
0 x


Who is online

Users browsing this forum: No registered users and 1 guest