18 January 2026:


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.

Query with variables

ashleyd182ashleyd182 Members
edited November -1 in Sahi - Open Source
Hi,

I am currently, trying to use a variable in my SQL query. It gives me the below error.

The sahi script for the sql contains:
var db = _getDB("oracle.jdbc.OracleDriver", "jdbc:oracle:thin:....:CCMSSAND", "v4dvlpr", "v4dvlpr");
var $feeId ;
_set($feeId, '2041132');
var $feeRecord;
_set($feeRecord,"select * from FEE where FEE_ID = [feeId$]);
$rs1=db.select($feeRecord);
_alert($rs1.length);

The Error I am coming across is:
_sahi.setServerVar('\$feeRecord', "select * from FEE where FEE_ID = [feeId$]);
SyntaxError: Unterminated string constant
No trace available
Click for browser script at May 18, 2010 11:14:30 AM

Can someone please help me figure this out?

Thanks,
Ashley

Comments

  • narayannarayan Administrators
    Hi Ashley,

    SyntaxError: Unterminated string constant means that a string which was started with quotes or double quotes, was not closed properly. The end quotes are missing in the string passed to _set.
    It should have been
    _set($feeRecord,"select * from FEE where FEE_ID = [feeId$]");
    instead of
    _set($feeRecord,"select * from FEE where FEE_ID = [feeId$]);

    Btw, there are a few mistakes in your code which have been corrected below:
    var $db = _getDB("oracle.jdbc.OracleDriver", "jdbc:oracle:thin:....:CCMSSAND", "v4dvlpr", "v4dvlpr");
    var $feeId = '2041132';
    var $feeRecord = "select * from FEE where FEE_ID = " + $feeId;
    $rs1=$db.select($feeRecord);
    _alert($rs1.length);
    

    Regards,
    Narayan
  • Thanks Narayan, that worked sweet!!

    Appreciate your quick response.

    Thanks,
    Ashley
This discussion has been closed.