18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Problem with count(*)
Hi all,
I just want retrive the count of users who belongs to WORK_GROUP_ID '1' and STATUS can be 9001||9002||9003
Here is my code:
Can any one suggest me whats wrong
var db = _getDB("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@10.11.252.254:1521:qgn600r2", "userId", "password");
var $Query=[];
$Query=db.select("select count(*) from USER_PROFILE where (WORK_GROUP_ID) = '1' and STATUS_CD = '9001' or STATUS_CD = '9002' or STATUS_CD = '9003');
_alert(($Query[0]["COUNT(*)"]));
Regards
Priya
I just want retrive the count of users who belongs to WORK_GROUP_ID '1' and STATUS can be 9001||9002||9003
Here is my code:
Can any one suggest me whats wrong
var db = _getDB("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@10.11.252.254:1521:qgn600r2", "userId", "password");
var $Query=[];
$Query=db.select("select count(*) from USER_PROFILE where (WORK_GROUP_ID) = '1' and STATUS_CD = '9001' or STATUS_CD = '9002' or STATUS_CD = '9003');
_alert(($Query[0]["COUNT(*)"]));
Regards
Priya
Comments
sorry Narayana . i have used the same code what ever u have sent . it was missing only here but not in my script. please help me out
Regards
Priya
var db = _getDB("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@10.11.252.254:1521:qgn600r2", "userid", "passwrd");
var $Query=[];
$Query=db.select("select count(*) from USER_PROFILE where WORK_GROUP_ID = '1' and STATUS_CD = '9001' or STATUS_CD = '9002' or STATUS_CD = '9003'");
_alert(($Query[0]["COUNT(*)"]));
I am getting this error
Error in script:
SyntaxError: missing : after property id (<cmd>#69(eval)#1)
--Stopped Playback: FAILURE--
Can U please explain me what is this error.
Thanks for the responce. i have tried the above query , but even this is returning an "undefined value"
See if this works: Regards,
Pankaj.
This statement is executing more than once which leads to failure.
_set($Query, db.select("select count(*) from USER_PROFILE where WORK_GROUP_ID = '1' and STATUS_CD = '9001' or STATUS_CD = '9002' or STATUS_CD = '9003'"));
If i use the Query like this,means if set the returned value to a $query,
_set($Query, db.select("select count(*) from USER_PROFILE where WORK_GROUP_ID = '1' and STATUS_CD = '9001' or STATUS_CD = '9002' or STATUS_CD = '9003'"));
This error is generated,
The Query line repeats for several times and this error line is given
TypeError: 'db' is undefined
No trace available
same line if written like this :
$Query=db.select("select count(*) from USER_PROFILE where WORK_GROUP_ID = '1' and STATUS_CD = '9001' or STATUS_CD = '9002' or STATUS_CD = '9003'");
jserror SyntaxError: missing : after property id (#69(eval)#1)
And i am sure that DB connection is successful because other queries are working fine and i am facing this problem only with count(*).
Your way of using _set for db queries will not work for Sahi V2.
_set is used to assign values fetched from the browser. The db query is executed on the proxy itself and hence you no longer need to do that.
Priya:
Why don't you alert $Query[0] and see what is being returned? That will give you an idea of why you keep seeing an error.
Its giving the below syntax error hence cannot move further
Error in script:
SyntaxError: missing : after property id (<cmd>#69(eval)#1)
--Stopped Playback: FAILURE--
<cmd>#69 does this mean error in line 69,but i have only 5 lines of code.
I am still using the older version. Sorry guys
thanks for the responce
i got the solution to retrieve the total number of rows in a table without using the count,as count(*) is giving a problem
var $stmt="select * from USER_PROFILE where WORK_GROUP_ID = '1' and STATUS_CD = '9001' or STATUS_CD = '9002' or STATUS_CD = '9003'";
$rs=db.select($stmt);
_alert($rs.length);
I will check why count(*) fails.